SHOGUN  4.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
PCA.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-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 
21 #include <shogun/lib/common.h>
22 
23 namespace shogun
24 {
27 {
31  AUTO = 10,
33  SVD = 20,
37  EVD = 30
38 };
39 
42 {
49 };
50 
53 {
64 };
65 
113 {
114  public:
115 
124  CPCA(bool do_whitening=false, EPCAMode mode=FIXED_NUMBER, float64_t thresh=1e-6,
125  EPCAMethod method=AUTO, EPCAMemoryMode mem_mode=MEM_REALLOCATE);
126 
133  CPCA(EPCAMethod method, bool do_whitening=false, EPCAMemoryMode mem=MEM_REALLOCATE);
134 
136  virtual ~CPCA();
137 
141  virtual bool init(CFeatures* features);
142 
144  virtual void cleanup();
145 
151 
157 
162 
166 
170 
172  virtual const char* get_name() const { return "PCA"; }
173 
175  virtual EPreprocessorType get_type() const { return P_PCA; }
176 
179 
184 
188  void set_eigenvalue_zero_tolerance(float64_t eigenvalue_zero_tolerance=1e-15);
189 
194 
195  protected:
196 
197  void init();
198 
199  protected:
200 
204  int32_t num_dim;
206  int32_t num_old_dim;
228 };
229 }
230 #endif // PCA_H_
void set_memory_mode(EPCAMemoryMode e)
Definition: PCA.cpp:369
the class DimensionReductionPreprocessor, a base class for preprocessors used to lower the dimensiona...
EPCAMemoryMode m_mem_mode
Definition: PCA.h:220
SGVector< float64_t > m_mean_vector
Definition: PCA.h:208
int32_t num_old_dim
Definition: PCA.h:206
EPreprocessorType
Definition: Preprocessor.h:32
EPCAMode m_mode
Definition: PCA.h:216
void set_eigenvalue_zero_tolerance(float64_t eigenvalue_zero_tolerance=1e-15)
Definition: PCA.cpp:374
EPCAMemoryMode
Definition: PCA.h:52
virtual void cleanup()
Definition: PCA.cpp:269
SGVector< float64_t > m_eigenvalues_vector
Definition: PCA.h:210
float64_t m_thresh
Definition: PCA.h:218
float64_t get_eigenvalue_zero_tolerance() const
Definition: PCA.cpp:379
virtual SGVector< float64_t > apply_to_feature_vector(SGVector< float64_t > vector)
Definition: PCA.cpp:332
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:25
void init()
Definition: PCA.cpp:45
SGMatrix< float64_t > m_transformation_matrix
Definition: PCA.h:202
virtual EPreprocessorType get_type() const
Definition: PCA.h:175
virtual const char * get_name() const
Definition: PCA.h:172
SGVector< float64_t > get_mean()
Definition: PCA.cpp:359
int32_t num_dim
Definition: PCA.h:204
bool m_initialized
Definition: PCA.h:212
double float64_t
Definition: common.h:50
bool m_whitening
Definition: PCA.h:214
EPCAMethod
Definition: PCA.h:26
EPCAMethod m_method
Definition: PCA.h:222
SGVector< float64_t > get_eigenvalues()
Definition: PCA.cpp:354
virtual ~CPCA()
Definition: PCA.cpp:79
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:112
EPCAMemoryMode get_memory_mode() const
Definition: PCA.cpp:364
EPCAMode
Definition: PCA.h:41
virtual SGMatrix< float64_t > apply_to_feature_matrix(CFeatures *features)
Definition: PCA.cpp:277
float64_t m_eigenvalue_zero_tolerance
Definition: PCA.h:227
SGMatrix< float64_t > get_transformation_matrix()
Definition: PCA.cpp:349

SHOGUN Machine Learning Toolbox - Documentation