Commit ef682da1 authored by André Anjos's avatar André Anjos

Merge branch 'fix_minimizing_threshold' into 'master'

Fix minimizing threshold

Closes #59

See merge request !92
parents 022f9712 ad5bb33c
Pipeline #28002 failed with stages
in 4 minutes and 4 seconds
......@@ -211,6 +211,7 @@ double minimizingThreshold(const blitz::Array<double, 1> &negatives,
else
current_threshold += *pos_it;
current_threshold /= 2;
}
} // while
......@@ -222,6 +223,22 @@ double minimizingThreshold(const blitz::Array<double, 1> &negatives,
min_threshold = current_threshold;
}
// now we just double check choosing the threshold higher than all scores will not improve the min_predicate
if (neg_it != negatives.end() || pos_it != positives.end()) {
double last_threshold = current_threshold;
if (neg_it != negatives.end())
last_threshold = std::nextafter(negatives(negatives.extent(0)-1), negatives(negatives.extent(0)-1)+1);
else {
if (pos_it != positives.end())
last_threshold = std::nextafter(positives(positives.extent(0)-1), positives(positives.extent(0)-1)+1);
}
current_predicate = predicate(0., 1.);
if (current_predicate < min_predicate) {
min_predicate = current_predicate;
min_threshold = last_threshold;
}
}
// return the best threshold found
return min_threshold;
}
......
......@@ -489,3 +489,18 @@ def test_open_set_rates():
assert abs(bob.measure.recognition_rate(cmc_scores) - 6. / 9.) < 1e-8
assert abs(bob.measure.recognition_rate(
cmc_scores, threshold=0.5) - 6. / 8.) < 1e-8
def test_mindcf():
""" Test outlier scores in negative set
"""
from bob.measure import min_weighted_error_rate_threshold, farfrr
cost = 0.99
negatives = [-3, -2, -1, -0.5, 4]
positives = [0.5, 3]
th = min_weighted_error_rate_threshold(negatives, positives, cost, True)
far, frr = farfrr(negatives, positives, th)
mindcf = (cost * far + (1-cost)*frr)*100
assert mindcf< 1.0 + 1e-8
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment