Machine Learning, FoundationsLesson 48 of 92

Module 5 · Measuring a model honestly

Is that improvement real?

In this lesson

  • 9 min read
  • 6 reading sections
  • Knowledge check
  • Lesson 7 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

The situation

Model A scores 0.847. Model B scores 0.852. Do you ship B?

The wrong answer is “yes, it is higher”. Both numbers were measured on a finite sample, both carry uncertainty, and 0.005 may be well inside it.

The bootstrap, which is all you need

Resample your evaluation set with replacement, recompute the metric, repeat a thousand times. The spread of those thousand values is the sampling distribution of your score.

Python
import numpy as np
rng = np.random.default_rng(0)
n = len(y_test)
diffs = []
for _ in range(2000):
    idx = rng.integers(0, n, n)
    diffs.append(roc_auc_score(y_test[idx], pB[idx])
                 - roc_auc_score(y_test[idx], pA[idx]))
lo, hi = np.percentile(diffs, [2.5, 97.5])
print(f"difference {np.mean(diffs):.4f}  95% CI [{lo:.4f}, {hi:.4f}]")

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) ‘Is that improvement real?’, in Machine Learning, Foundations. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/machine-learning-foundations/comparing-two-models (Accessed: 29 November 2026).