sklearn 绘制roc曲线_sklearn画ROC曲线方法总结1(plot_roc_curve)

本文介绍了如何使用sklearn.metrics.plot_roc_curve函数绘制ROC曲线。通过示例代码展示了单个模型和多个模型ROC曲线的绘制方法,并解释了RocCurveDisplay类的功能。详细解释了如何将ROC曲线添加到同一图中。
摘要由CSDN通过智能技术生成

plot_roc_curve

在sklearn0.22版本中,可以实现一行代码画出ROC-AUC图

sklearn.metrics.plot_roc_curve(estimator, X, y, sample_weight=None, drop_intermediate=True, response_method='auto', name=None, ax=None, **kwargs)

https://scikit-learn.org/stable/modules/generated/sklearn.metrics.plot_roc_curve.html?highlight=plot_roc_#sklearn.metrics.plot_roc_curve

例子:

import matplotlib.pyplot as plt

from sklearn import datasets, metrics, model_selection, svm

X, y = datasets.make_classification(random_state=0)

X_train, X_test, y_train, y_test = model_selection.train_test_split(X, y, random_state=0)

clf = svm.SVC(random_state=0)

clf.fit(X_train, y_train)

display = metrics.plot_roc_curve(clf, X_test, y_test)

print('type(display):',type(display))

plt.show()

结果:

type(di

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值