All labs

Where Leakage Hides

Impute before splitting, select features on all the data, or split a time series at random — and watch validation lie.

Ch 5 5.8
Misconception
Supervised Learning
22 mindifficulty 4/5

Controls

Dataset

60
3

More repeats per subject means more to leak if folds ignore grouping.

40
0

0 = no real relationship exists at all; the honest score should sit at chance.

0.900

Per-subject random offset shared by all of that subject's rows.

0.500

Per-block random offset shared by all rows collected in that block.

4

Pipeline / leakage toggles

Select features on all data

On = leaky: features are screened using rows that include the test fold.

Standardize on all data

On = leaky: mean/sd for scaling come from rows including the test fold.

Grouped CV (by subject)

On = honest: a subject's repeated rows all stay in one fold. Ignored when forward-chaining is on.

Forward-chaining split

On = honest: train only on the past, test only on the future block.

Estimation

8
5
60
Random seed

Every result on this page is a deterministic function of the seed and the controls.

Reported CV vs. honest held-out score

Reported = k-fold CV on the training pool, with whatever leakage the toggles allow. Honest = the same fitted pipeline scored on freshly simulated, unrelated subjects.

Reported accuracy
58.3%
Honest accuracy
48.3%
Reported AUC
0.663
Honest AUC
0.452
00.200.400.600.80101234[0.30, 1.30) n=58.3[1.70, 2.70) n=48.3chanceaccuracy
left bar: reported (CV)right bar: honest (fresh data)

Optimism climbs with the number of noise features

Averaged over 6 quick simulations per point, current toggles held fixed. Watch what happens when selection or scaling happens before the split.

00.200.400.600.801050100150200250300chancenumber of noise features (p)accuracy
reported (CV)honest (fresh data)

Distribution of the gap across repeated simulations

Reported − honest accuracy, over 60 independent simulations from fresh seeds.

Mean reported
67.5%
Mean honest
49.9%
Mean gap
17.6%
024681012-0.0500.050.100.150.200.250.30[-0.05, -0.03) n=0[-0.03, -0.01) n=0[-0.01, 0.01) n=0[0.01, 0.02) n=0[0.02, 0.04) n=0[0.04, 0.06) n=0[0.06, 0.08) n=1[0.08, 0.10) n=3[0.10, 0.12) n=2[0.12, 0.14) n=9[0.14, 0.15) n=5[0.15, 0.17) n=13[0.17, 0.19) n=2[0.19, 0.21) n=9[0.21, 0.23) n=7[0.23, 0.25) n=5[0.25, 0.27) n=1[0.27, 0.29) n=0[0.29, 0.30) n=2[0.30, 0.32) n=1reported − honest accuracydensity