SHOGUN  4.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules 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 #include <vector>
22 
23 namespace shogun
24 {
38 class CGMM : public CDistribution
39 {
40  public:
42  CGMM();
48  CGMM(int32_t n, ECovType cov_type=FULL);
55  CGMM(std::vector<CGaussian*> components, SGVector<float64_t> coefficients,
56  bool copy=false);
57  virtual ~CGMM();
58 
60  void cleanup();
61 
68  virtual bool train(CFeatures* data=NULL);
69 
78  float64_t train_em(float64_t min_cov=1e-9, int32_t max_iter=1000,
79  float64_t min_change=1e-9);
80 
91  float64_t train_smem(int32_t max_iter=100, int32_t max_cand=5,
92  float64_t min_cov=1e-9, int32_t max_em_iter=1000,
93  float64_t min_change=1e-9);
94 
100  void max_likelihood(SGMatrix<float64_t> alpha, float64_t min_cov);
101 
106  virtual int32_t get_num_model_parameters();
107 
113  virtual float64_t get_log_model_parameter(int32_t num_param);
114 
116  index_t get_num_components() const;
117 
122  CDistribution* get_component(index_t index) const;
123 
131  int32_t num_param, int32_t num_example);
132 
140  virtual float64_t get_log_likelihood_example(int32_t num_example);
141 
149  virtual float64_t get_likelihood_example(int32_t num_example);
150 
157  virtual SGVector<float64_t> get_nth_mean(int32_t num);
158 
164  virtual void set_nth_mean(SGVector<float64_t> mean, int32_t num);
165 
172  virtual SGMatrix<float64_t> get_nth_cov(int32_t num);
173 
179  virtual void set_nth_cov(SGMatrix<float64_t> cov, int32_t num);
180 
185  virtual SGVector<float64_t> get_coef();
186 
191  virtual void set_coef(const SGVector<float64_t> coefficients);
192 
197  virtual std::vector<CGaussian*> get_comp();
198 
203  virtual void set_comp(std::vector<CGaussian*> components);
204 
210 
217 
219  virtual const char* get_name() const { return "GMM"; }
220 
221  private:
228  SGMatrix<float64_t> alpha_init(SGMatrix<float64_t> init_means);
229 
231  void register_params();
232 
242  void partial_em(int32_t comp1, int32_t comp2, int32_t comp3,
243  float64_t min_cov, int32_t max_em_iter, float64_t min_change);
244 
245  protected:
247  std::vector<CGaussian*> m_components;
250 };
251 }
252 #endif //HAVE_LAPACK
253 #endif //_GMM_H__
virtual float64_t get_likelihood_example(int32_t num_example)
Definition: GMM.cpp:669
virtual int32_t get_num_model_parameters()
Definition: GMM.cpp:635
SGVector< float64_t > m_coefficients
Definition: GMM.h:249
float64_t train_smem(int32_t max_iter=100, int32_t max_cand=5, float64_t min_cov=1e-9, int32_t max_em_iter=1000, float64_t min_change=1e-9)
Definition: GMM.cpp:200
std::vector< CGaussian * > m_components
Definition: GMM.h:247
int32_t index_t
Definition: common.h:62
virtual float64_t get_log_derivative(int32_t num_param, int32_t num_example)
Definition: GMM.cpp:657
void max_likelihood(SGMatrix< float64_t > alpha, float64_t min_cov)
Definition: GMM.cpp:519
virtual void set_nth_mean(SGVector< float64_t > mean, int32_t num)
Definition: GMM.cpp:692
virtual SGVector< float64_t > get_coef()
Definition: GMM.cpp:710
Base class Distribution from which all methods implementing a distribution are derived.
Definition: Distribution.h:44
full covariance
Definition: Gaussian.h:36
virtual ~CGMM()
Definition: GMM.cpp:98
SGVector< float64_t > sample()
Definition: GMM.cpp:765
float64_t train_em(float64_t min_cov=1e-9, int32_t max_iter=1000, float64_t min_change=1e-9)
Definition: GMM.cpp:128
virtual SGVector< float64_t > get_nth_mean(int32_t num)
Definition: GMM.cpp:686
CDistribution * get_component(index_t index) const
Definition: GMM.cpp:652
virtual std::vector< CGaussian * > get_comp()
Definition: GMM.cpp:720
double float64_t
Definition: common.h:50
ECovType
Definition: Gaussian.h:33
virtual const char * get_name() const
Definition: GMM.h:219
void cleanup()
Definition: GMM.cpp:104
virtual void set_coef(const SGVector< float64_t > coefficients)
Definition: GMM.cpp:715
virtual void set_nth_cov(SGMatrix< float64_t > cov, int32_t num)
Definition: GMM.cpp:704
SGVector< float64_t > cluster(SGVector< float64_t > point)
Definition: GMM.cpp:783
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
virtual float64_t get_log_likelihood_example(int32_t num_example)
Definition: GMM.cpp:663
virtual float64_t get_log_model_parameter(int32_t num_param)
Definition: GMM.cpp:640
The class Features is the base class of all feature objects.
Definition: Features.h:68
virtual SGMatrix< float64_t > get_nth_cov(int32_t num)
Definition: GMM.cpp:698
virtual bool train(CFeatures *data=NULL)
Definition: GMM.cpp:113
virtual void set_comp(std::vector< CGaussian * > components)
Definition: GMM.cpp:725
Gaussian Mixture Model interface.
Definition: GMM.h:38
index_t get_num_components() const
Definition: GMM.cpp:647

SHOGUN Machine Learning Toolbox - Documentation