SHOGUN  3.2.1
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
LinearHMM.h
浏览该文件的文档.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * Written (W) 1999-2009 Soeren Sonnenburg
8  * Written (W) 1999-2008 Gunnar Raetsch
9  * Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society
10  */
11 
12 #ifndef _LINEARHMM_H__
13 #define _LINEARHMM_H__
14 
16 #include <shogun/labels/Labels.h>
18 
19 namespace shogun
20 {
39 class CLinearHMM : public CDistribution
40 {
41  public:
43  CLinearHMM();
44 
50 
56  CLinearHMM(int32_t p_num_features, int32_t p_num_symbols);
57 
58  virtual ~CLinearHMM();
59 
68  virtual bool train(CFeatures* data=NULL);
69 
77  bool train(
78  const int32_t* indizes, int32_t num_indizes,
80 
87  float64_t get_log_likelihood_example(uint16_t* vector, int32_t len);
88 
95  float64_t get_likelihood_example(uint16_t* vector, int32_t len);
96 
102  float64_t get_likelihood_example(int32_t num_example);
103 
109  virtual float64_t get_log_likelihood_example(int32_t num_example);
110 
118  int32_t num_param, int32_t num_example);
119 
127  uint16_t obs, int32_t pos)
128  {
129  return 1.0/transition_probs[pos*num_symbols+obs];
130  }
131 
139  uint16_t* vector, int32_t len, int32_t pos)
140  {
141  ASSERT(pos<len)
142  return get_likelihood_example(vector, len)/transition_probs[pos*num_symbols+vector[pos]];
143  }
144 
149  virtual int32_t get_sequence_length() { return sequence_length; }
150 
155  virtual int32_t get_num_symbols() { return num_symbols; }
156 
161  virtual int32_t get_num_model_parameters() { return num_params; }
162 
170  uint16_t obs, int32_t position)
171  {
172  return log_transition_probs[position*num_symbols+obs];
173  }
174 
180  virtual float64_t get_log_model_parameter(int32_t num_param)
181  {
183  ASSERT(num_param<num_params)
184 
185  return log_transition_probs[num_param];
186  }
187 
193 
199  virtual bool set_log_transition_probs(const SGVector<float64_t> probs);
200 
206 
212  virtual bool set_transition_probs(const SGVector<float64_t> probs);
213 
215  virtual const char* get_name() const { return "LinearHMM"; }
216 
217  protected:
218  virtual void load_serializable_post() throw (ShogunException);
219 
220  private:
221  void init();
222 
223  protected:
227  int32_t num_symbols;
229  int32_t num_params;
234 };
235 }
236 #endif

SHOGUN 机器学习工具包 - 项目文档