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 "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> // profile
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(); // profile
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         //int32_t* aa_to_index; // profile
00132 
00133         //double background[20]; // profile
00134         std::vector< std::vector<float64_t> > profiles; //profile
00135         std::vector<std::string> sequence_labels; // profile
00136         T_STRING<char>* sequences; // profile
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 /* _SPECTRUMMISMATCHRBFKERNEL_H__ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation