SHOGUN
v3.2.0
|
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) 2012 Fernando Jose Iglesias Garcia 00008 * Copyright (C) 2012 Fernando Jose Iglesias Garcia 00009 */ 00010 00011 #ifndef _HMSVM_MODEL__H__ 00012 #define _HMSVM_MODEL__H__ 00013 00014 #include <shogun/structure/StructuredModel.h> 00015 #include <shogun/structure/SequenceLabels.h> 00016 #include <shogun/structure/StateModelTypes.h> 00017 #include <shogun/structure/StateModel.h> 00018 00019 namespace shogun 00020 { 00021 00022 enum EStateModelType; 00023 00029 class CHMSVMModel : public CStructuredModel 00030 { 00031 public: 00033 CHMSVMModel(); 00034 00043 CHMSVMModel(CFeatures* features, CStructuredLabels* labels, EStateModelType smt, int32_t num_obs=0, bool use_plifs=false); 00044 00046 virtual ~CHMSVMModel(); 00047 00052 virtual int32_t get_dim() const; 00053 00066 virtual SGVector< float64_t > get_joint_feature_vector(int32_t feat_idx, CStructuredData* y); 00067 00081 virtual CResultSet* argmax(SGVector< float64_t > w, int32_t feat_idx, bool const training = true); 00082 00090 virtual float64_t delta_loss(CStructuredData* y1, CStructuredData* y2); 00091 00104 virtual void init_primal_opt( 00105 float64_t regularization, 00106 SGMatrix< float64_t > & A, SGVector< float64_t > a, 00107 SGMatrix< float64_t > B, SGVector< float64_t > & b, 00108 SGVector< float64_t > lb, SGVector< float64_t > ub, 00109 SGMatrix < float64_t > & C); 00110 00115 virtual bool check_training_setup() const; 00116 00125 virtual int32_t get_num_aux() const; 00126 00134 virtual int32_t get_num_aux_con() const; 00135 00140 void set_use_plifs(bool use_plifs); 00141 00147 virtual void init_training(); 00148 00153 SGMatrix< float64_t > get_transmission_weights() const; 00154 00159 SGVector< float64_t > get_emission_weights() const; 00160 00165 CStateModel* get_state_model() const; 00166 00171 virtual const char* get_name() const { return "HMSVMModel"; } 00172 00173 private: 00174 /* internal initialization */ 00175 void init(); 00176 00177 private: 00179 int32_t m_num_obs; 00180 00182 int32_t m_num_aux; 00183 00185 CStateModel* m_state_model; 00186 00188 SGMatrix< float64_t > m_transmission_weights; 00189 00191 SGVector< float64_t > m_emission_weights; 00192 00194 int32_t m_num_plif_nodes; 00195 00197 CDynamicObjectArray* m_plif_matrix; 00198 00200 bool m_use_plifs; 00201 00202 }; /* class CHMSVMModel */ 00203 00204 } /* namespace shogun */ 00205 00206 #endif /* _HMSVM_MODEL__H__ */