2024-07-03 06:05:12 发布
网友
假设我从csv文件的3列中检索了3个数组,它们是:
csv
y1=['1', '0', '0', '0', '1']; y2=['1', '1', '1', '0', '0']; y3=['0', '1', '1', '0', '1'];
如何绘制2个roc,使y1vsy2和{}vsy3(在sklearn中)?在
y1
y2
y3
假设y1是你的标签,y2和y3是你的分数,下面的代码应该可以做到:
y1=[1, 0, 0, 0, 1]; y2=[1, 1, 0, 0, 1]; y3=[0, 0, 1, 0, 1]; from sklearn.metrics import * import pandas as pd import matplotlib.pyplot as plt plt.figure(figsize=(14,10),dpi=640) fpr, tpr, thresholds = roc_curve(y1, y2) auc1 = auc(fpr,tpr) plt.plot(fpr, tpr,label="AUC Y2:{0}".format(auc1),color='red', linewidth=2) fpr, tpr, thresholds = roc_curve(y1, y3) auc1 = auc(fpr,tpr) plt.plot(fpr, tpr,label="AUC Y3:{0}".format(auc1),color='blue', linewidth=2) plt.plot([0, 1], [0, 1], 'k ', lw=1) plt.xlim([0.0, 1.0]) plt.ylim([0.0, 1.05]) plt.xlabel('False Positive Rate') plt.ylabel('True Positive Rate') plt.title('ROC') plt.grid(True) plt.legend(loc="lower right") plt.show()
假设y1是你的标签,y2和y3是你的分数,下面的代码应该可以做到:
相关问题 更多 >
编程相关推荐