21 #include "drwnClassifier.h"
71 inline int numSamples()
const {
return _numPositiveSamples + _numNegativeSamples; }
75 inline int numMisses()
const;
80 inline void setPosWeight(
double w) { DRWN_ASSERT(w > 0.0); _posWeight = w; }
84 inline void normalize();
90 bool write(
const char *filename)
const;
92 bool read(
const char *filename);
102 void accumulatePositives(
double score,
int count = 1);
104 void accumulatePositives(
const vector<double>& scores);
106 void accumulateNegatives(
double score,
int count = 1);
108 void accumulateNegatives(
const vector<double> &scores);
111 void accumulateMisses(
int count = 1);
131 vector<pair<double, double> > getCurve()
const;
133 void writeCurve(
const char *filename)
const;
135 double averagePrecision(
unsigned numPoints = 11)
const;
142 if ((_numPositiveSamples > 0) && (_numNegativeSamples > 0)) {
143 _posWeight = (double)_numNegativeSamples / (
double)_numPositiveSamples;
150 int count = _numPositiveSamples;
151 for (map<
double, pair<int, int> >::const_iterator it = _scoredResults.begin();
152 it != _scoredResults.end(); it++) {
153 count -= it->second.first;
void setPosWeight(double w)
set the relative weight of a positive sample to a negative sample
Definition: drwnClassificationResults.h:80
static bool INCLUDE_MISSES
true if some positive samples are never scored
Definition: drwnClassificationResults.h:50
int numSamples() const
return the total number (positive and negative) of samples accumulated
Definition: drwnClassificationResults.h:71
int numThresholds() const
return the number of unique classification scores
Definition: drwnClassificationResults.h:73
map< double, pair< int, int > > _scoredResults
number of positives (first) and negatives (second) grouped by score
Definition: drwnClassificationResults.h:54
int numPositives() const
return the number os positive samples accumulated
Definition: drwnClassificationResults.h:67
int numMisses() const
return the number of positive samples that have not been scored
Definition: drwnClassificationResults.h:149
Precision-recall curve.
Definition: drwnClassificationResults.h:122
void normalize()
this will change the weight of the positive examples such that overall positive and negative examples...
Definition: drwnClassificationResults.h:140
int numNegatives() const
return the number of negative samples accumulated
Definition: drwnClassificationResults.h:69
Implements the interface for a generic machine learning classifier.
Definition: drwnClassifier.h:31
double getPosWeight() const
return the relative weight of a positive sample to a negative sample
Definition: drwnClassificationResults.h:78
double _posWeight
weight of positive-to-negative count
Definition: drwnClassificationResults.h:57
int _numPositiveSamples
must be greater than sum(_scoredResults.first)
Definition: drwnClassificationResults.h:55
int _numNegativeSamples
must be must be equal to sum(_scoredResults.second)
Definition: drwnClassificationResults.h:56
Encapsulates summary of classifier output from which various curves can be generated (e...
Definition: drwnClassificationResults.h:48
Implements a cacheable dataset containing feature vectors, labels and optional weights.
Definition: drwnDataset.h:43