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
00026 namespace shogun
00027 {
00028
00029 class CSpectrumRBFKernel: public CStringKernel<char>
00030 {
00031 public:
00032
00038 CSpectrumRBFKernel(int32_t size, float64_t* AA_matrix, int32_t degree, float64_t width);
00039
00046 CSpectrumRBFKernel(
00047 CStringFeatures<char>* l, CStringFeatures<char>* r, int32_t size, float64_t* AA_matrix, int32_t degree, float64_t width);
00048
00049 virtual ~CSpectrumRBFKernel();
00050
00057 virtual bool init(CFeatures* l, CFeatures* r);
00058
00060 virtual void cleanup();
00061
00066 int32_t get_degree() const
00067 {
00068 return degree;
00069 }
00070
00075 virtual EKernelType get_kernel_type() { return K_SPECTRUMMISMATCHRBF; }
00076
00081 virtual const char* get_name() const { return "SpectrumMismatchRBF"; }
00082
00088 inline bool set_degree(int32_t deg) { degree=deg; return true; }
00089
00094 inline int32_t get_degree() { return degree; }
00095
00096
00097 bool set_AA_matrix(float64_t* AA_matrix_);
00098
00099 protected:
00100
00101 float64_t AA_helper(const char* path, const int degree, const char* joint_seq, unsigned int index);
00102
00103 void read_profiles_and_sequences();
00104
00105
00114 float64_t compute(int32_t idx_a, int32_t idx_b);
00115
00117 virtual void remove_lhs();
00118
00119
00120 protected:
00122 CAlphabet* alphabet;
00124 int32_t degree;
00127 float64_t* AA_matrix ;
00129 float64_t width;
00130
00131
00132
00133
00134 std::vector< std::vector<float64_t> > profiles;
00135 std::vector<std::string> sequence_labels;
00136 T_STRING<char>* sequences;
00137 CStringFeatures<char>* string_features;
00138 int32_t nof_sequences;
00139 int32_t max_sequence_length;
00140
00142 bool initialized;
00143
00144 int32_t max_mismatch;
00145
00146 CArray2<float64_t> kernel_matrix ;
00147 int target_letter_0 ;
00148 };
00149
00150 }
00151
00152
00153
00154 #endif