栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

Python画ROC图与AUC值

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Python画ROC图与AUC值

ROC和AUC定义

ROC全称是“受试者工作特征”(Receiver Operating Characteristic)。ROC曲线的面积就是AUC(Area Under the Curve)。AUC用于衡量“二分类问题”机器学习算法性能(泛化能力)

计算ROC的关键概念
  • P(Positive):预测值为正例
  • N(Negative):预测值为反例
  • T(True):预测值与真实值相同
  • F(False):预测值与真实值相反
  • TP:被模型预测为正类的正样本
  • TN:被模型预测为负类的负样本
  • FP:被模型预测为正类的负样本
  • FN:被模型预测为负类的正样本

from sklearn.metrics import roc_curve
from sklearn.metrics import auc
# fpr, tpr
fpr, tpr, thresholds = roc_curve(train_y, oof_lgb,pos_label=1)
# 计算auc
auc = auc(fpr, tpr)  


plt.xlim(0, 1)
plt.ylim(0, 1)
plt.plot(fpr, tpr, label='LightGBM (AUC = {:.3f})'.format(auc))
plt.plot([0, 1], [0, 1], 'k--')
plt.xlabel('False positive rate')
plt.ylabel('True positive rate')
plt.title('ROC curve ')
plt.legend(loc='best')
plt.show()

参考:
https://blog.csdn.net/dongjinkun/article/details/109899733
https://blog.csdn.net/weixin_45592298/article/details/115307705

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/530305.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号