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 
118 {
119 public:
122 
131  CCrossValidation(CMachine* machine, CFeatures* features, CLabels* labels,
132  CSplittingStrategy* splitting_strategy,
133  CEvaluation* evaluation_criterion, bool autolock=true);
134 
142  CCrossValidation(CMachine* machine, CLabels* labels,
143  CSplittingStrategy* splitting_strategy,
144  CEvaluation* evaluation_criterion, bool autolock=true);
145 
147  virtual ~CCrossValidation();
148 
150  void set_num_runs(int32_t num_runs);
151 
153  virtual CEvaluationResult* evaluate();
154 
161  CCrossValidationOutput* cross_validation_output);
162 
164  virtual const char* get_name() const
165  {
166  return "CrossValidation";
167  }
168 
169 private:
170  void init();
171 
172 protected:
181  virtual float64_t evaluate_one_run();
182 
184  int32_t m_num_runs;
185 
188 };
189 
190 }
191 
192 #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:54
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:84
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