import numpy as np
from sklearn import metrics
from matplotlib import pyplot
path = "PFS3_val_result.csv"
with open(path, 'r') as f:
file_list = f.read()
file_list = file_list.split('\n')[1:-1]
file_list = [file.split(',') for file in file_list]
y = np.array([float(y[1]) for y in file_list])
scores1 = np.array([float(preds[2]) for preds in file_list])
scores2 = np.array([float(preds[3]) for preds in file_list])
scores3 = np.array([float(preds[4]) for preds in file_list])
fpr1, tpr1, thresholds1 = metrics.roc_curve(y, scores1, pos_label=1)
fpr2, tpr2, thresholds2 = metrics.roc_curve(y, scores2, pos_label=1)
fpr3, tpr3, thresholds3 = metrics.roc_curve(y, scores3, pos_label=1)
#print("fpr:{},tpr:{},thresholds:{}".format(fpr,tpr,thresholds))
roc_auc1 = metrics.auc(fpr1, tpr1)
roc_auc2 = metrics.auc(fpr2, tpr2)
roc_auc3 = metrics.auc(fpr3, tpr3)
print(roc_auc1,roc_auc2,roc_auc3)
pyplot.plot(fpr1, tpr1, lw=1, color='green', label="Deep Learning, AUC=%0.3f" % (roc_auc1))
pyplot.plot(fpr2, tpr2, lw=1, color='blue', label="Radiomics, AUC=%0.3f" % (roc_auc2))
pyplot.plot(fpr3, tpr3, lw=1, color='red', label="Deep Learning+Radiomics, AUC=%0.3f" % (roc_auc3))
pyplot.xlim([0.00, 1.0])
pyplot.ylim([0.00, 1.0])
pyplot.xlabel("False Positive Rate")
pyplot.ylabel("True Positive Rate")
pyplot.title("PFS3_VAL_ROC")
pyplot.legend(loc="lower right")
pyplot.savefig(r"./PFS3_VAL_ROC.png")
来源:CSDN
作者:愿十四亿神州尽舜尧
链接:https://blog.csdn.net/weixin_41783077/article/details/103886215