Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef _SPECTRUMRBFKERNEL_H___
00013 #define _SPECTRUMRBFKERNEL_H___
00014
00015 #include "lib/common.h"
00016 #include "lib/Trie.h"
00017 #include "kernel/StringKernel.h"
00018 #include "features/StringFeatures.h"
00019
00020
00021 #include "lib/Array.h"
00022 #include "lib/Array2.h"
00023
00024 #include <vector>
00025 #include <string>
00026
00027 namespace shogun
00028 {
00029
00030 class CSpectrumRBFKernel: public CStringKernel<char>
00031 {
00032 public:
00034 CSpectrumRBFKernel(void);
00035
00041 CSpectrumRBFKernel(int32_t size, float64_t* AA_matrix, int32_t degree, float64_t width);
00042
00049 CSpectrumRBFKernel(
00050 CStringFeatures<char>* l, CStringFeatures<char>* r, int32_t size, float64_t* AA_matrix, int32_t degree, float64_t width);
00051
00052 virtual ~CSpectrumRBFKernel();
00053
00060 virtual bool init(CFeatures* l, CFeatures* r);
00061
00063 virtual void cleanup();
00064
00069 int32_t get_degree() const
00070 {
00071 return degree;
00072 }
00073
00078 virtual EKernelType get_kernel_type() { return K_SPECTRUMMISMATCHRBF; }
00079
00084 virtual const char* get_name() const { return "SpectrumMismatchRBF"; }
00085
00091 inline bool set_degree(int32_t deg) { degree=deg; return true; }
00092
00097 inline int32_t get_degree() { return degree; }
00098
00099
00100 bool set_AA_matrix(float64_t* AA_matrix_);
00101
00102 protected:
00103
00104 float64_t AA_helper(const char* path, const int degree, const char* joint_seq, unsigned int index);
00105
00106 void read_profiles_and_sequences();
00107
00108
00117 float64_t compute(int32_t idx_a, int32_t idx_b);
00118
00120 virtual void remove_lhs();
00121
00122
00123 protected:
00125 CAlphabet* alphabet;
00127 int32_t degree;
00130 float64_t* AA_matrix ;
00132 float64_t width;
00133
00134
00135
00136
00137 std::vector< std::vector<float64_t> > profiles;
00138 std::vector<std::string> sequence_labels;
00139 TString<char>* sequences;
00140 CStringFeatures<char>* string_features;
00141 int32_t nof_sequences;
00142 int32_t max_sequence_length;
00143
00145 bool initialized;
00146
00147 int32_t max_mismatch;
00148
00149 CArray2<float64_t> kernel_matrix ;
00150 int32_t target_letter_0 ;
00151 };
00152
00153 }
00154
00155
00156
00157 #endif