thresholds in roc_curve in scikit learn

情到浓时终转凉″ 提交于 2020-01-01 10:52:40

问题


I am referring to the below link and sample, and post the plot diagram from this page where I am confused. My confusion is, there are only 4 threshold, but it seems the roc curve has many data points (> 4 data points), wondering how roc_curve working underlying to find more data points?

http://scikit-learn.org/stable/modules/model_evaluation.html#roc-metrics

>>> import numpy as np
>>> from sklearn.metrics import roc_curve
>>> y = np.array([1, 1, 2, 2])
>>> scores = np.array([0.1, 0.4, 0.35, 0.8])
>>> fpr, tpr, thresholds = roc_curve(y, scores, pos_label=2)
>>> fpr
array([ 0. ,  0.5,  0.5,  1. ])
>>> tpr
array([ 0.5,  0.5,  1. ,  1. ])
>>> thresholds
array([ 0.8 ,  0.4 ,  0.35,  0.1 ])


回答1:


That plot is actually from this example: http://scikit-learn.org/stable/auto_examples/model_selection/plot_roc.html




回答2:


As HaohanWang mentioned, the parameter 'drop_intermediate' in function roc_curve can drop some suboptimal thresholds for creating lighter ROC curves. (roc_curve). If set the parameter to be False, all threshold will be displayed, for example: enter image description here all thresholds and corresponding TPRs and FPRs are calculated, but some of them are useless for plotting the ROC curve.



来源:https://stackoverflow.com/questions/39155900/thresholds-in-roc-curve-in-scikit-learn

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