MCPcopy Create free account
hub / github.com/davisking/dlib / equal_error_rate

Function equal_error_rate

dlib/statistics/lda.h:196–225  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

194// ----------------------------------------------------------------------------------------
195
196 inline std::pair<double,double> equal_error_rate (
197 const std::vector<double>& low_vals,
198 const std::vector<double>& high_vals
199 )
200 {
201 if (low_vals.size() == 0 && high_vals.size() == 0)
202 return std::make_pair(0,0);
203 else if (low_vals.size() == 0)
204 return std::make_pair(0, min(mat(high_vals)));
205 else if (high_vals.size() == 0)
206 return std::make_pair(0, max(mat(low_vals))+1);
207
208 // Find the point of equal error rates
209 double best_thresh = 0;
210 double best_error = 0;
211 double best_delta = std::numeric_limits<double>::infinity();
212 for (const auto& pt : compute_roc_curve(high_vals, low_vals))
213 {
214 const double false_negative_rate = 1-pt.true_positive_rate;
215 const double delta = std::abs(false_negative_rate - pt.false_positive_rate);
216 if (delta < best_delta)
217 {
218 best_delta = delta;
219 best_error = std::max(false_negative_rate, pt.false_positive_rate);
220 best_thresh = pt.detection_threshold;
221 }
222 }
223
224 return std::make_pair(best_error, best_thresh);
225 }
226
227// ----------------------------------------------------------------------------------------
228

Callers 2

test_ldaMethod · 0.85
test_equal_error_rateMethod · 0.85

Calls 6

compute_roc_curveFunction · 0.85
absFunction · 0.85
matFunction · 0.70
minFunction · 0.50
maxFunction · 0.50
sizeMethod · 0.45

Tested by 2

test_ldaMethod · 0.68
test_equal_error_rateMethod · 0.68