SHOGUN
v3.0.0
Main Page
Related Pages
Modules
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
src
shogun
preprocessor
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
* Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society
10
* Copyright (C) 2011 Berlin Institute of Technology
11
*/
12
13
#ifndef PCA_H_
14
#define PCA_H_
15
#include <
shogun/lib/config.h
>
16
#ifdef HAVE_LAPACK
17
#include <
shogun/mathematics/lapack.h
>
18
#include <stdio.h>
19
#include <
shogun/preprocessor/DimensionReductionPreprocessor.h
>
20
#include <
shogun/features/Features.h
>
21
#include <
shogun/lib/common.h
>
22
23
namespace
shogun
24
{
26
enum
EPCAMode
27
{
29
THRESHOLD
,
31
VARIANCE_EXPLAINED
,
33
FIXED_NUMBER
34
};
35
48
class
CPCA
:
public
CDimensionReductionPreprocessor
49
{
50
public
:
51
57
CPCA
(
bool
do_whitening=
false
,
EPCAMode
mode=
FIXED_NUMBER
,
float64_t
thresh
=1e-6);
58
60
virtual
~CPCA
();
61
65
virtual
bool
init
(
CFeatures
* features);
66
68
virtual
void
cleanup
();
69
74
virtual
SGMatrix<float64_t>
apply_to_feature_matrix
(
CFeatures
* features);
75
80
virtual
SGVector<float64_t>
apply_to_feature_vector
(
SGVector<float64_t>
vector);
81
85
SGMatrix<float64_t>
get_transformation_matrix
();
86
89
SGVector<float64_t>
get_eigenvalues
();
90
93
SGVector<float64_t>
get_mean
();
94
96
virtual
const
char
*
get_name
()
const
{
return
"PCA"
; }
97
99
virtual
EPreprocessorType
get_type
()
const
{
return
P_PCA
; }
100
101
protected
:
102
103
void
init
();
104
105
protected
:
106
108
SGMatrix<float64_t>
m_transformation_matrix
;
110
int32_t
num_dim
;
112
int32_t
num_old_dim
;
114
SGVector<float64_t>
m_mean_vector
;
116
SGVector<float64_t>
m_eigenvalues_vector
;
118
bool
m_initialized
;
120
bool
m_whitening
;
122
EPCAMode
m_mode
;
124
float64_t
thresh
;
125
};
126
}
127
#endif
128
#endif
SHOGUN
Machine Learning Toolbox - Documentation