SHOGUN  4.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules 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_ */
base class for cross-validation evaluation. Given a learning machine, a splitting strategy...
virtual EEvaluationResultType get_result_type() const
The class Labels models labels, i.e. class assignments of objects.
Definition: Labels.h:43
void set_conf_int_alpha(float64_t m_conf_int_alpha)
virtual CEvaluationResult * evaluate()
Abstract base class for all splitting types. Takes a CLabels instance and generates a desired number ...
#define REQUIRE(x,...)
Definition: SGIO.h:206
type to encapsulate the results of an evaluation run. May contain confidence interval (if conf_int_al...
#define SG_REF(x)
Definition: SGObject.h:51
void set_num_runs(int32_t num_runs)
A generic learning machine interface.
Definition: Machine.h:143
#define SG_SPRINT(...)
Definition: SGIO.h:180
Class for managing individual folds in cross-validation.
virtual const char * get_name() const
double float64_t
Definition: common.h:50
virtual const char * get_name() const
Abstract class that contains the result generated by the MachineEvaluation class. ...
Machine Evaluation is an abstract class that evaluates a machine according to some criterion...
static CCrossValidationResult * obtain_from_generic(CEvaluationResult *eval_result)
virtual float64_t evaluate_one_run()
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
The class Features is the base class of all feature objects.
Definition: Features.h:68
void add_cross_validation_output(CCrossValidationOutput *cross_validation_output)
#define SG_ADD(...)
Definition: SGObject.h:81
virtual EEvaluationResultType get_result_type() const =0
Class Evaluation, a base class for other classes used to evaluate labels, e.g. accuracy of classifica...
Definition: Evaluation.h:40
Class List implements a doubly connected list for low-level-objects.
Definition: List.h:84

SHOGUN Machine Learning Toolbox - Documentation