source: trunk/c++_tools/classifier/SubsetGenerator.h @ 613

Last change on this file since 613 was 613, checked in by Markus Ringnér, 15 years ago

Sampler and SubsetGenerator? in progress. Fixes #103

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.0 KB
Line 
1#ifndef _theplu_classifier_subsetgenerator_
2#define _theplu_classifier_subsetgenerator_
3
4// $Id: SubsetGenerator.h 613 2006-08-30 14:40:51Z markus $
5
6/*
7  Copyright (C) 2006 Markus Ringnér
8
9  This file is part of the thep c++ tools library,
10                                http://lev.thep.lu.se/trac/c++_tools
11
12  The c++ tools library is free software; you can redistribute it
13  and/or modify it under the terms of the GNU General Public License
14  as published by the Free Software Foundation; either version 2 of
15  the License, or (at your option) any later version.
16
17  The c++ tools library is distributed in the hope that it will be
18  useful, but WITHOUT ANY WARRANTY; without even the implied warranty
19  of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20  General Public License for more details.
21
22  You should have received a copy of the GNU General Public License
23  along with this program; if not, write to the Free Software
24  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
25  02111-1307, USA.
26*/
27
28
29namespace theplu {
30namespace classifier { 
31
32  ///
33  /// Class splitting a set into training set and validation set
34  /// in a way defined by a Sampler. 
35  ///
36  class SubsetGenerator
37  {
38 
39  public:
40    ///
41    /// @brief Constructor
42    /// 
43    SubsetGenerator(const Sampler&, const DataLookup2D&);
44   
45    ///
46    /// Destructor
47    ///
48    virtual ~SubsetGenerator();
49   
50    ///
51    /// @return true if in a valid state
52    ///
53    inline bool more(void) const { return state_<sampler_.size(); }
54   
55    ///
56    /// Function turning the object to the next state.
57    ///
58    inline void next(void) { state_++; }
59   
60    ///
61    /// rewind to the initial state
62    ///
63    inline void reset(void) { state_=0; }
64   
65  private:
66   
67    void build(const Sampler&);
68
69    u_long state_;
70   
71    std::vector<const DataLookup2D*> training_data_;
72    std::vector<const MatrixLookup*> training_weight_;
73   
74    std::vector<const DataLookup2D*> validation_data_;
75    std::vector<const MatrixLookup*> validation_weight_;
76   
77    FeatureSelector* f_selector_;
78    std::vector<std::vector<size_t> > features_;
79
80  };
81
82}} // of namespace classifier and namespace theplu
83
84#endif
Note: See TracBrowser for help on using the repository browser.