SHOGUN  3.2.1
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
CrossValidation.h
浏览该文件的文档.
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_ */
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:35
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:208
type to encapsulate the results of an evaluation run. May contain confidence interval (if conf_int_al...
void set_num_runs(int32_t num_runs)
A generic learning machine interface.
Definition: Machine.h:138
#define SG_SPRINT(...)
Definition: SGIO.h:182
Class for managing individual folds in cross-validation.
virtual const char * get_name() const
double float64_t
Definition: common.h:48
virtual const char * get_name() const
#define SG_REF(x)
Definition: SGRefObject.h:34
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()
The class Features is the base class of all feature objects.
Definition: Features.h:62
void add_cross_validation_output(CCrossValidationOutput *cross_validation_output)
#define SG_ADD(...)
Definition: SGObject.h:71
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:35
Class List implements a doubly connected list for low-level-objects.
Definition: List.h:82

SHOGUN 机器学习工具包 - 项目文档