Lawfare Academy

Regression and Business Forecasting · Chapter 5 of 6

Diagnostics, leakage and validation matched to business loss

Return to the linked course unit →

DEVELOPED COURSE TEXT

Diagnostics, leakage and validation matched to business loss

Residuals are an investigation tool

Plot or otherwise inspect residuals against fitted values, predictors, time and relevant groups. Curvature, changing spread, clusters or serial patterns may reveal limitations of the specified model or data process. A residual average of zero does not establish adequacy. Investigate influential records through source verification and sensitivity analysis; do not remove valid inconvenient cases to improve a summary. The diagnostic should connect to the assumption or decision it can inform.

Validation reproduces the information available at the decision

A held-out record is useful only if its features and preprocessing respect the intended deployment process. Using a later-known outcome proxy, or selecting variables using the full dataset before splitting, can leak information. Grouped records may require group-respecting splits; future forecasting requires time-respecting evaluation. Keep final test data separate from repeated model selection when claiming an untouched assessment. Validation is a designed comparison, not merely a random-button setting.

Accuracy metrics encode different costs

Mean absolute error averages absolute deviations; root mean squared error gives larger errors more weight through squaring. Other business losses can be asymmetric or constrained. The best metric depends on the decision, but it should be selected for that purpose rather than after seeing which model wins. Compare against simple relevant baselines and assess important subgroups. One overall average can hide unacceptable performance in a critical deployment region.

Worked records

Record 1

Four held-out fictional outcomes are 10,20,30,40. Model A predicts 8,22,28,42. Model B predicts 10,20,30,46.

Develop the reasoning

A has residual magnitudes 2,2,2,2, so MAE and RMSE both equal 2. B has magnitudes 0,0,0,6: MAE is 6/4=1.5, while RMSE is sqrt(36/4)=3. B wins under MAE, A under RMSE. Neither result is contradictory; the losses weight the errors differently. A business especially exposed to large misses may prefer A under its justified loss, while another may choose differently. The four-point illustration is too small to establish stable future superiority. Also verify that neither model used information unavailable at the time of prediction.

Progressive practice — optional

1. Foundation

Does a lower training error establish better future performance?

Compare the worked reasoning

No. Complexity can fit training variation that does not generalize.

Change the record

A simpler model has worse training loss but lower appropriate held-out loss.

Compare the changed-record reasoning

That is evidence favoring it for the evaluated deployment and loss, subject to uncertainty and the validity of the holdout.

2. Application

A feature records the invoice’s eventual payment date when predicting late payment at invoice issue. What is wrong?

Compare the worked reasoning

The feature is unavailable at the prediction time and leaks future information.

Change the record

The deployment pipeline leaves it blank.

Compare the changed-record reasoning

The apparent validation performance does not represent deployment. Rebuild evaluation using only available features.

3. Transfer

Repeatedly trying models against the same test set produces an excellent result. Is that set still untouched evidence?

Compare the worked reasoning

No. Model selection has used information from it.

Change the record

A genuinely separate later dataset is assessed once.

Compare the changed-record reasoning

That supplies a new evaluation opportunity, provided its population, timing and preprocessing match the intended claim.

Sources and scope