source: trunk/yat/classifier/FeatureSelector.h @ 1000

Last change on this file since 1000 was 1000, checked in by Jari Häkkinen, 14 years ago

trac moved to new location.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date ID
File size: 2.5 KB
Line 
1#ifndef _theplu_yat_classifier_featureselector_
2#define _theplu_yat_classifier_featureselector_
3
4// $Id$
5
6/*
7  Copyright (C) 2006 Jari Häkkinen, Peter Johansson
8
9  This file is part of the yat library, http://trac.thep.lu.se/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
30namespace theplu {
31namespace yat {
32namespace classifier {
33  class MatrixLookup;
34  class MatrixLookupWeighted;
35  class Target;
36
37  ///
38  /// @brief Interface class for FeatureSelection
39  ///
40  class FeatureSelector
41  {
42  public:
43    ///
44    /// @brief Default Constructor
45    ///
46    FeatureSelector(size_t N, size_t skip=0);
47
48    ///
49    /// Cleaning upp all objects that have beed returned from FeatureSelector.
50    ///
51    /// @brief Destructor
52    ///
53    virtual ~FeatureSelector(void);
54
55    ///
56    /// @return MatrixLookup containing only selected features.
57    ///
58    const MatrixLookup& get(const MatrixLookup& data);
59
60    ///
61    /// @return MatrixLookupWeighted containing only selected features.
62    ///
63    const MatrixLookupWeighted& get(const MatrixLookupWeighted& data);
64
65    ///
66    /// @return vector of indices corresponding to selected features.
67    ///
68    const std::vector<size_t> features(void) const;
69
70    ///
71    /// Uses @a matrix to select features.
72    ///
73    virtual void update(const MatrixLookup& matrix, const Target& target)=0;
74
75    ///
76    /// Uses @a matrix to select features.
77    ///
78    virtual void update(const MatrixLookupWeighted& matrix, 
79                        const Target& target)=0;
80
81  protected:
82    ///
83    /// @brief features
84    ///
85    std::vector<size_t> features_;
86
87    ///
88    /// number of features to skip in list
89    ///
90    size_t first_;
91
92    ///
93    /// number of features selected and returned
94    ///
95    size_t N_;
96
97  private:
98    std::list<const MatrixLookup*> garbage_;
99    std::list<const MatrixLookupWeighted*> garbage_weighted_;
100
101  };
102
103}}} // of namespace classifier, yat, and theplu
104
105#endif
Note: See TracBrowser for help on using the repository browser.