source: trunk/c++_tools/classifier/Sampler.h @ 675

Last change on this file since 675 was 675, checked in by Jari Häkkinen, 17 years ago

References #83. Changing project name to yat. Compilation will fail in this revision.

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