4200 |
19 Aug 22 |
peter |
1 |
#ifndef _theplu_yat_classifier_crossvalidation_sampler_ |
680 |
11 Oct 06 |
jari |
2 |
#define _theplu_yat_classifier_crossvalidation_sampler_ |
612 |
30 Aug 06 |
peter |
3 |
|
612 |
30 Aug 06 |
peter |
// $Id$ |
612 |
30 Aug 06 |
peter |
5 |
|
612 |
30 Aug 06 |
peter |
6 |
/* |
2119 |
12 Dec 09 |
peter |
Copyright (C) 2006 Jari Häkkinen, Peter Johansson, Markus Ringnér |
4359 |
23 Aug 23 |
peter |
Copyright (C) 2007 Peter Johansson |
4359 |
23 Aug 23 |
peter |
Copyright (C) 2008 Jari Häkkinen, Peter Johansson |
612 |
30 Aug 06 |
peter |
10 |
|
1437 |
25 Aug 08 |
peter |
This file is part of the yat library, http://dev.thep.lu.se/yat |
612 |
30 Aug 06 |
peter |
12 |
|
675 |
10 Oct 06 |
jari |
The yat library is free software; you can redistribute it and/or |
675 |
10 Oct 06 |
jari |
modify it under the terms of the GNU General Public License as |
1486 |
09 Sep 08 |
jari |
published by the Free Software Foundation; either version 3 of the |
675 |
10 Oct 06 |
jari |
License, or (at your option) any later version. |
612 |
30 Aug 06 |
peter |
17 |
|
675 |
10 Oct 06 |
jari |
The yat library is distributed in the hope that it will be useful, |
675 |
10 Oct 06 |
jari |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
675 |
10 Oct 06 |
jari |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
612 |
30 Aug 06 |
peter |
General Public License for more details. |
612 |
30 Aug 06 |
peter |
22 |
|
612 |
30 Aug 06 |
peter |
You should have received a copy of the GNU General Public License |
1487 |
10 Sep 08 |
jari |
along with yat. If not, see <http://www.gnu.org/licenses/>. |
612 |
30 Aug 06 |
peter |
25 |
*/ |
612 |
30 Aug 06 |
peter |
26 |
|
680 |
11 Oct 06 |
jari |
27 |
#include "Sampler.h" |
612 |
30 Aug 06 |
peter |
28 |
|
612 |
30 Aug 06 |
peter |
29 |
namespace theplu { |
680 |
11 Oct 06 |
jari |
30 |
namespace yat { |
823 |
19 Mar 07 |
peter |
31 |
namespace classifier { |
612 |
30 Aug 06 |
peter |
32 |
|
613 |
30 Aug 06 |
markus |
33 |
class Target; |
613 |
30 Aug 06 |
markus |
34 |
|
612 |
30 Aug 06 |
peter |
35 |
/// |
767 |
22 Feb 07 |
peter |
/// @brief Class splitting a set into training set and validation |
935 |
05 Oct 07 |
peter |
/// set in a crossvalidation manner. |
4200 |
19 Aug 22 |
peter |
38 |
/// |
935 |
05 Oct 07 |
peter |
/// This is done in a balanced way, meaning |
612 |
30 Aug 06 |
peter |
/// the proportions between the classes in the trainingset is close |
612 |
30 Aug 06 |
peter |
/// to the proportions in the whole dataset. In the first \a k |
612 |
30 Aug 06 |
peter |
/// rounds each sample is returned k-1 times, for next round the |
612 |
30 Aug 06 |
peter |
/// samples are shuffled and... In total there are N partitions, in |
612 |
30 Aug 06 |
peter |
/// other words, each sample is in validation roughly N/k |
4200 |
19 Aug 22 |
peter |
45 |
/// |
823 |
19 Mar 07 |
peter |
46 |
class CrossValidationSampler : public Sampler |
823 |
19 Mar 07 |
peter |
47 |
{ |
823 |
19 Mar 07 |
peter |
48 |
|
823 |
19 Mar 07 |
peter |
49 |
public: |
823 |
19 Mar 07 |
peter |
50 |
/// |
4200 |
19 Aug 22 |
peter |
/// @brief Constructor |
823 |
19 Mar 07 |
peter |
52 |
/// |
4200 |
19 Aug 22 |
peter |
/// @a target targets. |
645 |
08 Sep 06 |
markus |
/// @a N total number of partitions. |
645 |
08 Sep 06 |
markus |
/// @a k for k-fold crossvalidation. |
612 |
30 Aug 06 |
peter |
56 |
/// |
612 |
30 Aug 06 |
peter |
57 |
CrossValidationSampler(const Target& target, const size_t N,const size_t k); |
612 |
30 Aug 06 |
peter |
58 |
|
612 |
30 Aug 06 |
peter |
59 |
/// |
612 |
30 Aug 06 |
peter |
/// Destructor |
612 |
30 Aug 06 |
peter |
61 |
/// |
612 |
30 Aug 06 |
peter |
62 |
virtual ~CrossValidationSampler(); |
612 |
30 Aug 06 |
peter |
63 |
|
612 |
30 Aug 06 |
peter |
64 |
private: |
4200 |
19 Aug 22 |
peter |
65 |
void build(const Target& target, size_t N, size_t k); |
612 |
30 Aug 06 |
peter |
66 |
const size_t k_; |
612 |
30 Aug 06 |
peter |
67 |
|
612 |
30 Aug 06 |
peter |
68 |
}; |
612 |
30 Aug 06 |
peter |
69 |
|
680 |
11 Oct 06 |
jari |
70 |
}}} // of namespace classifier, yat, and theplu |
612 |
30 Aug 06 |
peter |
71 |
#endif |