A credible baseline — proper split, leakage-safe preprocessing, cross-validated metric, dumb-model comparison — used to be an afternoon of boilerplate. With spec-first codegen it is twenty minutes, which changes behavior: you baseline every idea before investing in it.
Tier: Foundation · Workflow area: Modeling
The discipline is writing the spec before the code and running a leakage checklist after, because generated pipelines fail exactly where review is boring.
Skip codegen when your team has a house pipeline template — extend that instead of generating a parallel structure.
Write the spec first, in the prompt. The spec forces the decisions leakage hides in:
Build a baseline sklearn pipeline. Spec:
- Task: binary classification, target = churned_90d (defined at day 90
after snapshot_date; features must use only data available AT snapshot).
- Data: pandas df, 180k rows; numeric: [tenure_days, mrr, tickets_30d],
categorical: [plan, country, channel]; missing values present in mrr.
- Split: time-based — train on snapshots <= 2025-09, test on 2025-10..12.
No shuffled split; explain why in a comment.
- Pipeline: ColumnTransformer (median impute + scale numeric; most_frequent
impute + OneHotEncoder(handle_unknown="ignore") categorical) →
LogisticRegression AND HistGradientBoostingClassifier as two candidates.
- Eval: PR-AUC and ROC-AUC via time-series CV on train; single final test
evaluation. Include DummyClassifier(strategy="prior") as the floor.
- Everything inside Pipeline/ColumnTransformer — nothing fit outside CV.
Review the generated code against the leakage checklist before running:
Pipeline (no fit_transform on the full frame)?GroupKFold if one customer spans rows)?tickets_30d counted before snapshot, not before churn)?Run and demand the floor comparison. A baseline is meaningful only against the dummy: PR-AUC of 0.31 means little until you see the prior is 0.08. If your fancy candidate barely beats dummy, that finding is the deliverable.
Ask for a suspicion report on its own output:
Act as a reviewer of the pipeline you just wrote. List the top 5 ways this
baseline could be overstating performance (leakage, split, metric, target
definition), each with a one-line test to check it.
Run the cheap tests. A classic: shuffle the target and re-run — CV score should collapse to the dummy's; if not, something leaks.
Probe feature legitimacy. Pull feature importances / coefficients and interrogate the top ones: mrr_last_invoice dominating a churn model may mean invoices stop before churn is recorded — a target proxy. Ask the assistant for the "too good to be true" analysis of each top feature given your schema timeline.
Freeze and record. Save the pipeline (joblib), the metric table (dummy vs both candidates, CV mean ± std, final test), seed, and data snapshot hash. This is the number all future work must beat; make it reproducible (see pb-07 for tracking).
The spec-first prompt is the deliverable skill — a precise spec generates a near-correct pipeline, while "build me a churn model" generates a leaky demo.
StandardScaler().fit_transform(X) before the split looks harmless and leaks distribution information into CV.