openModeller
Version 1.4.0
|
00001 00028 #ifndef _CONFUSIONMATRIXHH_ 00029 #define _CONFUSIONMATRIXHH_ 00030 00031 #include <openmodeller/om_defs.hh> 00032 #include <openmodeller/Configuration.hh> 00033 00034 #include <openmodeller/Model.hh> 00035 00036 #include <openmodeller/Occurrences.hh> 00037 #include <openmodeller/Environment.hh> 00038 #include <openmodeller/Sampler.hh> 00039 00040 #define CONF_MATRIX_DEFAULT_THRESHOLD 0.5 00041 00061 class dllexp ConfusionMatrix 00062 { 00063 public: 00070 ConfusionMatrix(Scalar predictionThreshold = CONF_MATRIX_DEFAULT_THRESHOLD, bool ignoreAbsences=false); 00071 00075 ~ConfusionMatrix(); 00076 00084 void reset(Scalar predictionThreshold = CONF_MATRIX_DEFAULT_THRESHOLD, bool ignoreAbsences=false); 00085 00092 void setLowestTrainingThreshold(const Model& model, const SamplerPtr& sampler); 00093 00105 void calculate(const EnvironmentPtr & env, const Model& model, 00106 const OccurrencesPtr& presences, const OccurrencesPtr& absences = OccurrencesPtr()); 00107 00114 void calculate(const Model& model, const SamplerPtr& sampler); 00115 00121 int getValue(Scalar predictionValue, Scalar actualValue) const; 00122 00128 double getAccuracy() const; 00129 00136 double getOmissionError() const; 00137 00144 double getCommissionError() const; 00145 00149 double getThreshold() const { return _predictionThreshold; } 00150 00154 bool ready() const { return _ready; } 00155 00159 ConfigurationPtr getConfiguration() const; 00160 00161 private: 00162 /* 00163 * Representation of the confusion matrix on _confMatrix: 00164 * 1st row is predicted absent 00165 * 2nd row is predicted present 00166 * 1st column is actual absent 00167 * 2nd column is actual present 00168 * 00169 * Note: it is inverted from the matrix representation above 00170 * so that the indexes match the actual or predicted values, 00171 * i.e., index[0][1] corresponds to predicted absence (0) 00172 * and actual presence (1). 00173 */ 00174 int _confMatrix[2][2]; 00175 00176 Scalar _predictionThreshold; 00177 00178 bool _ignoreAbsences; 00179 00180 bool _ready; 00181 }; 00182 00183 #endif