Evaluation
Choose metrics that match the cost of mistakes.
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.
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
EasyPrint a confusion matrix
Compute the confusion matrix for y_test and pred.
PYTHON · starter
from sklearn.metrics import confusion_matrixCheck 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 inFinished reading?
Lock in what you just learned.
0%
Mark this lesson complete to save your place and move one step closer to the certificate.