Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef __CROSSVALIDATION_H_
00012 #define __CROSSVALIDATION_H_
00013
00014 #include <shogun/base/SGObject.h>
00015 #include <shogun/evaluation/Evaluation.h>
00016
00017 namespace shogun
00018 {
00019
00020 class CMachine;
00021 class CFeatures;
00022 class CLabels;
00023 class CSplittingStrategy;
00024 class CEvaluation;
00025
00032 class CrossValidationResult
00033 {
00034 public:
00036 void print_result()
00037 {
00038 if (has_conf_int)
00039 {
00040 SG_SPRINT("[%f,%f] with alpha=%f, mean=%f\n", conf_int_low,
00041 conf_int_up, conf_int_alpha, mean);
00042 }
00043 else
00044 SG_SPRINT("%f\n", mean);
00045 }
00046
00047 public:
00049 float64_t mean;
00051 bool has_conf_int;
00053 float64_t conf_int_low;
00055 float64_t conf_int_up;
00057 float64_t conf_int_alpha;
00058
00059 };
00060
00081 class CCrossValidation: public CSGObject
00082 {
00083 public:
00085 CCrossValidation();
00086
00094 CCrossValidation(CMachine* machine, CFeatures* features, CLabels* labels,
00095 CSplittingStrategy* splitting_strategy,
00096 CEvaluation* evaluation_criterium);
00097
00099 virtual ~CCrossValidation();
00100
00102 EEvaluationDirection get_evaluation_direction();
00103
00111 CrossValidationResult evaluate();
00112
00114 CMachine* get_machine() const;
00115
00117 void set_num_runs(int32_t num_runs);
00118
00120 void set_conf_int_alpha(float64_t m_conf_int_alpha);
00121
00123 inline virtual const char* get_name() const
00124 {
00125 return "CrossValidation";
00126 }
00127
00128 private:
00129 void init();
00130
00131 protected:
00140 virtual float64_t evaluate_one_run();
00141
00142 private:
00143 int32_t m_num_runs;
00144 float64_t m_conf_int_alpha;
00145
00146 CMachine* m_machine;
00147 CFeatures* m_features;
00148 CLabels* m_labels;
00149 CSplittingStrategy* m_splitting_strategy;
00150 CEvaluation* m_evaluation_criterium;
00151 };
00152
00153 }
00154
00155 #endif