SHOGUN  v3.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  SG_ADD(&mean, "mean", "Mean of results", MS_NOT_AVAILABLE);
35  SG_ADD(&has_conf_int, "has_conf_int", "Has confidence intervals?",
37  SG_ADD(&conf_int_low, "conf_int_low", "Lower confidence bound",
39  SG_ADD(&conf_int_up, "conf_int_up", "Upper confidence bound",
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 
57  {
59  }
60 
66  virtual const char* get_name() const { return "CrossValidationResult"; }
67 
73  CEvaluationResult* eval_result)
74  {
75  if (!eval_result)
76  return NULL;
77 
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,
93  }
94  else
95  SG_SPRINT("%f\n", mean)
96  }
97 
98  public:
109 
110 };
111 
138 {
139 public:
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 
174 
176  virtual CEvaluationResult* evaluate();
177 
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;
210 
213 };
214 
215 }
216 
217 #endif /* __CROSSVALIDATION_H_ */

SHOGUN Machine Learning Toolbox - Documentation