Scikit - How to define thresholds for plotting roc curve

删除回忆录丶 提交于 2019-12-06 05:10:46

Each value in fpr and tpr is computed for a certain threshold, the values of these thresholds are returned in the third output roc_curve (the variable _ in your case)

here is an example

import numpy as np
from sklearn import metrics
y_true = np.array([1, 1, 2, 2])
y_scores = np.array([0.1, 0.4, 0.35, 0.8])
fpr, tpr, thresholds = metrics.roc_curve(y_true, y_scores, pos_label=2)

tabulating the data to demo

   Threshold  FPR  TPR
0       0.80  0.0  0.5
1       0.40  0.5  0.5
2       0.35  0.5  1.0
3       0.10  1.0  1.0

The first row above shows that for threshold .8 fpr is 0 and tpr is .5 and so on

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!