【问题标题】:sklearn's roc_curve() function returns thresholds and fpr of different dimensionssklearn 的 roc_curve() 函数返回不同维度的阈值和 fpr
【发布时间】:2021-05-22 11:16:02
【问题描述】:

我假设roc_curve() 为每个阈值计算 fpr 和 tpr。 但是下面的代码显示fpr和thresholds有不同的维度。

from sklearn.metrics import roc_curve
fpr,tpr,thresholds = roc_curve(y_train_5,y_scores)
fpr.shape #(3908,)
thresholds.shape #(59966,)

我也想知道为什么

precisions,recalls,thresholds = precision_recall_curve(y_train_5,y_scores)
precisions #(59967,)
thresholds #(59966,)

precisions 的维度与 thresholds' 相差 1?

【问题讨论】:

    标签: machine-learning scikit-learn roc


    【解决方案1】:

    对于 roc_curve() 的关注点,与精度/召回曲线不同,输出的长度确实取决于 drop_intermediate 选项(默认为 True),用于降低次优阈值(请参阅 here 以供参考)。

    对于第二点,只要达到完全召回,就不再输出阈值。这可能是原因; this linkthis link 也可能有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-12-28
      • 2015-07-15
      • 2017-01-02
      • 2014-06-05
      • 2014-10-23
      • 1970-01-01
      • 2020-06-23
      • 2015-08-28
      相关资源
      最近更新 更多