问题描述
我正在尝试为多类预测(虹膜数据集-3类)问题重现ROC曲线。如果测试数据集和测试预测为三维数组格式,则sklearn
软件包中的This script可以正常工作。如何使用以下格式绘制相同的ROC曲线?
y_test
array([0,2,1,2])
y_preds
tensor([0,2])
我尝试过的代码
from sklearn import metrics
fpr,tpr,thresholds = metrics.roc_curve(y_test,y_score,pos_label=2)
roc_auc = auc(fpr,tpr)
plt.figure()
lw = 2
plt.plot(fpr,color='darkorange',lw=lw,label='ROC curve (area = %0.2f)' % roc_auc)
plt.plot([0,1],[0,color='navy',linestyle='--')
plt.xlim([0.0,1.0])
plt.ylim([0.0,1.05])
plt.xlabel('False Positive Rate')
plt.ylabel('True Positive Rate')
plt.title('Receiver operating characteristic example')
plt.legend(loc="lower right")
plt.show()
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)