Skip to content

Instantly share code, notes, and snippets.

@Keiku Keiku/roc_auc.py

Last active Oct 11, 2019
Embed
What would you like to do?
Plot ROC curve.
import matplotlib.pyplot as plt
from sklearn.metrics import roc_curve, auc
import seaborn as sns
sns.set('talk', 'whitegrid', 'dark', font_scale=1.5, font='Ricty',
rc={"lines.linewidth": 2, 'grid.linestyle': '--'})
fpr, tpr, _ = roc_curve([1, 0, 1, 0, 1, 0, 0], [0.9, 0.8, 0.7, 0.7, 0.6, 0.5, 0.4])
roc_auc = auc(fpr, tpr)
lw = 2
plt.figure()
plt.plot(fpr, tpr, color='darkorange',
lw=lw, label='ROC curve (AUC = %0.2f)' % roc_auc)
plt.plot([0, 1], [0, 1], color='navy', lw=lw, 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('ROC曲線(Receiver Operating Characteristic curve)')
plt.legend(loc="lower right")
plt.show()
plt.savefig('roc_auc.png')
plt.close()
@DavidRosen

This comment has been minimized.

Copy link

DavidRosen commented Sep 25, 2019

Would anyone like to see a seaborn-only alternative?

@shaunildm

This comment has been minimized.

Copy link

shaunildm commented Oct 11, 2019

Would anyone like to see a seaborn-only alternative?

yes, that would be great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.