SpectrumRBFKernel.h

Go to the documentation of this file.
00001 /*
00002  * This program is free software; you can redistribute it and/or modify
00003  * it under the terms of the GNU General Public License as published by
00004  * the Free Software Foundation; either version 3 of the License, or
00005  * (at your option) any later version.
00006  *
00007  * Written (W) 1999-2009 Soeren Sonnenburg
00008  * Written (W) 1999-2008 Gunnar Raetsch
00009  * Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society
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> // profile
00025 #include <string> // profile
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         //int32_t* aa_to_index; // profile
00156 
00157         //double background[20]; // profile
00159         std::vector< std::vector<float64_t> > profiles; //profile
00161         std::vector<std::string> sequence_labels; // profile
00163         SGString<char>* sequences; // profile
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 /* _SPECTRUMMISMATCHRBFKERNEL_H__ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation