Precision, Recall & Fit Lab
Precision, Recall & Fit Lab
Interactive lab · Judging a model honestly

Is the model good, or just good on paper?

A single accuracy number hides two different questions. When a model flags something, how often is it right? Of everything it should have flagged, how much did it find? And a model that aces its training data may still fail on new data. These three benches let you trade precision against recall, push a model from underfitting to overfitting, and use regularization to pull it back.

Bench 1 · Classification metrics

Precision and recall pull against each other

A classifier scores 160 documents for how likely each is to be responsive to a discovery request. Everything at or above the threshold gets flagged for production. Responsive documents sit above the axis, non-responsive ones below.

Precision = TP / (TP + FP)   Recall = TP / (TP + FN)   F1 = 2PR / (P + R)

Precision asks how much of what you flagged is truly responsive. Recall asks how much of the responsive material you found. Drag the threshold. Lowering it finds more (recall up) but sweeps in more junk (precision down). Only a better model, one that separates the two groups more cleanly, improves both at once.

TP · flagged, responsiveFP · flagged, not responsiveFN · missed responsiveTN · correctly passed over
Drag anywhere on the chart to move the threshold.
Precision
Recall
F1
Accuracy

Actually responsive
Actually not
Flagged
0true positives
0false positives
Passed
0false negatives
0true negatives
Bench 2 · Model capacity

Too simple misses the pattern; too flexible memorizes the noise

The blue points are training data drawn from a smooth curve plus noise. A polynomial of degree d is fit to them by least squares. The coral points are test data from the same process, which the model never sees during fitting.

Underfitting (low degree): the model cannot bend enough, so error is high on both sets. Overfitting (high degree): the curve threads through every training point, training error falls toward zero, and test error climbs. Turn on the purple ghost fits to see the same degree fit to ten other samples of the data: a flexible model changes wildly from sample to sample. That spread is variance; the stiffness of a simple model is bias.

training pointstest pointsmodeltrue curve
Train MSE
Test MSE
Gap
Bench 3 · Regularization

Keep the flexible model, but charge it for big weights

Regularization adds a penalty on the size of the weights to the training loss. The model can still bend, but bending sharply now costs something, so it bends only where the data clearly calls for it. The data here is the same as in Bench 2, fit with a degree-12 polynomial.

L2 (ridge): MSE + λ Σ wj²   L1 (lasso): MSE + λ Σ |wj|

At tiny λ the model overfits. At huge λ every weight is crushed and the model underfits. In between, test error dips to its best. L2 shrinks all coefficients smoothly; L1 pushes many of them to exactly zero, which also selects features. Press Sweep λ to watch the coefficients shrink.

Coefficients w₀ … w₁₂ (Legendre basis, signed, square-root scale)
Penalty
Train MSE
Test MSE
‖w‖₂
Nonzero weights
Field guide

Reading the symptoms

SymptomDiagnosisRemedies
Many false negatives, recall lowThreshold too strict for the taskLower the threshold when misses are costly (screening, review for production); a better model helps both metrics.
Many false positives, precision lowThreshold too looseRaise the threshold when false alarms are costly (spam filtering, alerts).
High training and test errorUnderfitting (high bias)More capacity or better features, less regularization.
Low training error, much higher test errorOverfitting (high variance)More data, regularization (L2, L1, dropout, early stopping), or a simpler model.