StateModel.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) 2012 Fernando José Iglesias García
00008  * Copyright (C) 2012 Fernando José Iglesias García
00009  */
00010 
00011 #ifndef __STATE_MODEL_H__
00012 #define __STATE_MODEL_H__
00013 
00014 #include <shogun/base/SGObject.h>
00015 #include <shogun/lib/SGMatrix.h>
00016 #include <shogun/lib/SGVector.h>
00017 #include <shogun/mathematics/Math.h>
00018 #include <shogun/structure/HMSVMLabels.h>
00019 #include <shogun/structure/StateModelTypes.h>
00020 
00021 namespace shogun
00022 {
00023 
00028 class CStateModel : public CSGObject
00029 {
00030     public:
00032         CStateModel();
00033 
00035         virtual ~CStateModel();
00036 
00038         int32_t get_num_states() const;
00039 
00041         int32_t get_num_transmission_params() const;
00042 
00053         virtual SGMatrix< float64_t > loss_matrix(CSequence* label_seq) = 0;
00054 
00064         virtual float64_t loss(CSequence* label_seq_lhs, CSequence* label_seq_rhs) = 0;
00065 
00077         virtual void reshape_emission_params(SGVector< float64_t >& emission_weights,
00078             SGVector< float64_t > w, int32_t num_feats, int32_t num_obs) = 0;
00079 
00088         virtual void reshape_transmission_params(
00089                 SGMatrix< float64_t >& transmission_weights,
00090                 SGVector< float64_t > w) = 0;
00091 
00098         virtual SGVector< int32_t > labels_to_states(CSequence* label_seq) const = 0;
00099 
00106         virtual CSequence* states_to_labels(SGVector< int32_t > state_seq) const = 0;
00107 
00121         virtual void weights_to_vector(SGVector< float64_t >& psi,
00122                 SGMatrix< float64_t > transmission_weights,
00123                 SGVector< float64_t > emission_weights,
00124                 int32_t num_feats, int32_t num_obs) const = 0;
00125 
00144         virtual SGVector< int32_t > get_monotonicity(int32_t num_free_states,
00145                 int32_t num_feats) const;
00146 
00162         SGVector< float64_t > get_start_states() const;
00163 
00179         SGVector< float64_t > get_stop_states() const;
00180 
00182         virtual const char* get_name() const { return "StateModel"; }
00183 
00184     private:
00186         void init();
00187 
00188     protected:
00190         int32_t m_num_states;
00191 
00193         int32_t m_num_transmission_params;
00194 
00196         SGMatrix< float64_t > m_state_loss_mat;
00197 
00199         SGVector< float64_t > m_p;
00200 
00202         SGVector< float64_t > m_q;
00203 
00204 }; /* class CStateModel */
00205 
00206 } /* namespace shogun */
00207 
00208 #endif /* __STATE_MODEL_H__ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation