Validate and communicateLesson 56 of 76 · 8 min

Compare predictions with observations

Use held-out evidence to challenge a model’s predictive behaviour.

Validation asks whether a model is adequate for its intended use. It can involve comparing predictions with observations that were not used to choose or fit the model. A model can pass arithmetic checks while failing this empirical comparison.

This illustration supplies an invented held-out demand record and compares it with an assumed Poisson prediction. Compare how often the simulated and invented observations are at or below the model’s nominal 90th percentile. With a small validation set the count is itself variable, and repeated time observations may be dependent. Nominal means the stated model level. For integer counts the P90 cutoff can cover more than 90%, so fewer than 10% may lie strictly above it even in a correct model.

A discrepancy can reveal a poor model, changed conditions, a measurement problem or a mismatched validation population. It should lead to investigation. Do not delete inconvenient validation observations or retune on them while continuing to call them an untouched test set.

Hold evidence outside the fit
  1. Specify the input model
    D∼Poisson⁡(20)D\sim\operatorname{Poisson}(20)
  2. Predict a threshold
    q0.9q_{0.9}
  3. Compare held-out observations
    mean⁡(dholdout≤q0.9)\operatorname{mean}(d_{\rm holdout}\le q_{0.9})
Reference illustration. A precise simulation of a fitted or assumed model is a different check from prediction on held-out observations. The small invented holdout has its own sampling variability.

Does a prediction covering about 90% in its own simulated data guarantee 90% coverage on new observations?

Write a prediction (optional)

Seeded teaching simulation

Select Run Python below with the code unchanged.

Tools
About Python ↗

The code is editable. Press Ctrl+Enter or ⌘+Enter to run Python from the editor.

Published example output

This result comes from the original Python. Your runs appear above. Build environment ↗

Model nominal P90 count: 26.0
Model fraction <= threshold: 0.9231
Held-out observed fraction <= threshold: 0.5833
Holdout observations: 12

Read the first result

Discrete quantiles can have coverage above the nominal level. The held-out sample is tiny and deliberately illustrative.

Try an edit

Replace assumed_mean = 20 with assumed_mean = 26. Select Run Python again. Compare Model nominal P90 count and both coverage fractions. These rows can guide another model. If you use them to choose the mean, those rows no longer provide an independent check. What fresh observations would you hold out?

Back to the Python editor

Scope. The holdout record is invented and too short for a strong calibration claim. Its purpose is to show the validation distinction.

Try a fresh case

After repeatedly tuning a model to one validation set, what is needed for a fresh assessment?

Choose an answer
Need a hint?
Hint 1

Ask whether the observations influenced the final model.

Hint 2

Separate model revision from evaluation of the revised model.

Your notes