Machine Learning Basics·Machine learning from data to a responsible model

Evaluation

Choose metrics that match the cost of mistakes.

Intermediate 15 min read Lesson 6 of 300 Challenge included
What you will be able to do
  • Use a confusion matrix before a single number.
  • Choose precision or recall based on the cost.
  • Use cross-validation for small datasets.
  • Report a baseline alongside the model.

In plain English

Every metric answers a different question. Precision asks how many predicted positives are real; recall asks how many real positives were found. F1 balances them. Confusion matrices show the actual errors.

evaluate.pyPython
from sklearn.metrics import confusion_matrix, precision_score, recall_score

print(confusion_matrix(y_test, pred))
print('precision', precision_score(y_test, pred))
print('recall', recall_score(y_test, pred))
Your turn

Print a confusion matrix

Easy

Compute the confusion matrix for y_test and pred.

PYTHON · starter
from sklearn.metrics import confusion_matrix
Check your understanding before moving on.
Knowledge checkQuestion 1

What does recall measure?

Select an answer to continue
Study tools

Make it yours.

Keep a private note for this lesson, then turn the key ideas into flashcards you can revisit.

Sign in to save notes and flashcards.Both are private to your account and stay with your progress.
Sign in
Finished reading?

Lock in what you just learned.

Mark this lesson complete to save your place and move one step closer to the certificate.

Lesson 6 of 300 · 0% of course