SHOGUN  3.2.1
 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/config.h>
16 
17 #include <shogun/lib/common.h>
18 #include <shogun/lib/Trie.h>
21 
23 #include <string>
24 #include <vector>
25 
26 namespace shogun
27 {
28 
29 #ifndef DOXYGEN_SHOULD_SKIP_THIS
30 
31 struct joint_list_struct
32 {
34  unsigned int ex_index;
36  unsigned int index;
38  unsigned int mismatch;
39 };
40 #endif
41 
44 {
45 public:
48 
59  CSpectrumMismatchRBFKernel(int32_t size, float64_t* AA_matrix_, int32_t nr_,
60  int32_t nc_, int32_t degree, int32_t max_mismatch, float64_t width);
61 
75  CStringFeatures<char>* r, int32_t size, float64_t* AA_matrix_,
76  int32_t nr_, int32_t nc_, int32_t degree, int32_t max_mismatch,
77  float64_t width);
78 
81 
88  virtual bool init(CFeatures* l, CFeatures* r);
89 
91  virtual void cleanup();
92 
98  {
99  return K_SPECTRUMMISMATCHRBF;
100  }
101 
106  virtual const char* get_name() const
107  {
108  return "SpectrumMismatchRBFKernel";
109  }
110 
116  bool set_max_mismatch(int32_t max);
117 
122  inline int32_t get_max_mismatch() const
123  {
124  return max_mismatch;
125  }
126 
132  inline bool set_degree(int32_t deg)
133  {
134  degree=deg;
135  return true;
136  }
137 
142  inline int32_t get_degree() const
143  {
144  return degree;
145  }
146 
153  bool set_AA_matrix(float64_t* AA_matrix_=NULL, int32_t nr=128, int32_t nc=
154  128);
155 
156 protected:
157 
164  float64_t AA_helper(std::string &path, const char* joint_seq,
165  unsigned int index);
166 
176  float64_t compute_helper(const char* joint_seq,
177  std::vector<unsigned int> joint_index,
178  std::vector<unsigned int> joint_mismatch, std::string path,
179  unsigned int d, const int & alen);
180 
188  void compute_helper_all(const char* joint_seq,
189  std::vector<struct joint_list_struct> & joint_list,
190  std::string path, unsigned int d);
191 
193  void compute_all();
194 
203  float64_t compute(int32_t idx_a, int32_t idx_b);
204 
207  virtual void register_params();
210  void register_alphabet();
211 
212 protected:
216  int32_t degree;
218  int32_t max_mismatch;
223 
226 
233 
234 private:
235  void init();
236 };
237 
238 }
239 
240 #endif /* _SPECTRUMMISMATCHRBFKERNEL_H__ */

SHOGUN Machine Learning Toolbox - Documentation