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

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

Fixes #170. Almost all inlines removed, some classes have no cc file.

  • 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 720 2006-12-26 18:21:36Z 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 "Target.h"
28
29#include <vector>
30
31namespace theplu {
32namespace yat {
33namespace classifier { 
34
35  ///
36  /// Interface for dividing samples into training and validation.
37  ///   
38
39  class Sampler
40  {
41 
42  public:
43    ///
44    /// @brief Constructor
45    /// 
46    /// @param target used to balance partitions
47    ///
48    Sampler(const Target& target);
49
50    ///
51    /// Destructor (pure virtual destructor)
52    ///
53    virtual ~Sampler() =0;
54
55    ///
56    /// @return number of partitions
57    ///
58    u_long size(void) const;
59
60    ///
61    /// @return the targets for the total set
62    ///
63    const Target& target(void) const;
64
65    ///
66    /// @return training indices
67    ///
68    const std::vector<size_t>&
69    training_index(std::vector<size_t>::size_type i) const;
70
71    ///
72    /// @return training target
73    ///
74    /// @note if state is invalid the result is undefined
75    ///
76    const Target&
77    training_target(std::vector<Target>::size_type i) const;
78
79    ///
80    /// @return validation index
81    ///
82    /// @note if state is invalid the result is undefined
83    ///
84    const std::vector<size_t>&
85    validation_index(std::vector<size_t>::size_type 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(std::vector<Target>::size_type i) const;
93
94  protected:
95    /// Target used to balance partitions
96    Target target_;
97    /// index of training sets for the partitions
98    std::vector<std::vector<size_t> > training_index_;
99    /// Targets for training sets for the partitions
100    std::vector<Target> training_target_;
101    /// index of validation sets for the partitions
102    std::vector<std::vector<size_t> > validation_index_;
103    /// Targets for validation sets for the partitions
104    std::vector<Target> validation_target_;
105
106  };
107
108}}} // of namespace classifier, yat, and theplu
109
110#endif
111
Note: See TracBrowser for help on using the repository browser.