Skip to content

Instantly share code, notes, and snippets.

@elena-roff
Created March 29, 2019 10:38
Show Gist options
  • Save elena-roff/dd96a7faa3ae99da1eb56d1d294a96bd to your computer and use it in GitHub Desktop.
Save elena-roff/dd96a7faa3ae99da1eb56d1d294a96bd to your computer and use it in GitHub Desktop.
Precision / Recall curve
from sklearn.metrics import precision_score, recall_score, precision_recall_curve
import matplotlib.pyplot as plt
def plt_prc(recall, precision, label=None):
plt.step(recall, precision, label=label)
plt.xlabel('Recall')
plt.ylabel('Precision')
plt.ylim([0.0, 1.05])
plt.xlim([0.0, 1.0])
precision, recall, thresholds = precision_recall_curve(data['label'], data['probability']
_ = plt_prc(recall, precision, label=f'PRC {<description of plot>}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment