SHOGUN
v3.2.0
|
00001 /* 00002 * This program is free software; you can redistribute it and/or modify 00003 * it under the terms of the GNU General Public License as published by 00004 * the Free Software Foundation; either version 3 of the License, or 00005 * (at your option) any later version. 00006 * 00007 * Copyright (C) 2012 Jacob Walker 00008 * 00009 * Some code adapted from CrossValidation class by 00010 * Heiko Strathmann 00011 */ 00012 00013 #include "MachineEvaluation.h" 00014 #include <shogun/evaluation/CrossValidation.h> 00015 #include <shogun/machine/Machine.h> 00016 #include <shogun/evaluation/Evaluation.h> 00017 #include <shogun/evaluation/SplittingStrategy.h> 00018 #include <shogun/base/Parameter.h> 00019 #include <shogun/base/ParameterMap.h> 00020 #include <shogun/mathematics/Statistics.h> 00021 00022 using namespace shogun; 00023 00024 CMachineEvaluation::CMachineEvaluation() 00025 { 00026 init(); 00027 } 00028 00029 CMachineEvaluation::CMachineEvaluation(CMachine* machine, CFeatures* features, 00030 CLabels* labels, CSplittingStrategy* splitting_strategy, 00031 CEvaluation* evaluation_criterion, bool autolock) 00032 { 00033 init(); 00034 00035 m_machine = machine; 00036 m_features = features; 00037 m_labels = labels; 00038 m_splitting_strategy = splitting_strategy; 00039 m_evaluation_criterion = evaluation_criterion; 00040 m_autolock = autolock; 00041 00042 SG_REF(m_machine); 00043 SG_REF(m_features); 00044 SG_REF(m_labels); 00045 SG_REF(m_splitting_strategy); 00046 SG_REF(m_evaluation_criterion); 00047 } 00048 00049 CMachineEvaluation::CMachineEvaluation(CMachine* machine, CLabels* labels, 00050 CSplittingStrategy* splitting_strategy, 00051 CEvaluation* evaluation_criterion, bool autolock) 00052 { 00053 init(); 00054 00055 m_machine = machine; 00056 m_labels = labels; 00057 m_splitting_strategy = splitting_strategy; 00058 m_evaluation_criterion = evaluation_criterion; 00059 m_autolock = autolock; 00060 00061 SG_REF(m_machine); 00062 SG_REF(m_labels); 00063 SG_REF(m_splitting_strategy); 00064 SG_REF(m_evaluation_criterion); 00065 } 00066 00067 CMachineEvaluation::~CMachineEvaluation() 00068 { 00069 SG_UNREF(m_machine); 00070 SG_UNREF(m_features); 00071 SG_UNREF(m_labels); 00072 SG_UNREF(m_splitting_strategy); 00073 SG_UNREF(m_evaluation_criterion); 00074 } 00075 00076 void CMachineEvaluation::init() 00077 { 00078 m_machine = NULL; 00079 m_features = NULL; 00080 m_labels = NULL; 00081 m_splitting_strategy = NULL; 00082 m_evaluation_criterion = NULL; 00083 m_do_unlock = false; 00084 m_autolock = true; 00085 00086 SG_ADD((CSGObject**)&m_machine, "machine", "Used learning machine", 00087 MS_NOT_AVAILABLE); 00088 SG_ADD((CSGObject**)&m_features, "features", "Used features", 00089 MS_NOT_AVAILABLE); 00090 SG_ADD((CSGObject**)&m_labels, "labels", "Used labels", 00091 MS_NOT_AVAILABLE); 00092 SG_ADD((CSGObject**)&m_splitting_strategy, "splitting_strategy", 00093 "Used splitting strategy", MS_NOT_AVAILABLE); 00094 SG_ADD((CSGObject**)&m_evaluation_criterion, "evaluation_criterion", 00095 "Used evaluation criterion", MS_NOT_AVAILABLE); 00096 SG_ADD(&m_do_unlock, "do_unlock", 00097 "Whether machine should be unlocked after evaluation", 00098 MS_NOT_AVAILABLE); 00099 SG_ADD(&m_autolock, "m_autolock", 00100 "Whether machine should automatically try to be locked before ", 00101 MS_NOT_AVAILABLE); 00102 00103 /* new parameter from param version 0 to 1 */ 00104 m_parameter_map->put( 00105 new SGParamInfo("m_do_unlock", CT_SCALAR, ST_NONE, PT_BOOL, 1), 00106 new SGParamInfo() 00107 ); 00108 00109 /* new parameter from param version 0 to 1 */ 00110 m_parameter_map->put( 00111 new SGParamInfo("m_autolock", CT_SCALAR, ST_NONE, PT_BOOL, 1), 00112 new SGParamInfo() 00113 ); 00114 } 00115 00116 CMachine* CMachineEvaluation::get_machine() const 00117 { 00118 SG_REF(m_machine); 00119 return m_machine; 00120 } 00121 00122 EEvaluationDirection CMachineEvaluation::get_evaluation_direction() 00123 { 00124 return m_evaluation_criterion->get_evaluation_direction(); 00125 }