SHOGUN
3.2.1
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
* 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
20
#include <
shogun/mathematics/eigen3.h
>
21
#include <stdio.h>
22
#include <
shogun/preprocessor/DimensionReductionPreprocessor.h
>
23
#include <
shogun/features/Features.h
>
24
#include <
shogun/lib/common.h
>
25
26
namespace
shogun
27
{
29
enum
EPCAMethod
30
{
34
AUTO
,
36
SVD
,
40
EVD
41
};
42
44
enum
EPCAMode
45
{
47
THRESHOLD
,
49
VARIANCE_EXPLAINED
,
51
FIXED_NUMBER
52
};
53
55
enum
EPCAMemoryMode
56
{
61
MEM_REALLOCATE
,
66
MEM_IN_PLACE
67
};
68
115
class
CPCA
:
public
CDimensionReductionPreprocessor
116
{
117
public
:
118
127
CPCA
(
bool
do_whitening=
false
,
EPCAMode
mode=
FIXED_NUMBER
,
float64_t
thresh=1e-6,
128
EPCAMethod
method=
AUTO
,
EPCAMemoryMode
mem_mode=
MEM_REALLOCATE
);
129
136
CPCA
(
EPCAMethod
method,
bool
do_whitening=
false
,
EPCAMemoryMode
mem=
MEM_REALLOCATE
);
137
139
virtual
~CPCA
();
140
144
virtual
bool
init
(
CFeatures
* features);
145
147
virtual
void
cleanup
();
148
153
virtual
SGMatrix<float64_t>
apply_to_feature_matrix
(
CFeatures
* features);
154
159
virtual
SGVector<float64_t>
apply_to_feature_vector
(
SGVector<float64_t>
vector);
160
164
SGMatrix<float64_t>
get_transformation_matrix
();
165
168
SGVector<float64_t>
get_eigenvalues
();
169
172
SGVector<float64_t>
get_mean
();
173
175
virtual
const
char
*
get_name
()
const
{
return
"PCA"
; }
176
178
virtual
EPreprocessorType
get_type
()
const
{
return
P_PCA
; }
179
181
EPCAMemoryMode
get_memory_mode
()
const
;
182
186
void
set_memory_mode
(
EPCAMemoryMode
e);
187
188
protected
:
189
190
void
init
();
191
192
protected
:
193
195
SGMatrix<float64_t>
m_transformation_matrix
;
197
int32_t
num_dim
;
199
int32_t
num_old_dim
;
201
SGVector<float64_t>
m_mean_vector
;
203
SGVector<float64_t>
m_eigenvalues_vector
;
205
bool
m_initialized
;
207
bool
m_whitening
;
209
EPCAMode
m_mode
;
211
float64_t
m_thresh
;
213
EPCAMemoryMode
m_mem_mode
;
215
EPCAMethod
m_method
;
216
};
217
}
218
#endif // HAVE_EIGEN3
219
#endif // PCA_H_
SHOGUN
Machine Learning Toolbox - Documentation