Chapter 3 of 6
3
Features that hold
Write feature_spec.json before any fit. Every kept transform must score one new row from inputs known at decision time. Transforms are fitted on train only and applied to later partitions without refitting.
Operating rule
My operating rule: drop anything that fails the clock test, refuse a fit that used validation or test, keep dropped columns with the reason, and never treat high label correlation as permission to keep a leak.
Checked 29 Oct 2026ML pipeline field card
What harms the model
A candidate harms the model when it is unavailable at decision time, was built with the label on the full sample, is an identifier or the label itself, duplicates another column, will not hold at serve time, or is a proxy the decision may not use.
Keep: days past due, open amount, and dispute flag when each is known before the cut. Drop: invoice id; the paid-within-fourteen-days label; any payment after the cut; a full-history target mean that saw holdout mornings; whether a call was placed (operational act after ranking — not a feature, not part of the label).
scikit-learn’s data-leakage note warns that transforms such as StandardScaler, SimpleImputer, and feature selection must be fit on the training subset only — fitting on the whole table leaks test information. A full-sample target mean is the same class of leak. Out-of-fold target encoding on train, with smoothing toward the train base rate, is my allowed form. Validation, test, and live rows use the train mapping only.1
The clock test
High correlation with the label does not, by itself, keep a column. For each candidate: can one new overdue invoice at tomorrow’s cut produce this column from that morning’s extract alone? A transform that still needs the training table to score that row is removed unless a train-only mapping was frozen.
Allowed: raw column, log1p, missing indicator, days_since a source timestamp, ratio of two decision-time columns, categorical consolidation fit on train, out-of-fold target encoding on train only. Pass when every kept feature has fit_on: train and a clock pass. Dropped features stay listed with the reason in feature_spec.json.13
When a draft is cheap
A generated feature list can rank the paid label as the strongest column and still pass a unit test. Features that hold still applies. Importance with the label in view is not a keep.