source: trunk/yat/classifier/Sampler.h @ 1268

Last change on this file since 1268 was 1221, checked in by Peter, 13 years ago

writing size_t directly rather than vector<>::size_type

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.6 KB
Line 
1#ifndef _theplu_yat_classifier_sampler_
2#define _theplu_yat_classifier_sampler_
3
4// $Id: Sampler.h 1221 2008-03-11 10:43:22Z peter $
5
6/*
7  Copyright (C) 2006 Jari Häkkinen, Markus Ringnér, Peter Johansson
8  Copyright (C) 2007 Peter Johansson
9
10  This file is part of the yat library, http://trac.thep.lu.se/yat
11
12  The yat library is free software; you can redistribute it and/or
13  modify it under the terms of the GNU General Public License as
14  published by the Free Software Foundation; either version 2 of the
15  License, or (at your option) any later version.
16
17  The yat library is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  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#include "Target.h"
29#include "yat/utility/Index.h"
30
31#include <vector>
32
33namespace theplu {
34namespace yat {
35namespace classifier { 
36
37  ///
38  /// @brief Interface class for dividing samples into training and
39  /// validation.
40  ///   
41  class Sampler
42  {
43
44  public:
45    ///
46    /// @brief Constructor
47    ///
48    /// @param target used to balance partitions
49    /// @param N Number of partitions
50    ///
51    Sampler(const Target& target, size_t N);
52
53    ///
54    /// Destructor (pure virtual destructor)
55    ///
56    virtual ~Sampler() =0;
57
58    ///
59    /// @return number of partitions
60    ///
61    size_t size(void) const;
62
63    ///
64    /// @return the targets for the total set
65    ///
66    const Target& target(void) const;
67
68    ///
69    /// @return training indices
70    ///
71    const utility::Index&
72    training_index(size_t i) const;
73
74    ///
75    /// @return training target
76    ///
77    /// @note if state is invalid the result is undefined
78    ///
79    const Target& training_target(size_t i) const;
80
81    ///
82    /// @return validation index
83    ///
84    /// @note if state is invalid the result is undefined
85    ///
86    const utility::Index& validation_index(size_t i) const;
87
88    ///
89    /// @return validation target
90    ///
91    /// @note if state is invalid the result is undefined
92    ///
93    const Target& validation_target(size_t i) const;
94
95  protected:
96    /// index of training sets for the partitions
97    std::vector<utility::Index> training_index_;
98    /// Targets for training sets for the partitions
99    std::vector<Target> training_target_;
100    /// index of validation sets for the partitions
101    std::vector<utility::Index> validation_index_;
102    /// Targets for validation sets for the partitions
103    std::vector<Target> validation_target_;
104
105  private:
106    Target target_;
107  };
108
109}}} // of namespace classifier, yat, and theplu
110
111#endif
112
Note: See TracBrowser for help on using the repository browser.