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 _CFKFEATURES__H__ 00013 #define _CFKFEATURES__H__ 00014 00015 #include "features/SimpleFeatures.h" 00016 #include "distributions/HMM.h" 00017 00018 namespace shogun 00019 { 00020 00021 template <class T> class CSimpleFeatures; 00022 class CHMM; 00023 00041 class CFKFeatures: public CSimpleFeatures<float64_t> 00042 { 00043 public: 00045 CFKFeatures(); 00046 00053 CFKFeatures(int32_t size, CHMM* p, CHMM* n); 00054 00056 CFKFeatures(const CFKFeatures &orig); 00057 00058 virtual ~CFKFeatures(); 00059 00065 void set_models(CHMM* p, CHMM* n); 00066 00071 inline void set_a(float64_t a) 00072 { 00073 weight_a=a; 00074 } 00075 00080 inline float64_t get_a() 00081 { 00082 return weight_a; 00083 } 00084 00089 virtual float64_t* set_feature_matrix(); 00090 00096 float64_t set_opt_a(float64_t a=-1); 00097 00102 inline float64_t get_weight_a() { return weight_a; }; 00103 00105 inline virtual const char* get_name() const { return "FKFeatures"; } 00106 00107 protected: 00115 virtual float64_t* compute_feature_vector( 00116 int32_t num, int32_t& len, float64_t* target=NULL); 00117 00124 void compute_feature_vector(float64_t* addr, int32_t num, int32_t& len); 00125 00131 float64_t deriv_a(float64_t a, int32_t dimension=-1) ; 00132 00133 private: 00134 void init(); 00135 00136 protected: 00138 CHMM* pos; 00140 CHMM* neg; 00142 float64_t* pos_prob; 00144 float64_t* neg_prob; 00146 float64_t weight_a; 00147 }; 00148 } 00149 #endif