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) 2011 Soeren Sonnenburg 00008 * Copyright (C) 2011 Berlin Institute of Technology and Max-Planck-Society 00009 */ 00010 00011 #ifndef _POSITIONAL_PWM_H__ 00012 #define _POSITIONAL_PWM_H__ 00013 00014 #include <shogun/distributions/Distribution.h> 00015 #include <shogun/features/StringFeatures.h> 00016 #include <shogun/lib/common.h> 00017 #include <shogun/mathematics/Math.h> 00018 00019 namespace shogun 00020 { 00022 class CPositionalPWM : public CDistribution 00023 { 00024 public: 00026 CPositionalPWM(); 00027 00028 virtual ~CPositionalPWM(); 00029 00036 virtual bool train(CFeatures* data=NULL); 00037 00042 virtual int32_t get_num_model_parameters(); 00043 00049 virtual float64_t get_log_model_parameter(int32_t num_param); 00050 00057 virtual float64_t get_log_derivative( 00058 int32_t num_param, int32_t num_example); 00059 00067 virtual float64_t get_log_likelihood_example(int32_t num_example); 00068 00074 float64_t get_log_likelihood_window(uint8_t* window, int32_t len, float64_t pos); 00075 00078 virtual inline float64_t get_sigma() 00079 { 00080 return m_sigma; 00081 } 00082 00087 virtual inline void set_sigma(float64_t sigma) 00088 { 00089 m_sigma=sigma; 00090 } 00091 00094 virtual inline float64_t get_mean() 00095 { 00096 return m_mean; 00097 } 00098 00103 virtual inline void set_mean(float64_t mean) 00104 { 00105 m_mean=mean; 00106 } 00107 00112 virtual inline void set_pwm(SGMatrix<float64_t> pwm) 00113 { 00114 m_pwm=pwm.matrix; 00115 m_pwm_rows=pwm.num_rows; 00116 m_pwm_cols=pwm.num_cols; 00117 } 00118 00123 virtual inline SGMatrix<float64_t> get_pwm() 00124 { 00125 return SGMatrix<float64_t>(m_pwm,m_pwm_rows,m_pwm_cols); 00126 } 00127 00132 virtual inline SGMatrix<float64_t> get_w() 00133 { 00134 return SGMatrix<float64_t>(m_w,m_w_rows,m_w_cols); 00135 } 00136 00143 virtual SGMatrix<float64_t> get_scoring(int32_t d); 00144 00148 void compute_w(int32_t num_pos); 00149 00153 void compute_scoring(int32_t max_degree); 00154 00156 inline virtual const char* get_name() const { return "PositionalPWM"; } 00157 00158 private: 00160 void register_params(); 00161 00162 protected: 00163 00165 int32_t m_pwm_rows; 00166 00168 int32_t m_pwm_cols; 00169 00171 float64_t* m_pwm; 00172 00174 float64_t m_sigma; 00175 00177 float64_t m_mean; 00178 00180 int32_t m_w_rows; 00181 00183 int32_t m_w_cols; 00184 00186 float64_t* m_w; 00187 00189 int32_t m_poim_len; 00190 00192 float64_t* m_poim; 00193 00194 }; 00195 } 00196 #endif //_POSITIONAL_PWM_H__