The Precision-Recall Trade-Off

MyModel.predict_proba(X_val)
import numpy as np
import matplotlib.pyplot as plt
from sklearn.metrics import precision_score, recall_score
thresholds = np.linspace(0, 1, 100)
precision_scores = []
recall_scores = []
for threshold in thresholds: adjusted_predictions = [1 if p > threshold else 0 for p in predictions] precision_scores.append(precision_score(y_val, adjusted_predictions)) recall_scores.append(recall_score(y_val, adjusted_predictions))plt.plot(thresholds, precision_scores, label="precision")
plt.plot(thresholds, recall_scores, label="recall")
plt.show()
  1. Image link: https://qph.fs.quoracdn.net/main-qimg-18cd74b05b850406e1c01b76b1cb8fd6
  2. Image link: https://machinelearningaptitude.com/wp-content/uploads/2019/03/precision-recall-tradeoff.png

--

--

--

Data scientist learning at Flat Iron School

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

The definitive guide to Accuracy, Precision, and Recall for product developers

What Deep Learning Can Offer to Business

Solving Match-3 Games with Graph Algorithms

Curse of Dimensionality through Monte Carlo techniques in Hyperspace

Predicting Metrics With Neural Nets

Initial

CNN for MNIST Handwritten dataset

Classification of Signature and Text images using CNN and Deploying the model on Google Cloud ML…

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Datascience George

Datascience George

Data scientist learning at Flat Iron School

More from Medium

Credit Card Applications and Logistic Regression

Interview Questions for My Data Science Besties, Part 2: Linear Regression

Grid search CV 💪 Vs Randomize search CV 🦾

Approach to missing values in python E01