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

Last change on this file since 1580 was 1487, checked in by Jari Häkkinen, 13 years ago

Addresses #436. GPL license copy reference should also be updated.

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