Measuring model performance

This project documents how to measure the performance of predictive models, working through every method on real models fitted to real data. Each page answers one question about a model, shows the method on our examples, and explains when it misleads.

The examples

Most pages use the French motor insurance dataset (freMTPL2, about 680,000 policies) with two targets:

Target Type Question
HasClaim binary (0/1) Will this policy have a claim?
PurePremium continuous, weighted by exposure What claim cost per year should we expect?

For each target we compare a GLM (the traditional baseline) with a gradient boosting machine (GBM), plus a Null model that predicts the average for everyone. A few pages also use California Housing, a continuous target with a strong signal, where standard error metrics behave as textbooks describe. See Data and models.

How the pages are organized

Metrics are grouped by the question they answer rather than listed by name:

Working with the code

All metric and plotting code lives in the modelperf package (src/modelperf/) and is tested against scikit-learn. Pages only call it, so explanations and implementations stay in sync.

uv sync                  # install the environment
uv run pytest            # check the metrics
uv run quarto preview    # build and serve the site locally

The first page you render downloads the data and fits all models (about a minute); fitted models are cached in artifacts/.