Commit 5a1e06747277bf005a6c4ea657aec5cf7b5726df

Authored by Ben Klein
2 parents e226f069 3c69526b

Merge pull request #306 from biometrics/pessimistic_tie_break

break comparison sorting ties pessimistically in -eval
Showing 1 changed file with 7 additions and 2 deletions
openbr/core/eval.cpp
... ... @@ -36,7 +36,12 @@ struct Comparison
36 36 Comparison() {}
37 37 Comparison(float _score, int _target, int _query, bool _genuine)
38 38 : score(_score), target(_target), query(_query), genuine(_genuine) {}
39   - inline bool operator<(const Comparison &other) const { return score > other.score; }
  39 +
  40 + inline bool operator<(const Comparison &other) const
  41 + {
  42 + if (score != other.score) return (score > other.score);
  43 + else return !genuine; // Tie-break favors pessimistic behavior of ranking impostors higher.
  44 + }
40 45 };
41 46  
42 47 #undef FAR // Windows preprecessor definition conflicts with variable name
... ... @@ -183,7 +188,7 @@ float Evaluate(const Mat &amp;simmat, const Mat &amp;mask, const QString &amp;csv, const QSt
183 188 if (impostorCount == 0) qFatal("No impostor scores!");
184 189  
185 190 // Sort comparisons by simmat_val (score)
186   - std::sort(comparisons.begin(), comparisons.end());
  191 + std::stable_sort(comparisons.begin(), comparisons.end());
187 192  
188 193 QList<OperatingPoint> operatingPoints;
189 194 QList<float> genuines; genuines.reserve(sqrt((float)comparisons.size()));
... ...