SHOGUN  v1.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
List of all members | Public Member Functions | Protected Member Functions | Protected Attributes
CPCA Class Reference

Detailed Description

Preprocessor PCACut performs principial component analysis on the input vectors and keeps only the n eigenvectors with eigenvalues above a certain threshold.

On preprocessing the stored covariance matrix is used to project vectors into eigenspace only returning vectors of reduced dimension n. Optional whitening is performed.

This is only useful if the dimensionality of the data is rather low, as the covariance matrix is of size num_feat*num_feat. Note that vectors don't have to have zero mean as it is substracted.

Definition at line 48 of file PCA.h.

Inheritance diagram for CPCA:
Inheritance graph
[legend]

Public Member Functions

 CPCA (bool do_whitening=false, EPCAMode mode=FIXED_NUMBER, float64_t thresh=1e-6)
virtual ~CPCA ()
virtual bool init (CFeatures *features)
virtual void cleanup ()
virtual SGMatrix< float64_tapply_to_feature_matrix (CFeatures *features)
virtual SGVector< float64_tapply_to_feature_vector (SGVector< float64_t > vector)
SGMatrix< float64_tget_transformation_matrix ()
SGVector< float64_tget_eigenvalues ()
SGVector< float64_tget_mean ()
virtual const char * get_name () const
virtual EPreprocessorType get_type () const
- Public Member Functions inherited from CDimensionReductionPreprocessor
 CDimensionReductionPreprocessor ()
 CDimensionReductionPreprocessor (CEmbeddingConverter *converter)
virtual ~CDimensionReductionPreprocessor ()
void set_target_dim (int32_t dim)
int32_t get_target_dim () const
void set_distance (CDistance *distance)
CDistanceget_distance () const
void set_kernel (CKernel *kernel)
CKernelget_kernel () const
- Public Member Functions inherited from CSimplePreprocessor< float64_t >
 CSimplePreprocessor ()
virtual EFeatureClass get_feature_class ()
 return that we are simple features (just fixed size matrices)
virtual EFeatureType get_feature_type ()
 return feature type
- Public Member Functions inherited from CPreprocessor
 CPreprocessor ()
virtual ~CPreprocessor ()
- Public Member Functions inherited from CSGObject
 CSGObject ()
 CSGObject (const CSGObject &orig)
virtual ~CSGObject ()
virtual bool is_generic (EPrimitiveType *generic) const
template<class T >
void set_generic ()
void unset_generic ()
virtual void print_serializable (const char *prefix="")
virtual bool save_serializable (CSerializableFile *file, const char *prefix="")
virtual bool load_serializable (CSerializableFile *file, const char *prefix="")
void set_global_io (SGIO *io)
SGIOget_global_io ()
void set_global_parallel (Parallel *parallel)
Parallelget_global_parallel ()
void set_global_version (Version *version)
Versionget_global_version ()
SGVector< char * > get_modelsel_names ()
char * get_modsel_param_descr (const char *param_name)
index_t get_modsel_param_index (const char *param_name)

Protected Member Functions

void init ()

Protected Attributes

SGMatrix< float64_tm_transformation_matrix
int32_t num_dim
int32_t num_old_dim
SGVector< float64_tm_mean_vector
SGVector< float64_tm_eigenvalues_vector
bool m_initialized
bool m_whitening
EPCAMode m_mode
float64_t thresh
- Protected Attributes inherited from CDimensionReductionPreprocessor
int32_t m_target_dim
CDistancem_distance
CKernelm_kernel
CEmbeddingConverterm_converter

Additional Inherited Members

- Public Attributes inherited from CSGObject
SGIOio
Parallelparallel
Versionversion
Parameterm_parameters
Parameterm_model_selection_parameters

Constructor & Destructor Documentation

CPCA ( bool  do_whitening = false,
EPCAMode  mode = FIXED_NUMBER,
float64_t  thresh = 1e-6 
)

constructor

Parameters
do_whiteningdo whitening
modemode of pca
threshthreshold

Definition at line 27 of file PCA.cpp.

~CPCA ( )
virtual

destructor

Definition at line 57 of file PCA.cpp.

Member Function Documentation

SGMatrix< float64_t > apply_to_feature_matrix ( CFeatures features)
virtual

apply preprocessor to feature matrix

Parameters
featuresfeatures
Returns
processed feature matrix

Reimplemented from CDimensionReductionPreprocessor.

Definition at line 187 of file PCA.cpp.

SGVector< float64_t > apply_to_feature_vector ( SGVector< float64_t vector)
virtual

apply preprocessor to feature vector

Parameters
vectorfeature vector
Returns
processed feature vector

Reimplemented from CDimensionReductionPreprocessor.

Definition at line 230 of file PCA.cpp.

void cleanup ( )
virtual

cleanup

Reimplemented from CDimensionReductionPreprocessor.

Definition at line 180 of file PCA.cpp.

SGVector< float64_t > get_eigenvalues ( )

get eigenvalues of PCA

Definition at line 253 of file PCA.cpp.

SGVector< float64_t > get_mean ( )

get mean vector of original data

Definition at line 258 of file PCA.cpp.

virtual const char* get_name ( ) const
virtual
Returns
object name

Reimplemented from CDimensionReductionPreprocessor.

Definition at line 96 of file PCA.h.

SGMatrix< float64_t > get_transformation_matrix ( )

get transformation matrix, i.e. eigenvectors (potentially scaled if do_whitening is true)

Definition at line 248 of file PCA.cpp.

virtual EPreprocessorType get_type ( ) const
virtual
Returns
a type of preprocessor

Reimplemented from CDimensionReductionPreprocessor.

Definition at line 99 of file PCA.h.

bool init ( CFeatures features)
virtual

initialize preprocessor from features

Parameters
features

Reimplemented from CDimensionReductionPreprocessor.

Definition at line 64 of file PCA.cpp.

void init ( )
protected

default init

Reimplemented from CDimensionReductionPreprocessor.

Definition at line 34 of file PCA.cpp.

Member Data Documentation

SGVector<float64_t> m_eigenvalues_vector
protected

eigenvalues vector

Definition at line 116 of file PCA.h.

bool m_initialized
protected

initialized

Definition at line 118 of file PCA.h.

SGVector<float64_t> m_mean_vector
protected

mean vector

Definition at line 114 of file PCA.h.

EPCAMode m_mode
protected

PCA mode

Definition at line 122 of file PCA.h.

SGMatrix<float64_t> m_transformation_matrix
protected

transformation matrix

Definition at line 108 of file PCA.h.

bool m_whitening
protected

whitening

Definition at line 120 of file PCA.h.

int32_t num_dim
protected

num dim

Definition at line 110 of file PCA.h.

int32_t num_old_dim
protected

num old dim

Definition at line 112 of file PCA.h.

float64_t thresh
protected

thresh

Definition at line 124 of file PCA.h.


The documentation for this class was generated from the following files:

SHOGUN Machine Learning Toolbox - Documentation