Last active
February 8, 2018 16:52
-
-
Save ryf123/d087f615c65c65f24c45bd83864d32c6 to your computer and use it in GitHub Desktop.
Plot precision recall using sklearn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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