Chapter 2 of 6
2
Prepare the table
Prepare is the first arc. Profile, quality, and outlier policy leave files Fit can refuse. After every repair, describe the table again — a fill, drop, or clip changes the distribution the next stage will trust.
Operating rule
My operating rule: assign every column a role, score quality before any impute, write an outlier policy instead of a silent delete, and stop when the quarantine rate exceeds quarantine_rate_max for this run.
Checked 29 Oct 2026ML pipeline field card
Profile first
Write profile.json before anything is cleaned. For every column: type, null count, null rate, distinct count, five examples. Numeric columns add min, p01, median, p99, max, mean, standard deviation, and skew. For the label add the positive rate on rows whose fourteen-day window has already closed. For decision time add min and max.
On the call-order path: entity key = invoice id; decision time = this morning’s cut; label = paid within fourteen days of the cut (not whether a call was placed). Candidates include days past due, open amount, dispute flag, and customer segment. Invoice id is id, not a feature. A constant column is drop.
Assign one role per column: id, time, decision_time, label, feature, or drop. Pass only when every column has a role and label and decision time are set. Fail → stop. Do not invent a label.5
Quality before impute
Quality does not impute yet. Completeness marks high-null columns for drop or a later missing indicator (null rate above forty percent in this recipe). Validity quarantines illegal labels and nulls out-of-domain feature cells. Uniqueness keeps the latest row on entity key at decision time. The clock fails when a feature’s event time is at or after the decision time.
Prepare’s maturity job: exclude immature invoices — fourteen-day window still open, or outcome not yet available — from the labeled set Fit will freeze; count them in quality.json. On matured rows only, write label_delay_days as the median cut-to-label delay. That median sizes Fit’s embargo; it does not prove maturity. Fit owns the train / validation / test freeze. A post-cut payment offered as a feature fails the clock. Planned train-only imputation is recorded here and fitted only later on train.
Recompute the profile on kept matured rows. Write quality.json and quarantine.parquet. Pass when label validity is 100% on those rows, the key is unique, no remaining feature uses post-decision values, and quarantine rate ≤ quarantine_rate_max (task.json; this recipe’s default 0.05 is an operating threshold with an owner, not a universal law). Above that → stop.5
Outliers as policy
Extremes are measured after impossibles were quarantined. Per numeric feature I use the modified Z-score with MAD and label |M| > 3.5 as a potential outlier, from the NIST note on Iglewicz and Hoaglin. That note is for labeling, not automatic deletion. If MAD is zero, my operating fallback is Tukey fences (Q1 − 1.5 IQR, Q3 + 1.5 IQR) — not a NIST rule.
Write outlier_policy.json: keep, log1p (skew high and min ≥ 0), cap (bounds learned later on train), or quarantine. Rare categories become OTHER later from train counts only. New quarantine → return through Quality. Cap bounds and OTHER maps are not fitted here.1
When a draft is cheap
A generated cleaning script can drop large open amounts to raise a later metric and still leave no quarantine file, no role list, and no clock test. Prepare still applies. Features cannot be chosen from a morning list nobody can describe.