SHOGUN
v3.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
SG_ADD
(&
mean
,
"mean"
,
"Mean of results"
,
MS_NOT_AVAILABLE
);
35
SG_ADD
(&
has_conf_int
,
"has_conf_int"
,
"Has confidence intervals?"
,
36
MS_NOT_AVAILABLE
);
37
SG_ADD
(&
conf_int_low
,
"conf_int_low"
,
"Lower confidence bound"
,
38
MS_NOT_AVAILABLE
);
39
SG_ADD
(&
conf_int_up
,
"conf_int_up"
,
"Upper confidence bound"
,
40
MS_NOT_AVAILABLE
);
41
42
SG_ADD
(&
conf_int_alpha
,
"conf_int_alpha"
,
43
"Alpha of confidence interval"
,
MS_NOT_AVAILABLE
);
44
45
mean
= 0;
46
has_conf_int
= 0;
47
conf_int_low
= 0;
48
conf_int_up
= 0;
49
conf_int_alpha
= 0;
50
}
51
56
virtual
EEvaluationResultType
get_result_type
()
const
57
{
58
return
CROSSVALIDATION_RESULT
;
59
}
60
66
virtual
const
char
*
get_name
()
const
{
return
"CrossValidationResult"
; }
67
72
static
CCrossValidationResult
*
obtain_from_generic
(
73
CEvaluationResult
* eval_result)
74
{
75
if
(!eval_result)
76
return
NULL;
77
78
REQUIRE
(eval_result->
get_result_type
()==
CROSSVALIDATION_RESULT
,
79
"CrossValidationResult::obtain_from_generic(): argument is"
80
"of wrong type!\n"
);
81
82
SG_REF
(eval_result);
83
return
(
CCrossValidationResult
*) eval_result;
84
}
85
87
virtual
void
print_result
()
88
{
89
if
(
has_conf_int
)
90
{
91
SG_SPRINT
(
"[%f,%f] with alpha=%f, mean=%f\n"
,
conf_int_low
,
92
conf_int_up
,
conf_int_alpha
,
mean
);
93
}
94
else
95
SG_SPRINT
(
"%f\n"
,
mean
)
96
}
97
98
public
:
100
float64_t
mean
;
102
bool
has_conf_int
;
104
float64_t
conf_int_low
;
106
float64_t
conf_int_up
;
108
float64_t
conf_int_alpha
;
109
110
};
111
137
class
CCrossValidation
:
public
CMachineEvaluation
138
{
139
public
:
141
CCrossValidation
();
142
151
CCrossValidation
(
CMachine
* machine,
CFeatures
* features,
CLabels
* labels,
152
CSplittingStrategy
* splitting_strategy,
153
CEvaluation
* evaluation_criterion,
bool
autolock=
true
);
154
162
CCrossValidation
(
CMachine
* machine,
CLabels
* labels,
163
CSplittingStrategy
* splitting_strategy,
164
CEvaluation
* evaluation_criterion,
bool
autolock=
true
);
165
167
virtual
~CCrossValidation
();
168
170
void
set_num_runs
(int32_t num_runs);
171
173
void
set_conf_int_alpha
(
float64_t
m_conf_int_alpha
);
174
176
virtual
CEvaluationResult
*
evaluate
();
177
183
void
add_cross_validation_output
(
184
CCrossValidationOutput
* cross_validation_output);
185
187
virtual
const
char
*
get_name
()
const
188
{
189
return
"CrossValidation"
;
190
}
191
192
private
:
193
void
init();
194
195
protected
:
204
virtual
float64_t
evaluate_one_run
();
205
207
int32_t
m_num_runs
;
209
float64_t
m_conf_int_alpha
;
210
212
CList
*
m_xval_outputs
;
213
};
214
215
}
216
217
#endif
/* __CROSSVALIDATION_H_ */
SHOGUN
Machine Learning Toolbox - Documentation