SHOGUN  4.1.0
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
PCA.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-2008 Gunnar Raetsch
8  * Written (W) 1999-2008,2011 Soeren Sonnenburg
9  * Written (W) 2014 Parijat Mazumdar
10  * Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society
11  * Copyright (C) 2011 Berlin Institute of Technology
12  */
13 
14 #ifndef PCA_H_
15 #define PCA_H_
16 
17 #include <shogun/lib/config.h>
18 
19 #ifdef HAVE_EIGEN3
22 #include <shogun/lib/common.h>
23 
24 namespace shogun
25 {
28 {
32  AUTO = 10,
34  SVD = 20,
38  EVD = 30
39 };
40 
43 {
50 };
51 
54 {
65 };
66 
114 {
115  public:
116 
125  CPCA(bool do_whitening=false, EPCAMode mode=FIXED_NUMBER, float64_t thresh=1e-6,
126  EPCAMethod method=AUTO, EPCAMemoryMode mem_mode=MEM_REALLOCATE);
127 
134  CPCA(EPCAMethod method, bool do_whitening=false, EPCAMemoryMode mem=MEM_REALLOCATE);
135 
137  virtual ~CPCA();
138 
142  virtual bool init(CFeatures* features);
143 
145  virtual void cleanup();
146 
152 
158 
163 
167 
171 
173  virtual const char* get_name() const { return "PCA"; }
174 
176  virtual EPreprocessorType get_type() const { return P_PCA; }
177 
180 
185 
189  void set_eigenvalue_zero_tolerance(float64_t eigenvalue_zero_tolerance=1e-15);
190 
195 
196  protected:
197 
198  void init();
199 
200  protected:
201 
205  int32_t num_dim;
207  int32_t num_old_dim;
229 };
230 }
231 #endif // HAVE_EIGEN3
232 #endif // PCA_H_
void set_memory_mode(EPCAMemoryMode e)
Definition: PCA.cpp:370
the class DimensionReductionPreprocessor, a base class for preprocessors used to lower the dimensiona...
EPCAMemoryMode m_mem_mode
Definition: PCA.h:221
SGVector< float64_t > m_mean_vector
Definition: PCA.h:209
int32_t num_old_dim
Definition: PCA.h:207
EPreprocessorType
Definition: Preprocessor.h:32
EPCAMode m_mode
Definition: PCA.h:217
void set_eigenvalue_zero_tolerance(float64_t eigenvalue_zero_tolerance=1e-15)
Definition: PCA.cpp:375
EPCAMemoryMode
Definition: PCA.h:53
virtual void cleanup()
Definition: PCA.cpp:270
SGVector< float64_t > m_eigenvalues_vector
Definition: PCA.h:211
float64_t m_thresh
Definition: PCA.h:219
float64_t get_eigenvalue_zero_tolerance() const
Definition: PCA.cpp:380
virtual SGVector< float64_t > apply_to_feature_vector(SGVector< float64_t > vector)
Definition: PCA.cpp:333
CPCA(bool do_whitening=false, EPCAMode mode=FIXED_NUMBER, float64_t thresh=1e-6, EPCAMethod method=AUTO, EPCAMemoryMode mem_mode=MEM_REALLOCATE)
Definition: PCA.cpp:26
void init()
Definition: PCA.cpp:46
SGMatrix< float64_t > m_transformation_matrix
Definition: PCA.h:203
virtual EPreprocessorType get_type() const
Definition: PCA.h:176
virtual const char * get_name() const
Definition: PCA.h:173
SGVector< float64_t > get_mean()
Definition: PCA.cpp:360
int32_t num_dim
Definition: PCA.h:205
bool m_initialized
Definition: PCA.h:213
double float64_t
Definition: common.h:50
bool m_whitening
Definition: PCA.h:215
EPCAMethod
Definition: PCA.h:27
EPCAMethod m_method
Definition: PCA.h:223
SGVector< float64_t > get_eigenvalues()
Definition: PCA.cpp:355
virtual ~CPCA()
Definition: PCA.cpp:80
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
The class Features is the base class of all feature objects.
Definition: Features.h:68
Preprocessor PCA performs principial component analysis on input feature vectors/matrices. When the init method in PCA is called with proper feature matrix X (with say N number of vectors and D feature dimension), a transformation matrix is computed and stored internally. This transformation matrix is then used to transform all D-dimensional feature vectors or feature matrices (with D feature dimensions) supplied via apply_to_feature_matrix or apply_to_feature_vector methods. This tranformation outputs the T-Dimensional approximation of all these input vectors and matrices (where T<=min(D,N)). The transformation matrix is essentially a DxT matrix, the columns of which correspond to the eigenvectors of the covariance matrix(XX') having top T eigenvalues.
Definition: PCA.h:113
EPCAMemoryMode get_memory_mode() const
Definition: PCA.cpp:365
EPCAMode
Definition: PCA.h:42
virtual SGMatrix< float64_t > apply_to_feature_matrix(CFeatures *features)
Definition: PCA.cpp:278
float64_t m_eigenvalue_zero_tolerance
Definition: PCA.h:228
SGMatrix< float64_t > get_transformation_matrix()
Definition: PCA.cpp:350

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