SHOGUN  4.1.0
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
LDA.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) 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 #ifdef HAVE_EIGEN3
18 #include <shogun/lib/common.h>
22 
23 namespace shogun
24 {
25 
28 {
32  AUTO_LDA = 10,
35  SVD_LDA = 20,
38  FLD_LDA = 30
39 };
40 
41 template <class ST> class CDenseFeatures;
90 class CLDA : public CLinearMachine
91 {
92  public:
94 
100  CLDA(float64_t gamma=0, ELDAMethod method=AUTO_LDA);
101 
110  CLDA(float64_t gamma, CDenseFeatures<float64_t>* traindat, CLabels* trainlab, ELDAMethod method=AUTO_LDA);
111  virtual ~CLDA();
112 
117  inline void set_gamma(float64_t gamma)
118  {
119  m_gamma=gamma;
120  }
121 
127  {
128  return m_gamma;
129  }
130 
136  {
137  return CT_LDA;
138  }
139 
144  virtual void set_features(CDotFeatures* feat)
145  {
146  if (feat->get_feature_class() != C_DENSE ||
147  feat->get_feature_type() != F_DREAL)
148  SG_ERROR("LDA requires SIMPLE REAL valued features\n")
149 
151  }
152 
154  virtual const char* get_name() const { return "LDA"; }
155 
156  protected:
165  virtual bool train_machine(CFeatures* data=NULL);
166 
167  protected:
168 
169  void init();
170 
175 };
176 }
177 #endif//HAVE_EIGEN3
178 #endif//ifndef
virtual bool train_machine(CFeatures *data=NULL)
Definition: LDA.cpp:59
EMachineType
Definition: Machine.h:33
The class DenseFeatures implements dense feature matrices.
Definition: LDA.h:41
virtual EMachineType get_classifier_type()
Definition: LDA.h:135
The class Labels models labels, i.e. class assignments of objects.
Definition: Labels.h:43
#define SG_ERROR(...)
Definition: SGIO.h:129
float64_t get_gamma()
Definition: LDA.h:126
virtual void set_features(CDotFeatures *feat)
Definition: LDA.h:144
Features that support dot products among other operations.
Definition: DotFeatures.h:44
Class LDA implements regularized Linear Discriminant Analysis.
Definition: LDA.h:90
virtual const char * get_name() const
Definition: LDA.h:154
MACHINE_PROBLEM_TYPE(PT_BINARY)
CLDA(float64_t gamma=0, ELDAMethod method=AUTO_LDA)
Definition: LDA.cpp:26
double float64_t
Definition: common.h:50
virtual void set_features(CDotFeatures *feat)
float64_t m_gamma
Definition: LDA.h:172
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:27
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
virtual ~CLDA()
Definition: LDA.cpp:55
The class Features is the base class of all feature objects.
Definition: Features.h:68
void init()
Definition: LDA.cpp:45
ELDAMethod m_method
Definition: LDA.h:174
void set_gamma(float64_t gamma)
Definition: LDA.h:117
virtual EFeatureType get_feature_type() const =0

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