Skip to content

Instantly share code, notes, and snippets.

@vikramsoni2
Created October 3, 2018 07:45
Show Gist options
  • Save vikramsoni2/614a95a5c0ad87de650f9b86a9062909 to your computer and use it in GitHub Desktop.
Save vikramsoni2/614a95a5c0ad87de650f9b86a9062909 to your computer and use it in GitHub Desktop.
precision recall and auc plot
def plot_auc_pr(y_test, y_pred):
fig = plt.figure(figsize=(20,7))
plt.subplot(1,2,1)
fpr, tpr, _ = roc_curve(y_test, y_pred)
auc = roc_auc_score(y_test, y_pred)
plt.plot(fpr,tpr,label="auc="+str(auc))
plt.title('roc-auc curve')
plt.legend(loc=4)
plt.subplot(1,2,2)
pr, rc, _ = precision_recall_curve(y_test, y_pred)
auc = roc_auc_score(y_test, y_pred)
plt.plot(pr,rc,label="auc="+str(auc))
plt.title('precision recall curve')
plt.xlabel("precision")
plt.ylabel("recall")
plt.legend(loc=1 )
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment