SHOGUN  3.2.1
 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 
14 #include <shogun/lib/config.h>
15 
18 
19 namespace shogun
20 {
21 
22 class CMachineEvaluation;
23 class CCrossValidationOutput;
24 class CList;
25 
32 {
33  public:
35  {
36  SG_ADD(&mean, "mean", "Mean of results", MS_NOT_AVAILABLE);
37  SG_ADD(&has_conf_int, "has_conf_int", "Has confidence intervals?",
39  SG_ADD(&conf_int_low, "conf_int_low", "Lower confidence bound",
41  SG_ADD(&conf_int_up, "conf_int_up", "Upper confidence bound",
43 
44  SG_ADD(&conf_int_alpha, "conf_int_alpha",
45  "Alpha of confidence interval", MS_NOT_AVAILABLE);
46 
47  mean = 0;
48  has_conf_int = 0;
49  conf_int_low = 0;
50  conf_int_up = 0;
51  conf_int_alpha = 0;
52  }
53 
59  {
61  }
62 
68  virtual const char* get_name() const { return "CrossValidationResult"; }
69 
75  CEvaluationResult* eval_result)
76  {
77  if (!eval_result)
78  return NULL;
79 
81  "CrossValidationResult::obtain_from_generic(): argument is"
82  "of wrong type!\n");
83 
84  SG_REF(eval_result);
85  return (CCrossValidationResult*) eval_result;
86  }
87 
89  virtual void print_result()
90  {
91  if (has_conf_int)
92  {
93  SG_SPRINT("[%f,%f] with alpha=%f, mean=%f\n", conf_int_low,
95  }
96  else
97  SG_SPRINT("%f\n", mean)
98  }
99 
100  public:
111 
112 };
113 
140 {
141 public:
144 
153  CCrossValidation(CMachine* machine, CFeatures* features, CLabels* labels,
154  CSplittingStrategy* splitting_strategy,
155  CEvaluation* evaluation_criterion, bool autolock=true);
156 
164  CCrossValidation(CMachine* machine, CLabels* labels,
165  CSplittingStrategy* splitting_strategy,
166  CEvaluation* evaluation_criterion, bool autolock=true);
167 
169  virtual ~CCrossValidation();
170 
172  void set_num_runs(int32_t num_runs);
173 
176 
178  virtual CEvaluationResult* evaluate();
179 
186  CCrossValidationOutput* cross_validation_output);
187 
189  virtual const char* get_name() const
190  {
191  return "CrossValidation";
192  }
193 
194 private:
195  void init();
196 
197 protected:
206  virtual float64_t evaluate_one_run();
207 
209  int32_t m_num_runs;
212 
215 };
216 
217 }
218 
219 #endif /* __CROSSVALIDATION_H_ */

SHOGUN Machine Learning Toolbox - Documentation