SHOGUN  6.1.3
LDA.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) 1999-2009 Soeren Sonnenburg
8  * Written (W) 2014 Abhijeet Kislay
9  * Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society
10  */
11 
12 #ifndef _LDA_H___
13 #define _LDA_H___
14 
15 #include <shogun/lib/config.h>
16 
17 #include <shogun/lib/common.h>
21 
22 namespace shogun
23 {
24 
27 {
31  AUTO_LDA = 10,
34  SVD_LDA = 20,
37  FLD_LDA = 30
38 };
39 
40 template <class ST> class CDenseFeatures;
99 class CLDA : public CLinearMachine
100 {
101  public:
103 
114  CLDA(
115  float64_t gamma = 0, ELDAMethod method = AUTO_LDA,
116  bool bdc_svd = true);
117 
130  CLDA(
131  float64_t gamma, CDenseFeatures<float64_t>* traindat,
132  CLabels* trainlab, ELDAMethod method = AUTO_LDA,
133  bool bdc_svd = true);
134  virtual ~CLDA();
135 
140  inline void set_gamma(float64_t gamma)
141  {
142  m_gamma=gamma;
143  }
144 
150  {
151  return m_gamma;
152  }
153 
159  {
160  return CT_LDA;
161  }
162 
167  virtual void set_features(CDotFeatures* feat)
168  {
169  if (feat->get_feature_class() != C_DENSE ||
170  feat->get_feature_type() != F_DREAL)
171  SG_ERROR("LDA requires SIMPLE REAL valued features\n")
172 
174  }
175 
177  virtual const char* get_name() const { return "LDA"; }
178 
179  protected:
188  virtual bool train_machine(CFeatures* data=NULL);
189 
196  template <typename ST>
198 
204  template <typename ST>
205  bool solver_svd();
206 
213  template <typename ST>
214  bool solver_classic();
215 
216  protected:
217 
218  void init();
219 
225  bool m_bdc_svd;
226 };
227 }
228 #endif//ifndef
virtual bool train_machine(CFeatures *data=NULL)
Definition: LDA.cpp:64
EMachineType
Definition: Machine.h:36
virtual EMachineType get_classifier_type()
Definition: LDA.h:158
The class Labels models labels, i.e. class assignments of objects.
Definition: Labels.h:43
bool solver_svd()
Definition: LDA.cpp:120
#define SG_ERROR(...)
Definition: SGIO.h:128
float64_t get_gamma()
Definition: LDA.h:149
CLDA(float64_t gamma=0, ELDAMethod method=AUTO_LDA, bool bdc_svd=true)
Definition: LDA.cpp:24
virtual void set_features(CDotFeatures *feat)
Definition: LDA.h:167
Features that support dot products among other operations.
Definition: DotFeatures.h:44
Class LDA implements regularized Linear Discriminant Analysis.
Definition: LDA.h:99
bool train_machine_templated()
Definition: LDA.cpp:105
virtual const char * get_name() const
Definition: LDA.h:177
MACHINE_PROBLEM_TYPE(PT_BINARY)
double float64_t
Definition: common.h:60
bool m_bdc_svd
Definition: LDA.h:225
virtual void set_features(CDotFeatures *feat)
float64_t m_gamma
Definition: LDA.h:221
virtual EFeatureClass get_feature_class() const =0
Class LinearMachine is a generic interface for all kinds of linear machines like classifiers.
Definition: LinearMachine.h:63
ELDAMethod
Definition: LDA.h:26
bool solver_classic()
Definition: LDA.cpp:153
The class DenseFeatures implements dense feature matrices.
Definition: LDA.h:40
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
virtual ~CLDA()
Definition: LDA.cpp:60
The class Features is the base class of all feature objects.
Definition: Features.h:69
void init()
Definition: LDA.cpp:46
ELDAMethod m_method
Definition: LDA.h:223
void set_gamma(float64_t gamma)
Definition: LDA.h:140
virtual EFeatureType get_feature_type() const =0

SHOGUN Machine Learning Toolbox - Documentation