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 <shogun/lib/common.h>
00016 #include <shogun/lib/Trie.h>
00017 #include <shogun/kernel/StringKernel.h>
00018 #include <shogun/features/StringFeatures.h>
00019
00020
00021 #include <shogun/lib/Array.h>
00022 #include <shogun/lib/Array2.h>
00023
00024 #include <vector>
00025 #include <string>
00026
00027 namespace shogun
00028 {
00029
00031 class CSpectrumRBFKernel: public CStringKernel<char>
00032 {
00033 public:
00035 CSpectrumRBFKernel();
00036
00043 CSpectrumRBFKernel(int32_t size, float64_t* AA_matrix, int32_t degree, float64_t width);
00044
00054 CSpectrumRBFKernel(
00055 CStringFeatures<char>* l, CStringFeatures<char>* r, int32_t size, float64_t* AA_matrix, int32_t degree, float64_t width);
00056
00058 virtual ~CSpectrumRBFKernel();
00059
00066 virtual bool init(CFeatures* l, CFeatures* r);
00067
00069 virtual void cleanup();
00070
00075 int32_t get_degree() const
00076 {
00077 return degree;
00078 }
00079
00084 virtual EKernelType get_kernel_type() { return K_SPECTRUMRBF; }
00085
00090 virtual const char* get_name() const { return "SpectrumRBFKernel"; }
00091
00097 inline bool set_degree(int32_t deg) { degree=deg; return true; }
00098
00103 inline int32_t get_degree() { return degree; }
00104
00108 bool set_AA_matrix(float64_t* AA_matrix_);
00109
00110 protected:
00111
00118 float64_t AA_helper(const char* path, const int degree, const char* joint_seq, unsigned int index);
00119
00121 void read_profiles_and_sequences();
00122
00131 float64_t compute(int32_t idx_a, int32_t idx_b);
00132
00134 virtual void remove_lhs();
00136 virtual void register_param();
00138 void register_alphabet();
00139
00140
00141 protected:
00143 CAlphabet* alphabet;
00145 int32_t degree;
00147 int32_t max_mismatch;
00149 float64_t* AA_matrix ;
00151 int32_t AA_matrix_length;
00153 float64_t width;
00154
00155
00156
00157
00159 std::vector< std::vector<float64_t> > profiles;
00161 std::vector<std::string> sequence_labels;
00163 SGString<char>* sequences;
00165 CStringFeatures<char>* string_features;
00167 int32_t nof_sequences;
00169 int32_t max_sequence_length;
00170
00172 bool initialized;
00174 CArray2<float64_t> kernel_matrix;
00176 int32_t target_letter_0;
00177
00178 private:
00179 void init();
00180 };
00181
00182 }
00183
00184
00185
00186 #endif