MODULE 22 Β· Middle+ Β· 3 hours

Half an hour spent reading errors beats a week of tuning

Loss, offline metric, online metric and money are four different things. We stack them into a pyramid and build the ladder of baselines from the bottom up.

Open this module in the simulator All 23 lessons

The first two modules are free, no card. The rest are $20/month.

🏒 The situation

The SuperMegaRetail design doc is approved. Lena:

"Now we fill it with engineering substance. Four sections the book calls the 'early stage': metrics and losses, the dataset, the validation schema, the baselines. Each with a justification of why exactly this way. Remember: a mistake at this stage costs months, because everything downstream is built on these decisions."

🎯 Your task

  1. Build a hierarchy of metrics: from the loss to the business metric.
  2. Design the dataset and answer "how much data is enough".
  3. Choose the validation schema (including the non-trivial ones: nested, adversarial).
  4. Build the baseline ladder and understand why the constant baseline matters.

πŸ“š Theory

The hierarchy of metrics

One metric does not describe a system. In a mature design doc the metrics form a pyramid β€” from what the gradient optimizes to what the CFO sees:

Business metric $ lost on the deliveryβˆ’sales gap, shelf SLA Online metrics (A/B) perishable write-offs, out-of-stock share, store margin Offline model metrics WAPE, bias (over/under-forecast), quantile loss on validation Loss function what the gradient optimizes: quantile/MSE/log loss β€” aligned with the metric above
The metrics pyramid: every level is a proxy for the one above. Breaks between levels (optimizing one thing, reporting another) are the source of "the model got better, the business got worse".

The pyramid's rules:

The dataset: how much data is enough?

The doc's data sections: sources, ETL, filtering, labeling, metadata.

Validation schemas: standard and non-trivial

Schema When
Holdout lots of data, fast iterations
K-fold CV little data, need the estimate's spread
Time-series (rolling) anything with time β€” like our demand forecast
Nested CV tuning hyperparameters and estimating quality honestly at the same time: the inner loop tunes, the outer measures
Adversarial validation a "does train resemble test?" check: train a classifier to tell train from test. AUC β‰ˆ 0.5 β€” same world; AUC β†’ 1 β€” the distributions differ and your validation lies

Adversarial validation is an underrated trick: it also shows which features distinguish train from prod (the classifier's top features) β€” those are the future sources of drift.

The baseline ladder

Constant Rule / seasonal naive Simple model (linear, one boosting) Target system (ensemble, hierarchy, quantiles) Each step must NOTICEABLY beat the previous one β€” otherwise stay on the simple one
The baseline ladder: constant β†’ rule β†’ simple model β†’ target system. The winner is the simplest step nobody managed to significantly beat.

What to remember

  • Metrics are a pyramid: loss β†’ offline β†’ online β†’ business; fix broken links before improving the model.
  • "Is the data enough" is a question for the sample-wise learning curve, not for intuition.
  • Adversarial validation answers whether train resembles test/prod and names the drift sources in advance.
  • The baseline ladder: a 5-minute constant is mandatory; the simplest unbeaten step wins.

Next in this module: Practice

A step-by-step walkthrough of the solution, the code and a five-question quiz.

Open the module β†’

Nearby lessons

21 Advanced Β· Before writing code: the Design Doc 23 Advanced Β· Integration, A/B, monitoring, ownership

The whole program β€” 23 lessons