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

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

Fixes #170. Almost all inlines removed, some classes have no cc file.

  • 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 720 2006-12-26 18:21:36Z jari $
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  /// Class splitting a set into training set and validation set using
41  /// a Sampler method.
42  ///   
43  class SubsetGenerator
44  {
45 
46  public:
47    ///
48    /// @brief Constructor
49    /// 
50    /// @param sampler sampler
51    /// @param data data to split up in validation and training.
52    ///
53    SubsetGenerator(const Sampler& sampler, const DataLookup2D& data);
54
55
56    ///
57    /// @brief Constructor
58    /// 
59    /// @param sampler taking care of partioning dataset
60    /// @param data data to be split up in validation and training.
61    /// @param fs Object selecting features for each subset
62    ///
63    SubsetGenerator(const Sampler& sampler, const DataLookup2D& data, 
64                    FeatureSelector& fs);
65
66    ///
67    /// Destructor
68    ///
69    ~SubsetGenerator();
70 
71    ///
72    /// @return number of subsets
73    ///
74    u_long size(void) const;
75
76    ///
77    /// @return the target for the total set
78    ///
79    const Target& target(void) const;
80
81    ///
82    /// @return the sampler for the total set
83    ///
84    //    const Sampler& sampler(void) const;
85
86    ///
87    /// @return training data
88    ///
89    const DataLookup2D&
90    training_data(std::vector<DataLookup2D*>::size_type i) const;
91
92    ///
93    /// @return training features
94    ///
95    const std::vector<size_t>&
96    training_features(std::vector<size_t>::size_type i) const;
97
98    ///
99    /// @return training index
100    ///
101    const std::vector<size_t>&
102    training_index(std::vector<size_t>::size_type i) const;
103
104    ///
105    /// @return training target
106    ///
107    const Target& training_target(std::vector<Target>::size_type i) const;
108
109    ///
110    /// @return validation data
111    ///
112    const DataLookup2D&
113    validation_data(std::vector<DataLookup2D*>::size_type i) const;
114
115    ///
116    /// @return validation index
117    ///
118    const std::vector<size_t>&
119    validation_index(std::vector<size_t>::size_type i) const;
120
121    ///
122    /// @return validation target
123    ///
124    const Target& validation_target(std::vector<Target>::size_type i) const;
125
126    ///
127    /// @return true if weighted
128    /// @todo remove this function
129    //bool weighted(void) const;
130
131  private:
132    SubsetGenerator(const SubsetGenerator&);
133    const SubsetGenerator& operator=(const SubsetGenerator&) const;
134
135    FeatureSelector* f_selector_;
136    std::vector<std::vector<size_t> > features_;
137    const Sampler& sampler_;
138    std::vector<const DataLookup2D*> training_data_;
139    std::vector<Target> training_target_;
140    std::vector<const DataLookup2D*> validation_data_;
141    std::vector<Target> validation_target_;
142    const bool weighted_;
143
144  };
145
146}}} // of namespace classifier, yat, and theplu
147
148#endif
149
Note: See TracBrowser for help on using the repository browser.