-
-
Notifications
You must be signed in to change notification settings - Fork 1k
/
DimensionReductionPreprocessor.h
122 lines (94 loc) · 2.78 KB
/
DimensionReductionPreprocessor.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/*
* This software is distributed under BSD 3-clause license (see LICENSE file).
*
* Authors: Sergey Lisitsyn, Soeren Sonnenburg, Evgeniy Andreev, Evan Shelhamer,
* Yuyu Zhang, Elijah Rippeth
*/
#ifndef DIMENSIONREDUCTIONPREPROCESSOR_H_
#define DIMENSIONREDUCTIONPREPROCESSOR_H_
#include <shogun/lib/config.h>
#include <shogun/preprocessor/DensePreprocessor.h>
#include <shogun/converter/EmbeddingConverter.h>
#include <shogun/features/Features.h>
#include <shogun/distance/Distance.h>
namespace shogun
{
class CFeatures;
class CDistance;
class CKernel;
/** @brief the class DimensionReductionPreprocessor, a base
* class for preprocessors used to lower the dimensionality of given
* simple features (dense matrices).
*/
class CDimensionReductionPreprocessor: public CDensePreprocessor<float64_t>
{
public:
/** default constructor */
CDimensionReductionPreprocessor();
/** convenience constructor converting any embeddingconverter into a
* dimensionreduction preprocessor
*
* @param converter embedding converter
*/
CDimensionReductionPreprocessor(CEmbeddingConverter* converter);
/** destructor */
virtual ~CDimensionReductionPreprocessor();
/** cleanup
* set empty by default, should be defined if dimension reduction
* preprocessor should free some resources
*/
virtual void cleanup();
/** apply preproc to feature matrix
* by default does nothing, returns given features' matrix
*/
virtual SGMatrix<float64_t> apply_to_feature_matrix(CFeatures* features);
/** apply preproc to feature vector
* by default does nothing, returns given feature vector
*/
virtual SGVector<float64_t> apply_to_feature_vector(SGVector<float64_t> vector)
{
return vector;
}
/** get name */
virtual const char* get_name() const { return "DimensionReductionPreprocessor"; };
/** get type */
virtual EPreprocessorType get_type() const;
/** setter for target dimension
* @param dim target dimension
*/
void set_target_dim(int32_t dim);
/** getter for target dimension
* @return target dimension
*/
int32_t get_target_dim() const;
/** setter for distance
* @param distance distance to set
*/
void set_distance(CDistance* distance);
/** getter for distance
* @return distance
*/
CDistance* get_distance() const;
/** setter for kernel
* @param kernel kernel to set
*/
void set_kernel(CKernel* kernel);
/** getter for kernel
* @return kernel
*/
CKernel* get_kernel() const;
private:
/** default init */
void initialize_parameters();
protected:
/** target dim of dimensionality reduction preprocessor */
int32_t m_target_dim;
/** distance to be used */
CDistance* m_distance;
/** kernel to be used */
CKernel* m_kernel;
/** embedding converter to be used */
CEmbeddingConverter* m_converter;
};
}
#endif /* DIMENSIONREDUCTIONPREPROCESSOR_H_ */