1 | #ifndef _theplu_yat_classifier_sampler_ |
---|
2 | #define _theplu_yat_classifier_sampler_ |
---|
3 | |
---|
4 | // $Id: Sampler.h 1486 2008-09-09 21:17:19Z jari $ |
---|
5 | |
---|
6 | /* |
---|
7 | Copyright (C) 2006 Jari Häkkinen, Peter Johansson, Markus Ringnér |
---|
8 | Copyright (C) 2007 Jari Häkkinen, Peter Johansson |
---|
9 | Copyright (C) 2008 Peter Johansson |
---|
10 | |
---|
11 | This file is part of the yat library, http://dev.thep.lu.se/yat |
---|
12 | |
---|
13 | The yat library is free software; you can redistribute it and/or |
---|
14 | modify it under the terms of the GNU General Public License as |
---|
15 | published by the Free Software Foundation; either version 3 of the |
---|
16 | License, or (at your option) any later version. |
---|
17 | |
---|
18 | The yat library is distributed in the hope that it will be useful, |
---|
19 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
20 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
21 | General Public License for more details. |
---|
22 | |
---|
23 | You should have received a copy of the GNU General Public License |
---|
24 | along with this program; if not, write to the Free Software |
---|
25 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
---|
26 | 02111-1307, USA. |
---|
27 | */ |
---|
28 | |
---|
29 | #include "Target.h" |
---|
30 | #include "yat/utility/Index.h" |
---|
31 | |
---|
32 | #include <vector> |
---|
33 | |
---|
34 | namespace theplu { |
---|
35 | namespace yat { |
---|
36 | namespace classifier { |
---|
37 | |
---|
38 | /// |
---|
39 | /// @brief Interface class for dividing samples into training and |
---|
40 | /// validation. |
---|
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 | size_t 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(size_t i) const; |
---|
74 | |
---|
75 | /// |
---|
76 | /// @return training target |
---|
77 | /// |
---|
78 | /// @note if state is invalid the result is undefined |
---|
79 | /// |
---|
80 | const Target& training_target(size_t i) const; |
---|
81 | |
---|
82 | /// |
---|
83 | /// @return validation index |
---|
84 | /// |
---|
85 | /// @note if state is invalid the result is undefined |
---|
86 | /// |
---|
87 | const utility::Index& validation_index(size_t 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(size_t i) const; |
---|
95 | |
---|
96 | protected: |
---|
97 | /// index of training sets for the partitions |
---|
98 | std::vector<utility::Index> 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<utility::Index> validation_index_; |
---|
103 | /// Targets for validation sets for the partitions |
---|
104 | std::vector<Target> validation_target_; |
---|
105 | |
---|
106 | private: |
---|
107 | Target target_; |
---|
108 | }; |
---|
109 | |
---|
110 | }}} // of namespace classifier, yat, and theplu |
---|
111 | |
---|
112 | #endif |
---|
113 | |
---|