SHOGUN  v3.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 
21 #include <string>
22 #include <vector>
23 
24 namespace shogun
25 {
26 
27 #ifndef DOXYGEN_SHOULD_SKIP_THIS
28 
29 struct joint_list_struct
30 {
32  unsigned int ex_index;
34  unsigned int index;
36  unsigned int mismatch;
37 };
38 #endif
39 
42 {
43 public:
46 
57  CSpectrumMismatchRBFKernel(int32_t size, float64_t* AA_matrix_, int32_t nr_,
58  int32_t nc_, int32_t degree, int32_t max_mismatch, float64_t width);
59 
73  CStringFeatures<char>* r, int32_t size, float64_t* AA_matrix_,
74  int32_t nr_, int32_t nc_, int32_t degree, int32_t max_mismatch,
75  float64_t width);
76 
79 
86  virtual bool init(CFeatures* l, CFeatures* r);
87 
89  virtual void cleanup();
90 
96  {
97  return K_SPECTRUMMISMATCHRBF;
98  }
99 
104  virtual const char* get_name() const
105  {
106  return "SpectrumMismatchRBFKernel";
107  }
108 
114  bool set_max_mismatch(int32_t max);
115 
120  inline int32_t get_max_mismatch() const
121  {
122  return max_mismatch;
123  }
124 
130  inline bool set_degree(int32_t deg)
131  {
132  degree=deg;
133  return true;
134  }
135 
140  inline int32_t get_degree() const
141  {
142  return degree;
143  }
144 
151  bool set_AA_matrix(float64_t* AA_matrix_=NULL, int32_t nr=128, int32_t nc=
152  128);
153 
154 protected:
155 
162  float64_t AA_helper(std::string &path, const char* joint_seq,
163  unsigned int index);
164 
174  float64_t compute_helper(const char* joint_seq,
175  std::vector<unsigned int> joint_index,
176  std::vector<unsigned int> joint_mismatch, std::string path,
177  unsigned int d, const int & alen);
178 
186  void compute_helper_all(const char* joint_seq,
187  std::vector<struct joint_list_struct> & joint_list,
188  std::string path, unsigned int d);
189 
191  void compute_all();
192 
201  float64_t compute(int32_t idx_a, int32_t idx_b);
202 
205  virtual void register_params();
208  void register_alphabet();
209 
210 protected:
214  int32_t degree;
216  int32_t max_mismatch;
221 
224 
231 
232 private:
233  void init();
234 };
235 
236 }
237 
238 #endif /* _SPECTRUMMISMATCHRBFKERNEL_H__ */

SHOGUN Machine Learning Toolbox - Documentation