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

Last change on this file since 1220 was 1220, checked in by Peter, 14 years ago

refs #341

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.7 KB
Line 
1#ifndef _theplu_yat_classifier_sampler_
2#define _theplu_yat_classifier_sampler_
3
4// $Id: Sampler.h 1220 2008-03-11 00:07:42Z 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&
80    training_target(std::vector<Target>::size_type i) const;
81
82    ///
83    /// @return validation index
84    ///
85    /// @note if state is invalid the result is undefined
86    ///
87    const utility::Index&
88    validation_index(std::vector<size_t>::size_type i) const;
89
90    ///
91    /// @return validation target
92    ///
93    /// @note if state is invalid the result is undefined
94    ///
95    const Target& validation_target(std::vector<Target>::size_type i) const;
96
97  protected:
98    /// index of training sets for the partitions
99    std::vector<utility::Index> training_index_;
100    /// Targets for training sets for the partitions
101    std::vector<Target> training_target_;
102    /// index of validation sets for the partitions
103    std::vector<utility::Index> validation_index_;
104    /// Targets for validation sets for the partitions
105    std::vector<Target> validation_target_;
106
107  private:
108    Target target_;
109  };
110
111}}} // of namespace classifier, yat, and theplu
112
113#endif
114
Note: See TracBrowser for help on using the repository browser.