scikit中roc_curve的阈值学习

问题描述 投票:4回答:2

我指的是下面的链接和示例,并从这个页面发布我感到困惑的情节图。我的困惑是,只有4个阈值,但似乎roc曲线有很多数据点(> 4个数据点),想知道roc_curve如何在底层找到更多的数据点?

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 ])

enter image description here

python python-2.7 machine-learning scikit-learn roc
2个回答

0
投票

正如HaohanWang所提到的,函数roc_curve中的参数'drop_intermediate'可以降低一些次优阈值以创建更轻的ROC曲线。 (roc_curve)。如果将参数设置为False,则将显示所有阈值,例如:enter image description here计算所有阈值和相应的TPR和FPR,但是其中一些用于绘制ROC曲线无用。

© www.soinside.com 2019 - 2024. All rights reserved.