-
-
Notifications
You must be signed in to change notification settings - Fork 1k
/
Preprocessor.h
103 lines (90 loc) · 2.98 KB
/
Preprocessor.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
/*
* This software is distributed under BSD 3-clause license (see LICENSE file).
*
* Authors: Sergey Lisitsyn, Soeren Sonnenburg, Viktor Gal, Soumyajit De,
* Abhijeet Kislay, Evan Shelhamer, Yuyu Zhang
*/
#ifndef PREPROCESSOR_H_
#define PREPROCESSOR_H_
#include <shogun/lib/config.h>
#include <shogun/base/SGObject.h>
#include <shogun/features/FeatureTypes.h>
#include <shogun/features/Features.h>
#include <shogun/lib/common.h>
#include <shogun/transformer/Transformer.h>
namespace shogun
{
class CFeatures;
/** enumeration of possible preprocessor types
* used by Shogun UI
*
* Note to developer: any new preprocessor should be added here.
*/
enum EPreprocessorType
{
P_UNKNOWN=0,
P_NORMONE=10,
P_LOGPLUSONE=20,
P_SORTWORDSTRING=30,
P_SORTULONGSTRING=40,
P_SORTWORD=50,
P_PRUNEVARSUBMEAN=60,
P_DECOMPRESSSTRING=70,
P_DECOMPRESSCHARSTRING=80,
P_DECOMPRESSBYTESTRING=90,
P_DECOMPRESSWORDSTRING=100,
P_DECOMPRESSULONGSTRING=110,
P_RANDOMFOURIERGAUSS=120,
P_PCA=130,
P_KERNELPCA=140,
P_NORMDERIVATIVELEM3=150,
P_DIMENSIONREDUCTIONPREPROCESSOR=160,
P_SUMONE=170,
P_HOMOGENEOUSKERNELMAP = 180,
P_PNORM = 190,
P_RESCALEFEATURES = 200,
P_FISHERLDA = 210
};
/** @brief Class Preprocessor defines a preprocessor interface.
*
* Preprocessors are transformation functions that doesn't change the domain of
* the input features. These functions can be applied in-place if the input
* features fit in memory or can be applied on-the-fly when (depending on
* features) a feature caching strategy is applied. However, if the individual
* features are in \f$\bf{R}\f$ they have to stay in \f$\bf{R}\f$ although the
* dimensionality of the feature vectors is allowed to be changed.
*
* As preprocessors might need a certain initialization they may expect that
* the init() function is called before anything else. The actual preprocessing
* is feature type dependent and thus coordinated in the sub-classes, cf. e.g.
* CDensePreprocessor. Although, for providing a generic interface for this,
* an abstract apply() method is there, which sub-classes may choose to use as
* a wrapper to more specific methods.
*/
class CPreprocessor : public CTransformer
{
public:
/** constructor */
CPreprocessor() : CTransformer(){};
/** destructor */
virtual ~CPreprocessor()
{
}
/** generic interface for applying the preprocessor. sub-classes may use
* this method as a wrapper to specific implementations
*
* @param features the input features
* @return the result feature object after applying the preprocessor
*/
virtual CFeatures* apply(CFeatures* features)=0;
/** clean-up. should be called (if necessary) after processing */
virtual void cleanup()=0;
/** @return type of objects preprocessor can deal with */
virtual EFeatureType get_feature_type()=0;
/** @return class of features preprocessor deals with */
virtual EFeatureClass get_feature_class()=0;
/** @return the actual type of the preprocessor */
virtual EPreprocessorType get_type() const=0;
};
}
#endif // PREPROCESSOR_H_