Machine Learning, FoundationsLesson 45 of 92

Module 5 · Measuring a model honestly

ROC and precision-recall: every threshold at once

In this lesson

  • 9 min read
  • 6 reading sections
  • Knowledge check
  • Lesson 4 of 11 in this chapter

This chapter’s goalGiven a fitted classifier and a stated cost of each kind of error, compute the confusion matrix at a chosen threshold, defend that threshold by expected cost, say whether the model’s probabilities are calibrated, decide with an interval whether one model genuinely beats another, and report per-group performance with a defensible fairness criterion and its known trade-offs.

This chapter’s media

The film explains chapter ideas. The audiobook narrates the complete teaching text.

FormatEnglishहिंदी
Chapter filmWatch1:59Not available
Full audiobookNot availableNot available

A little at a time

Explore an idea, try it, then check what stays.

Step 1 of 8Free · no account needed
Lesson steps

Two curves, two questions

Rather than pick one threshold, plot the model’s behaviour at all of them.

The ROC curve plots true positive rate (recall) against false positive rate. It sweeps from the top-right corner (flag everything, catch everything, alarm on everything) to the bottom-left, where you flag nothing. A diagonal line is a model with no information.

The precision-recall curve plots precision against recall over the same sweep. Its baseline is not a diagonal but a horizontal line at the positive class’s prevalence, which is what a random model achieves.

Python
from sklearn.metrics import roc_auc_score, average_precision_score
roc_auc_score(y_val, p)
average_precision_score(y_val, p)

Your place and first choices stay on this browser. Classroom credit is recorded separately.

Every lesson here is open. Your progress is recorded once you pass the How a Language Model Actually Works exam.

Stuck on something?Ask Funke, your AI tutor

How to cite: Addaly (2026) ‘ROC and precision-recall: every threshold at once’, in Machine Learning, Foundations. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/machine-learning-foundations/roc-and-pr-curves (Accessed: 29 November 2026).