Skip to content

Chapter 1.3 — Practical statistics for ML

🎯 Objective

Cover the operational statistical minimum: bias, variance, overfitting/underfitting, calibration, ECE, confidence intervals and significance.

🧠 Core concepts

  • Bias — systematic error from excessive simplification. Leads to underfitting.
  • Variance — excessive sensitivity to the dataset. Leads to overfitting.
  • Underfitting — high error on training and test. The model does not capture the pattern.
  • Overfitting — low training error, high test error. The model memorizes noise.
  • Calibration — correspondence between predicted probability and observed real frequency.
  • ECE (Expected Calibration Error) — weighted average difference between confidence and accuracy across bins.
  • Confidence interval — uncertainty range for a metric.
  • Statistical significance — incompatibility of the data with a null hypothesis under a study design and its assumptions. It does not measure the probability that the hypothesis is true, effect size, or practical usefulness.

📏 Classification metrics

Metric Formula When to use
Accuracy (TP+TN)/total Balanced classes
Precision TP/(TP+FP) High false-positive cost
Recall TP/(TP+FN) High false-negative cost
F1 2·P·R/(P+R) Imbalanced classes
ROC-AUC Area under ROC Threshold-independent comparison
PR-AUC Area under PR Heavily imbalanced classes
Brier score Squared probability error Calibration
Log loss -log(p truth) Calibration and ranking
ECE Confidence vs accuracy difference Calibration

📐 Regression metrics

Metric When to use
MAE Robust to outliers
RMSE Penalizes outliers
MAPE Percentage error
R² Explained variance
Quantile loss Quantile prediction

📊 Ranking and recommendation metrics

Metric When to use
NDCG@k Ranking with ordinal relevance
MAP@k Multiple relevant items
MRR Position of the first relevant item
Hit rate@k Basic coverage
Coverage Diversity of recommended items
Diversity / serendipity Non-trivial recommendation

🚨 Failure modes

  • High accuracy with a rare class ignored.
  • The default threshold (0.5) treated as sacred.
  • A miscalibrated model used in a financial decision.
  • A statistical difference not tested before declaring "a better model".

🛡️ Mitigations

  • Evaluate with multiple metrics.
  • Report confidence intervals via bootstrap.
  • Apply isotonic calibration or Platt scaling when needed.
  • Compare the same units using paired tests or intervals when the design allows; McNemar applies to paired binary outcomes under its assumptions.
  • Define the minimum useful effect, sampling unit, and analysis before inspecting results. Lack of significance does not establish equivalence or absence of an effect; equivalence and non-inferiority require explicit margins and designs.
  • For agents, distinguish variation across tasks from variation across runs. Resample tasks (or families/repositories when dependent), preserving pairing; repeated runs do not create new independent tasks.
  • Report effect size, interval, unit count, execution budget, and generalization limits.

Primary source: ASA statement on p-values, accessed 2026-10-24.

📏 Comparing systems: unit, pairing, interval and relevance

"Model B scored 4 points above A" is the most common and most fragile sentence in an evaluation report. The mitigation bullets above summarize the stance; this section details the four questions that need an answer before accepting the sentence.

  1. What is the independent unit? In an eval with 100 questions and 3 repetitions there are 100 units, not 300. In tasks derived from 10 families, there may be only 10. Intervals computed on the wrong unit look narrow and are not: in published examples, standard errors clustered by family reached 3× the naive ones.
  2. Is the comparison paired? Did A and B run on the same items? If so, compute the per-item difference and the interval of that difference (paired bootstrap resampling items, or McNemar for binary outcomes). Pairing removes between-item variance at no extra collection cost.
  3. What was the minimum relevant effect, declared before looking at the result? A 95% interval of [−1, +9] points authorizes neither "B is better" nor "they are equal". It only authorizes "we did not measure enough for the decision we want to make".
  4. How many comparisons were made? Ten prompt variants against the same holdout easily produce a "winner" by chance. Reserve a holdout never used for iteration (Ch. 2.11) and declare which comparison is primary.

Minimum protocol to compare two configurations (50–200 items):

  • Same items, randomized execution order, same budgets, same task version.
  • Repetitions per item when the output is stochastic; the per-item mean is the observation. Do not lower the temperature to "reduce variance": that biases the estimate of real-use performance.
  • Paired mean difference with a 95% interval. Below a few hundred items, normal-approximation (CLT) intervals understate uncertainty; prefer Wilson or a paired Bayesian interval, and treat the bootstrap with caution in that regime.
  • Report: n of units (and of clusters), effect, interval, pre-declared minimum effect, cost per success and what was not covered. With 100 items, differences of 2–5 points are not detectable; say so or increase n (on the order of a thousand items to detect 3 points).

For agents, the unit, flakiness and budget change the reading (see Ch. 5.7).

📚 References