Could anybody tell me how could I compute Equal Error Rate(EER) from ROC Curve in python? In scikit-learn there is method to compute roc curve and auc but could not find the met
For any one else whom arrives here via a Google search. The Fran answer is incorrect as Gerhard points out. The correct code would be:
fpr, tpr, threshold = roc_curve(y, y_pred, pos_label=1)
fnr = 1 - tpr
eer_threshold = threshold(np.nanargmin(np.absolute((fnr - fpr))))
Note that this gets you the threshold at which the EER occurs not, the EER. The EER is defined as FPR = 1 - PTR = FNR. Thus to get the EER (the actual error rate) you could use the following:
EER = fpr(np.nanargmin(np.absolute((fnr - fpr))))
as a sanity check the value should be close to
EER = fnr(np.nanargmin(np.absolute((fnr - fpr))))
since this is an approximation.