Skip to content

Instantly share code, notes, and snippets.

@ryf123
Last active February 8, 2018 16:52
Show Gist options
  • Save ryf123/d087f615c65c65f24c45bd83864d32c6 to your computer and use it in GitHub Desktop.
Save ryf123/d087f615c65c65f24c45bd83864d32c6 to your computer and use it in GitHub Desktop.
Plot precision recall using sklearn
from sklearn.metrics import precision_recall_curve
import matplotlib.pyplot as plt
precision, recall, thresholds = precision_recall_curve(b_test, predictions)
plt.step(recall, precision, color='b', alpha=0.2,
where='post')
plt.fill_between(recall, precision, step='post', alpha=0.2,
color='b')
plt.xlabel('Recall')
plt.ylabel('Precision')
plt.ylim([0.0, 1.05])
plt.xlim([0.0, 1.0])
plt.title('2-class Precision-Recall curve: AP={0:0.2f}'.format(
average_precision))
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment