How to compute Equal Error Rate (EER) on ROC curve

Saturday, September 24, 2016

Receiver operating characteristic(ROC) curve is “a graphical plot that illustrates the performance of a binary classifier system as its discrimination threshold is varied” (see wikipedia).

scikit-learn has nice functions to draw ROC curve and to compute the area under the ROC (see here). But currently there is no function to compute the Equal Error Rate (EER) on ROC curve.

After some thoughts, I have the following one-liner in Python:

from scipy.optimize import brentq
from scipy.interpolate import interp1d
eer = brentq(lambda x : 1. - x - interp1d(fpr, tpr)(x), 0., 1.)
thresh = interp1d(fpr, thresholds)(eer)

where fpr, tpr and thresholds are the returns of function roc_curve.