SHOGUN  v2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
16 
17 namespace shogun
18 {
19 
20 class CMachineEvaluation;
21 class CCrossValidationOutput;
22 class CList;
23 
30 {
31  public:
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 
47  {
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,
65  }
66  else
67  SG_SPRINT("%f\n", mean);
68  }
69 
70  public:
81 
82 };
83 
110 {
111 public:
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 
146 
148  virtual CEvaluationResult* evaluate();
149 
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;
182 
185 };
186 
187 }
188 
189 #endif /* __CROSSVALIDATION_H_ */

SHOGUN Machine Learning Toolbox - Documentation