Skip to content
ORBIT

Chapter 3 of 6

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

Keepdecision-time inputsDays past due at the cutat the cutCounted from this morning’s extract.Open amount at the cutat the cutBalance as of the cut, not after.Dispute flagif before the cutKeep only when the dispute was logged before the cut.Droplisted in feature_spec.json with the reasonInvoice IDidentifierNames the row; predicts nothing that holds.Paid within fourteen daysthe labelThe outcome itself.Call placedafter rankingA workflow act the score informs. Not the label either.Payments after the cutclock failUnknown when the list is ordered.Full-history target meanleakComputed on rows that include validation and test mornings.BEFORE A KEPT FEATURE SHIPSPasses the clock test for one new invoice.Every transform has fit_on: train.High label correlation is a flag, not a keep.Synthetic call-order illustration. Tags name the reason; the colour only repeats it.
Keepdecision-time inputsDays past due at the cutat the cutCounted from this morning’s extract.Open amount at the cutat the cutBalance as of the cut, not after.Dispute flagif before the cutKeep only when the dispute was logged before thecut.Droplisted with the reasonInvoice IDidentifierNames the row; predicts nothing that holds.Paid within fourteen daysthe labelThe outcome itself.Call placedafter rankingA workflow act the score informs. Not the labeleither.Payments after the cutclock failUnknown when the list is ordered.Full-history target meanleakComputed on rows that include validation and testmornings.BEFORE A KEPT FEATURE SHIPSPasses the clock test.Every transform has fit_on: train.High label correlation is a flag, not a keep.
Figure 1. Keep or drop for the call-order path. Reason stays on the row.

What good looks like

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

1STEP 1 · THE CLOCKCan one new invoice at tomorrow’s cut build it from that morning’s extract alone?no → drop: clock failMORNING EXTRACT · MAY BECOME A FEATUREDays past due, counted at the cutOpen amount at the cutDispute logged before the cutAFTER THE CUT · EXCLUDEDCall placed at 09:30workflow actPayment on day 4futurePaid within fourteen daysthe labeltomorrow’s cut · 07:00timeyes2STEP 2 · THE FITWas every statistic fitted on train rows only?no → drop: leakTRAIN ROWSThe only rowsany statistic maysee.FITImputer median · Scaler · Category mapOut-of-fold target meanFROZENpreprocess.joblibOne mapping, reusedValidationapply, never refitTestapply, never refitLiveapply, never refitNever fitted on these rowsyes3STEP 3 · WRITE IT DOWNKeep it, with the evidence on the row.Keepfit_on: train · clock: pass · reasonfeature_spec.jsonDropStays listed with the reason
1STEP 1 · THE CLOCKCan one new invoice at tomorrow’s cutbuild it from that morning’s extract alone?MORNING EXTRACT · MAY BECOME A FEATUREDays past due, counted at the cutOpen amount at the cutDispute logged before the cuttomorrow’s cut · 07:00AFTER THE CUT · EXCLUDEDCall placed at 09:30workflow actPayment on day 4futurePaid within fourteen daysthe labelno → drop: clock failyes2STEP 2 · THE FITWas every statistic fitted on train rowsonly?TRAIN ROWSThe only rows any statistic may see.FITImputer median · Scaler · Category map ·Out-of-fold target meanFROZENpreprocess.joblibone mapping, reusedValidationapply, never refitTestapply, never refitLiveapply, never refitNever fitted on these rowsno → drop: leakyes3STEP 3 · WRITE IT DOWNKeep it, with the evidence on the row.Keepfeature_spec.jsonfit_on: train · clock: pass · reasonDropstays listed with the reason
Figure 2. The clock test, in order: known at the 07:00 cut, fitted on train only, then kept with its reason.
Morning extractsealed at the cut07:00 · the cutAfter the cutnever read
Figure 3. Only what the 07:00 extract sealed may become a feature. A page dated after the cut is never read.

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.

References

  1. scikit-learn, data leakage
  2. Prepare the table
  3. ML pipeline agent recipe