openModeller  Version 1.5.0
ConfusionMatrix.hh
Go to the documentation of this file.
1 
28 #ifndef _CONFUSIONMATRIXHH_
29 #define _CONFUSIONMATRIXHH_
30 
31 #include <openmodeller/om_defs.hh>
33 
34 #include <openmodeller/Model.hh>
35 
38 #include <openmodeller/Sampler.hh>
39 
40 #define CONF_MATRIX_DEFAULT_THRESHOLD 0.5
41 
61 class dllexp ConfusionMatrix
62 {
63 public:
70  ConfusionMatrix(Scalar predictionThreshold = CONF_MATRIX_DEFAULT_THRESHOLD, bool ignoreAbsences=false);
71 
75  ~ConfusionMatrix();
76 
84  void reset(Scalar predictionThreshold = CONF_MATRIX_DEFAULT_THRESHOLD, bool ignoreAbsences=false);
85 
92  void setLowestTrainingThreshold(const Model& model, const SamplerPtr& sampler);
93 
105  void calculate(const EnvironmentPtr & env, const Model& model,
106  const OccurrencesPtr& presences, const OccurrencesPtr& absences = OccurrencesPtr());
107 
114  void calculate(const Model& model, const SamplerPtr& sampler);
115 
121  int getValue(Scalar predictionValue, Scalar actualValue) const;
122 
128  double getAccuracy() const;
129 
136  double getOmissionError() const;
137 
144  double getCommissionError() const;
145 
149  double getThreshold() const { return _predictionThreshold; }
150 
154  bool ready() const { return _ready; }
155 
159  ConfigurationPtr getConfiguration() const;
160 
161 private:
162  /*
163  * Representation of the confusion matrix on _confMatrix:
164  * 1st row is predicted absent
165  * 2nd row is predicted present
166  * 1st column is actual absent
167  * 2nd column is actual present
168  *
169  * Note: it is inverted from the matrix representation above
170  * so that the indexes match the actual or predicted values,
171  * i.e., index[0][1] corresponds to predicted absence (0)
172  * and actual presence (1).
173  */
174  int _confMatrix[2][2];
175 
177 
179 
180  bool _ready;
181 };
182 
183 #endif
ReferenceCountedPointer< OccurrencesImpl > OccurrencesPtr
Definition: Occurrences.hh:47
double Scalar
Type of map values.
Definition: om_defs.hh:39
bool ready() const
double getThreshold() const
#define CONF_MATRIX_DEFAULT_THRESHOLD