import matplotlib.pyplot as plt
from sklearn import metrics
#
# test data for AUC plot
#
y = [0, 1, 1, 0, 1, 0, 0, 1, 0, 0]
pred = [0.4, 0.89, 0.84, 0.74, 0.36, 0.94, 0.59, 0.71, 0.46, 0.12]
#
# caculate true positive rate and false positive rate
#
fpr, tpr, thresholds = metrics.roc_curve(y, pred)
roc_auc = metrics.auc(fpr, tpr)
display = metrics.RocCurveDisplay(fpr=fpr, tpr=tpr, roc_auc=roc_auc)
display.plot()
plt.title("AUC ROC curve")
plt.plot([0, 1], [0, 1], color='red', lw=1, linestyle='--')
plt.show()