python3 使用ROC 曲线(sklearn.metrics实现)

本文介绍了如何利用Python3和sklearn.metrics库中的roc_curve函数计算并绘制ROC曲线。ROC曲线用于评估二分类模型,每个点代表特定阈值下的真正例率(TPR)和假正例率(FPR)。示例代码展示了如何根据实际标签和预测得分计算ROC曲线,并解释了阈值、TPR和FPR的概念。
摘要由CSDN通过智能技术生成

主要需要使用的是函数roc_curve(from sklearn.metrics import roc_curve,auc)。
这里先记录一下代码的注释:

roc_curve(y_true, y_score, pos_label=None, sample_weight=None, drop_intermediate=True)
Compute Receiver operating characteristic (ROC)

Note: this implementation is restricted to the binary classification task.

Read more in the :ref:`User Guide <roc_metrics>`.

Parameters
----------

y_true : array, shape = [n_samples]
    True binary labels in range {0, 1} or {-1, 1}.  If labels are not
    binary, pos_label should be explicitly given.

y_score : array, shape = [n_samples]
    Target scores, can either be probability estimates of the positive
    class, confidence values, or non-thresholded measure of decisions
    (as returned by "decision_function" on some classifiers).

pos_label : int or str, default=None
    Label considered as positive and others are considered negative.

sample_weight : array-like
  • 1
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值