1 | #ifndef _theplu_classifier_featureselector_ |
---|
2 | #define _theplu_classifier_featureselector_ |
---|
3 | |
---|
4 | // $Id$ |
---|
5 | |
---|
6 | /* |
---|
7 | Copyright (C) The authors contributing to this file. |
---|
8 | |
---|
9 | This file is part of the yat library, http://lev.thep.lu.se/trac/yat |
---|
10 | |
---|
11 | The yat library is free software; you can redistribute it and/or |
---|
12 | modify it under the terms of the GNU General Public License as |
---|
13 | published by the Free Software Foundation; either version 2 of the |
---|
14 | License, or (at your option) any later version. |
---|
15 | |
---|
16 | The yat library is distributed in the hope that it will be useful, |
---|
17 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
19 | General Public License for more details. |
---|
20 | |
---|
21 | You should have received a copy of the GNU General Public License |
---|
22 | along with this program; if not, write to the Free Software |
---|
23 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
---|
24 | 02111-1307, USA. |
---|
25 | */ |
---|
26 | |
---|
27 | #include <list> |
---|
28 | #include <vector> |
---|
29 | |
---|
30 | namespace theplu { |
---|
31 | namespace classifier { |
---|
32 | class MatrixLookup; |
---|
33 | class MatrixLookupWeighted; |
---|
34 | class Target; |
---|
35 | |
---|
36 | /// |
---|
37 | /// @brief Interface class for FeatureSelection |
---|
38 | /// |
---|
39 | class FeatureSelector |
---|
40 | { |
---|
41 | public: |
---|
42 | /// |
---|
43 | /// @brief Default Constructor |
---|
44 | /// |
---|
45 | FeatureSelector(size_t N, size_t skip=0); |
---|
46 | |
---|
47 | /// |
---|
48 | /// Cleaning upp all objects that have beed returned from FeatureSelector. |
---|
49 | /// |
---|
50 | /// @brief Destructor |
---|
51 | /// |
---|
52 | virtual ~FeatureSelector(void); |
---|
53 | |
---|
54 | /// |
---|
55 | /// @return MatrixLookup containing only selected features. |
---|
56 | /// |
---|
57 | const MatrixLookup& get(const MatrixLookup& data); |
---|
58 | |
---|
59 | /// |
---|
60 | /// @return MatrixLookupWeighted containing only selected features. |
---|
61 | /// |
---|
62 | const MatrixLookupWeighted& get(const MatrixLookupWeighted& data); |
---|
63 | |
---|
64 | /// |
---|
65 | /// @return vector of indices corresponding to selected features. |
---|
66 | /// |
---|
67 | inline const std::vector<size_t> features(void) const { return features_; } |
---|
68 | |
---|
69 | /// |
---|
70 | /// Uses @a matrix to select features. |
---|
71 | /// |
---|
72 | virtual void update(const MatrixLookup& matrix, const Target& target)=0; |
---|
73 | |
---|
74 | /// |
---|
75 | /// Uses @a matrix to select features. |
---|
76 | /// |
---|
77 | virtual void update(const MatrixLookupWeighted& matrix, |
---|
78 | const Target& target)=0; |
---|
79 | |
---|
80 | protected: |
---|
81 | /// |
---|
82 | /// @brief features |
---|
83 | /// |
---|
84 | std::vector<size_t> features_; |
---|
85 | |
---|
86 | /// |
---|
87 | /// number of features to skip in list |
---|
88 | /// |
---|
89 | size_t first_; |
---|
90 | |
---|
91 | /// |
---|
92 | /// number of features selected and returned |
---|
93 | /// |
---|
94 | size_t N_; |
---|
95 | |
---|
96 | private: |
---|
97 | std::list<const MatrixLookup*> garbage_; |
---|
98 | std::list<const MatrixLookupWeighted*> garbage_weighted_; |
---|
99 | |
---|
100 | }; |
---|
101 | |
---|
102 | } // end of namespace classifier |
---|
103 | } // end of namespace theplu |
---|
104 | |
---|
105 | #endif |
---|