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

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

Fixes #65

  • 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 767 2007-02-22 15:14:40Z 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    ///
49    Sampler(const Target& target);
50
51    ///
52    /// Destructor (pure virtual destructor)
53    ///
54    virtual ~Sampler() =0;
55
56    ///
57    /// @return number of partitions
58    ///
59    u_long size(void) const;
60
61    ///
62    /// @return the targets for the total set
63    ///
64    const Target& target(void) const;
65
66    ///
67    /// @return training indices
68    ///
69    const std::vector<size_t>&
70    training_index(std::vector<size_t>::size_type i) const;
71
72    ///
73    /// @return training target
74    ///
75    /// @note if state is invalid the result is undefined
76    ///
77    const Target&
78    training_target(std::vector<Target>::size_type i) const;
79
80    ///
81    /// @return validation index
82    ///
83    /// @note if state is invalid the result is undefined
84    ///
85    const std::vector<size_t>&
86    validation_index(std::vector<size_t>::size_type i) const;
87
88    ///
89    /// @return validation target
90    ///
91    /// @note if state is invalid the result is undefined
92    ///
93    const Target& validation_target(std::vector<Target>::size_type i) const;
94
95  protected:
96    /// Target used to balance partitions
97    Target target_;
98    /// index of training sets for the partitions
99    std::vector<std::vector<size_t> > 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<std::vector<size_t> > validation_index_;
104    /// Targets for validation sets for the partitions
105    std::vector<Target> validation_target_;
106
107  };
108
109}}} // of namespace classifier, yat, and theplu
110
111#endif
112
Note: See TracBrowser for help on using the repository browser.