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

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

using Index class instead of std::vector<size_t>

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.8 KB
Line 
1#ifndef _theplu_yat_classifier_sampler_
2#define _theplu_yat_classifier_sampler_
3
4// $Id: Sampler.h 1134 2008-02-23 22:52:43Z 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
42  class Sampler
43  {
44
45  public:
46    ///
47    /// @brief Constructor
48    ///
49    /// @param target used to balance partitions
50    /// @param N Number of partitions
51    ///
52    Sampler(const Target& target, size_t N);
53
54    ///
55    /// Destructor (pure virtual destructor)
56    ///
57    virtual ~Sampler() =0;
58
59    ///
60    /// @return number of partitions
61    ///
62    u_long size(void) const;
63
64    ///
65    /// @return the targets for the total set
66    ///
67    const Target& target(void) const;
68
69    ///
70    /// @return training indices
71    ///
72    const utility::Index&
73    training_index(std::vector<size_t>::size_type i) const;
74
75    ///
76    /// @return training target
77    ///
78    /// @note if state is invalid the result is undefined
79    ///
80    const Target&
81    training_target(std::vector<Target>::size_type i) const;
82
83    ///
84    /// @return validation index
85    ///
86    /// @note if state is invalid the result is undefined
87    ///
88    const utility::Index&
89    validation_index(std::vector<size_t>::size_type i) const;
90
91    ///
92    /// @return validation target
93    ///
94    /// @note if state is invalid the result is undefined
95    ///
96    const Target& validation_target(std::vector<Target>::size_type i) const;
97
98  protected:
99    /// Target used to balance partitions
100    Target target_;
101    /// index of training sets for the partitions
102    std::vector<utility::Index> training_index_;
103    /// Targets for training sets for the partitions
104    std::vector<Target> training_target_;
105    /// index of validation sets for the partitions
106    std::vector<utility::Index> validation_index_;
107    /// Targets for validation sets for the partitions
108    std::vector<Target> validation_target_;
109
110  };
111
112}}} // of namespace classifier, yat, and theplu
113
114#endif
115
Note: See TracBrowser for help on using the repository browser.