source: trunk/yat/classifier/SubsetGenerator.h @ 767

Last change on this file since 767 was 767, checked in by Peter, 15 years ago

Fixes #65

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.5 KB
Line 
1#ifndef _theplu_yat_classifier_subset_generator_
2#define _theplu_yat_classifier_subset_generator_
3
4// $Id: SubsetGenerator.h 767 2007-02-22 15:14:40Z peter $
5
6/*
7  Copyright (C) 2006 Markus Ringnér, Peter Johansson
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 "Target.h"
28#include "Sampler.h"
29
30#include <vector>
31
32namespace theplu {
33namespace yat {
34namespace classifier { 
35  class DataLookup2D;
36  class FeatureSelector;
37  class MatrixLookup;
38
39  ///
40  /// @brief Class splitting a set into training set and validation set.
41  ///
42  class SubsetGenerator
43  {
44 
45  public:
46    ///
47    /// @brief Constructor
48    /// 
49    /// @param sampler sampler
50    /// @param data data to split up in validation and training.
51    ///
52    SubsetGenerator(const Sampler& sampler, const DataLookup2D& data);
53
54
55    ///
56    /// @brief Constructor
57    /// 
58    /// @param sampler taking care of partioning dataset
59    /// @param data data to be split up in validation and training.
60    /// @param fs Object selecting features for each subset
61    ///
62    SubsetGenerator(const Sampler& sampler, const DataLookup2D& data, 
63                    FeatureSelector& fs);
64
65    ///
66    /// Destructor
67    ///
68    ~SubsetGenerator();
69 
70    ///
71    /// @return number of subsets
72    ///
73    u_long size(void) const;
74
75    ///
76    /// @return the target for the total set
77    ///
78    const Target& target(void) const;
79
80    ///
81    /// @return the sampler for the total set
82    ///
83    //    const Sampler& sampler(void) const;
84
85    ///
86    /// @return training data
87    ///
88    const DataLookup2D&
89    training_data(std::vector<DataLookup2D*>::size_type i) const;
90
91    ///
92    /// @return training features
93    ///
94    const std::vector<size_t>&
95    training_features(std::vector<size_t>::size_type i) const;
96
97    ///
98    /// @return training index
99    ///
100    const std::vector<size_t>&
101    training_index(std::vector<size_t>::size_type i) const;
102
103    ///
104    /// @return training target
105    ///
106    const Target& training_target(std::vector<Target>::size_type i) const;
107
108    ///
109    /// @return validation data
110    ///
111    const DataLookup2D&
112    validation_data(std::vector<DataLookup2D*>::size_type i) const;
113
114    ///
115    /// @return validation index
116    ///
117    const std::vector<size_t>&
118    validation_index(std::vector<size_t>::size_type i) const;
119
120    ///
121    /// @return validation target
122    ///
123    const Target& validation_target(std::vector<Target>::size_type i) const;
124
125    ///
126    /// @return true if weighted
127    /// @todo remove this function
128    //bool weighted(void) const;
129
130  private:
131    SubsetGenerator(const SubsetGenerator&);
132    const SubsetGenerator& operator=(const SubsetGenerator&) const;
133
134    FeatureSelector* f_selector_;
135    std::vector<std::vector<size_t> > features_;
136    const Sampler& sampler_;
137    std::vector<const DataLookup2D*> training_data_;
138    std::vector<Target> training_target_;
139    std::vector<const DataLookup2D*> validation_data_;
140    std::vector<Target> validation_target_;
141    const bool weighted_;
142
143  };
144
145}}} // of namespace classifier, yat, and theplu
146
147#endif
148
Note: See TracBrowser for help on using the repository browser.