Equal Error Rate in Python

后端 未结 5 1765
离开以前
离开以前 2021-02-04 09:50

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

5条回答
  •  孤街浪徒
    2021-02-04 10:42

    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.

提交回复
热议问题