SHOGUN
v2.0.0
Main Page
Related Pages
Modules
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
src
shogun
evaluation
CrossValidation.h
Go to the documentation of this file.
1
/*
2
* This program is free software; you can redistribute it and/or modify
3
* it under the terms of the GNU General Public License as published by
4
* the Free Software Foundation; either version 3 of the License, or
5
* (at your option) any later version.
6
*
7
* Written (W) 2011-2012 Heiko Strathmann
8
* Copyright (C) 2011 Berlin Institute of Technology and Max-Planck-Society
9
*/
10
11
#ifndef __CROSSVALIDATION_H_
12
#define __CROSSVALIDATION_H_
13
14
#include <
shogun/evaluation/EvaluationResult.h
>
15
#include <
shogun/evaluation/MachineEvaluation.h
>
16
17
namespace
shogun
18
{
19
20
class
CMachineEvaluation;
21
class
CCrossValidationOutput;
22
class
CList;
23
29
class
CCrossValidationResult
:
public
CEvaluationResult
30
{
31
public
:
32
CCrossValidationResult
()
33
{
34
mean
= 0;
35
has_conf_int
= 0;
36
conf_int_low
= 0;
37
conf_int_up
= 0;
38
conf_int_alpha
= 0;
39
}
40
46
virtual
EEvaluationResultType
get_result_type
()
47
{
48
return
CROSSVALIDATION_RESULT
;
49
}
50
56
virtual
const
char
*
get_name
()
const
{
return
"CrossValidationResult"
; }
57
59
virtual
void
print_result
()
60
{
61
if
(
has_conf_int
)
62
{
63
SG_SPRINT
(
"[%f,%f] with alpha=%f, mean=%f\n"
,
conf_int_low
,
64
conf_int_up
,
conf_int_alpha
,
mean
);
65
}
66
else
67
SG_SPRINT
(
"%f\n"
,
mean
);
68
}
69
70
public
:
72
float64_t
mean
;
74
bool
has_conf_int
;
76
float64_t
conf_int_low
;
78
float64_t
conf_int_up
;
80
float64_t
conf_int_alpha
;
81
82
};
83
109
class
CCrossValidation
:
public
CMachineEvaluation
110
{
111
public
:
113
CCrossValidation
();
114
123
CCrossValidation
(
CMachine
* machine,
CFeatures
* features,
CLabels
* labels,
124
CSplittingStrategy
* splitting_strategy,
125
CEvaluation
* evaluation_criterion,
bool
autolock=
true
);
126
134
CCrossValidation
(
CMachine
* machine,
CLabels
* labels,
135
CSplittingStrategy
* splitting_strategy,
136
CEvaluation
* evaluation_criterion,
bool
autolock=
true
);
137
139
virtual
~CCrossValidation
();
140
142
void
set_num_runs
(int32_t num_runs);
143
145
void
set_conf_int_alpha
(
float64_t
m_conf_int_alpha
);
146
148
virtual
CEvaluationResult
*
evaluate
();
149
155
void
add_cross_validation_output
(
156
CCrossValidationOutput
* cross_validation_output);
157
159
inline
virtual
const
char
*
get_name
()
const
160
{
161
return
"CrossValidation"
;
162
}
163
164
private
:
165
void
init();
166
167
protected
:
176
virtual
float64_t
evaluate_one_run
();
177
179
int32_t
m_num_runs
;
181
float64_t
m_conf_int_alpha
;
182
184
CList
*
m_xval_outputs
;
185
};
186
187
}
188
189
#endif
/* __CROSSVALIDATION_H_ */
SHOGUN
Machine Learning Toolbox - Documentation