SHOGUN  4.2.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 
29 {
30  public:
32  {
33  SG_ADD(&mean, "mean", "Mean of results", MS_NOT_AVAILABLE);
34  SG_ADD(&std_dev, "std_dev",
35  "Standard deviation of cross-validation folds", MS_NOT_AVAILABLE);
36 
37  mean = 0;
38  std_dev = 0;
39  }
40 
46  {
48  }
49 
55  virtual const char* get_name() const { return "CrossValidationResult"; }
56 
62  CEvaluationResult* eval_result)
63  {
64  if (!eval_result)
65  return NULL;
66 
68  "CrossValidationResult::obtain_from_generic(): argument is"
69  "of wrong type!\n");
70 
71  SG_REF(eval_result);
72  return (CCrossValidationResult*) eval_result;
73  }
74 
76  virtual void print_result()
77  {
78  SG_SPRINT("%f+-%f\n", mean, std_dev);
79  }
80 
81  public:
86 };
87 
113 {
114 public:
117 
126  CCrossValidation(CMachine* machine, CFeatures* features, CLabels* labels,
127  CSplittingStrategy* splitting_strategy,
128  CEvaluation* evaluation_criterion, bool autolock=true);
129 
137  CCrossValidation(CMachine* machine, CLabels* labels,
138  CSplittingStrategy* splitting_strategy,
139  CEvaluation* evaluation_criterion, bool autolock=true);
140 
142  virtual ~CCrossValidation();
143 
145  void set_num_runs(int32_t num_runs);
146 
148  virtual CEvaluationResult* evaluate();
149 
156  CCrossValidationOutput* cross_validation_output);
157 
159  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;
180 
183 };
184 
185 }
186 
187 #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
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.
#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