SHOGUN  v2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SpectrumMismatchRBFKernel.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * Written (W) 1999-2009 Soeren Sonnenburg
8  * Written (W) 1999-2008 Gunnar Raetsch
9  * Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society
10  */
11 
12 #ifndef _SPECTRUMMISMATCHRBFKERNEL_H___
13 #define _SPECTRUMMISMATCHRBFKERNEL_H___
14 
15 #include <shogun/lib/common.h>
16 #include <shogun/lib/Trie.h>
19 
20 
22 #include <string>
23 #include <vector>
24 
25 namespace shogun
26 {
27 
28 #ifndef DOXYGEN_SHOULD_SKIP_THIS
29 
30 struct joint_list_struct
31 {
33  unsigned int ex_index;
35  unsigned int index;
37  unsigned int mismatch;
38 };
39 #endif
40 
43 {
44  public:
47 
58  CSpectrumMismatchRBFKernel(int32_t size, float64_t* AA_matrix_, int32_t nr_, int32_t nc_, int32_t degree, int32_t max_mismatch, float64_t width);
59 
74  int32_t size, float64_t* AA_matrix_, int32_t nr_,
75  int32_t nc_, int32_t degree, int32_t max_mismatch, float64_t width);
76 
79 
86  virtual bool init(CFeatures* l, CFeatures* r);
87 
89  virtual void cleanup();
90 
96 
101  virtual const char* get_name() const { return "SpectrumMismatchRBFKernel"; }
102 
108  bool set_max_mismatch(int32_t max);
109 
114  inline int32_t get_max_mismatch() const { return max_mismatch; }
115 
121  inline bool set_degree(int32_t deg) { degree=deg; return true; }
122 
127  inline int32_t get_degree() const { return degree; }
128 
135  bool set_AA_matrix(float64_t* AA_matrix_=NULL, int32_t nr=128, int32_t nc=128);
136 
137  protected:
138 
145  float64_t AA_helper(std::string &path, const char* joint_seq, unsigned int index);
146 
156  float64_t compute_helper(const char* joint_seq,
157  std::vector<unsigned int> joint_index, std::vector<unsigned int> joint_mismatch,
158  std::string path, unsigned int d,
159  const int & alen) ;
160 
168  void compute_helper_all(const char* joint_seq,
169  std::vector<struct joint_list_struct> & joint_list,
170  std::string path, unsigned int d);
171 
173  void compute_all();
174 
183  float64_t compute(int32_t idx_a, int32_t idx_b);
184 
186  virtual void remove_lhs();
189  virtual void register_params();
192  void register_alphabet();
193 
194 
195  protected:
199  int32_t degree;
201  int32_t max_mismatch;
208 
211 
218 
219  private:
220  void init();
221 };
222 
223 }
224 
225 #endif /* _SPECTRUMMISMATCHRBFKERNEL_H__ */

SHOGUN Machine Learning Toolbox - Documentation