SHOGUN  v1.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GMM.h
Go to the documentation of this file.
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) 2011 Alesis Novik
8  * Copyright (C) 2011 Berlin Institute of Technology and Max-Planck-Society
9  */
10 #ifndef _GMM_H__
11 #define _GMM_H__
12 
13 #include <shogun/lib/config.h>
14 
15 #ifdef HAVE_LAPACK
16 
19 #include <shogun/lib/common.h>
20 
21 namespace shogun
22 {
36 class CGMM : public CDistribution
37 {
38  public:
40  CGMM();
46  CGMM(int32_t n, ECovType cov_type=FULL);
53  CGMM(SGVector<CGaussian*> components, SGVector<float64_t> coefficients,
54  bool copy=false);
55  virtual ~CGMM();
56 
58  void cleanup();
59 
66  virtual bool train(CFeatures* data=NULL);
67 
76  float64_t train_em(float64_t min_cov=1e-9, int32_t max_iter=1000,
77  float64_t min_change=1e-9);
78 
89  float64_t train_smem(int32_t max_iter=100, int32_t max_cand=5,
90  float64_t min_cov=1e-9, int32_t max_em_iter=1000,
91  float64_t min_change=1e-9);
92 
98  void max_likelihood(SGMatrix<float64_t> alpha, float64_t min_cov);
99 
104  virtual int32_t get_num_model_parameters();
105 
111  virtual float64_t get_log_model_parameter(int32_t num_param);
112 
120  int32_t num_param, int32_t num_example);
121 
129  virtual float64_t get_log_likelihood_example(int32_t num_example);
130 
138  virtual float64_t get_likelihood_example(int32_t num_example);
139 
146  virtual SGVector<float64_t> get_nth_mean(int32_t num);
147 
153  virtual void set_nth_mean(SGVector<float64_t> mean, int32_t num);
154 
161  virtual SGMatrix<float64_t> get_nth_cov(int32_t num);
162 
168  virtual void set_nth_cov(SGMatrix<float64_t> cov, int32_t num);
169 
174  virtual SGVector<float64_t> get_coef();
175 
180  virtual void set_coef(SGVector<float64_t> coefficients);
181 
186  virtual SGVector<CGaussian*> get_comp();
187 
192  virtual void set_comp(SGVector<CGaussian*> components);
193 
199 
206 
208  inline virtual const char* get_name() const { return "GMM"; }
209 
210  private:
217  SGMatrix<float64_t> alpha_init(SGMatrix<float64_t> init_means);
218 
220  void register_params();
221 
231  void partial_em(int32_t comp1, int32_t comp2, int32_t comp3,
232  float64_t min_cov, int32_t max_em_iter, float64_t min_change);
233 
234  protected:
239 };
240 }
241 #endif //HAVE_LAPACK
242 #endif //_GMM_H__

SHOGUN Machine Learning Toolbox - Documentation