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

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

BootstrapSampler?. Fixes #134

  • 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 823 2007-03-19 11:03:27Z peter $
5
6/*
7  Copyright (C) 2006 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
29#include <vector>
30
31namespace theplu {
32namespace yat {
33namespace classifier { 
34
35  ///
36  /// @brief Interface class for dividing samples into training and
37  /// validation.
38  ///   
39
40  class Sampler
41  {
42
43  public:
44    ///
45    /// @brief Constructor
46    ///
47    /// @param target used to balance partitions
48    /// @param 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    u_long 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 std::vector<size_t>&
71    training_index(std::vector<size_t>::size_type i) const;
72
73    ///
74    /// @return training target
75    ///
76    /// @note if state is invalid the result is undefined
77    ///
78    const Target&
79    training_target(std::vector<Target>::size_type i) const;
80
81    ///
82    /// @return validation index
83    ///
84    /// @note if state is invalid the result is undefined
85    ///
86    const std::vector<size_t>&
87    validation_index(std::vector<size_t>::size_type i) const;
88
89    ///
90    /// @return validation target
91    ///
92    /// @note if state is invalid the result is undefined
93    ///
94    const Target& validation_target(std::vector<Target>::size_type i) const;
95
96  protected:
97    /// Target used to balance partitions
98    Target target_;
99    /// index of training sets for the partitions
100    std::vector<std::vector<size_t> > training_index_;
101    /// Targets for training sets for the partitions
102    std::vector<Target> training_target_;
103    /// index of validation sets for the partitions
104    std::vector<std::vector<size_t> > validation_index_;
105    /// Targets for validation sets for the partitions
106    std::vector<Target> validation_target_;
107
108  };
109
110}}} // of namespace classifier, yat, and theplu
111
112#endif
113
Note: See TracBrowser for help on using the repository browser.