image.png
from sklearn.metrics import auc
import pandas as pd
import matplotlib.pyplot as plt
df = pd.read_csv('/Users/yh/Desktop/roc/df_xy.csv', )
fpr_1 = df['x'].values
tpr = df['y'].values
print(auc(fpr_1, tpr))
x2 = 1 - 0.78
y2 = 0.94
x22 = 1-0.84
y22 = 0.98
x1 = 1-0.92
y1 = 0.94
x11 = 1-1
y11 = 0.92
x3 = 1-0.8
y3 = 0.34
x33 = 1-0.92
y33 = 0.88
plt.rcParams['savefig.dpi'] = 300 #图片像素
plt.rcParams['figure.dpi'] = 300 #分辨率
plt.plot(fpr_11, tpr1)
plt.scatter(x1, y1, c='lightgreen')
plt.scatter(x11, y11, c='lightgreen')
plt.scatter(x2, y2, c='g')
plt.scatter(x22, y22, c='g')
plt.scatter(x3, y3, c='orange')
plt.scatter(x33, y33, c='orange')
plt.annotate(s="", xy=(x11, y11), xytext=(x1, y1),arrowprops={"arrowstyle":"->"}) # 1
plt.annotate(s="", xy=(x22, y22), xytext=(x2, y2),arrowprops={"arrowstyle":"->"}) # 2
plt.annotate(s="", xy=(x33, y33), xytext=(x3, y3),arrowprops={"arrowstyle":"->"}) # 3
plt.xlabel('1 - specific')
plt.ylabel('sensitivity')
plt.title('ROC')
plt.text(0.58, 0.3, 'ROC curve(area = 0.990)')
plt.ylim(0, 1.1)