Prepare features and targets
Run xpd data-prep <paths> to check Python data preparation code across pandas, Polars, NumPy, scikit-learn, skrub (Cleaner, TableReport, fuzzy_join, Joiner, AggJoiner, InterpolationJoiner, DataOp, to_datetime, SquashingScaler), and feature_engine (imputation, outliers, preprocessing) from raw ingestion through joins, imputation, train-test splits, and feature or target scaling. Add --adapter to profile the real columns and record every scaling and cleaning decision in a gated ledger.
What xpd data-prep checks
Section titled “What xpd data-prep checks”| Group | Example finding kinds |
|---|---|
| Leakage | fit-before-split, fit-on-test, cross-val-on-fitted-data, scaler-fit-before-split, prefit-before-cross-validation |
| Joins and alignment | merge-without-validate, polars-join-without-validate, merge-asof-unsorted, concat-columns-unchecked, join-key-unvalidated, joiner-conflicting-keys |
| Target transforms | transformed-target-pair, scaled-target-without-inverse |
| Dtypes and missing values | compare-to-missing, polars-null-comparison, nan-to-int, silent-dtype-coercion, arbitrary-outlier-capper-empty, quantiles-capping-invalid-fold |
| Pipeline shape | stateful-function-transformer, unfitted-keep-subsampling, read-parquet-all-columns, frame-column-write, no-inplace |
Write a column adapter
Section titled “Write a column adapter”Commit a preparation script, a reproducible check command, and a small adapter file that returns the data the script reads. Declare target and model_family when you want scaling guidance tailored to the model family.
from pathlib import Path
model_family = "linear"target = "sale_price"
def columns(): return Path(__file__).with_name("sales.csv")Run a recorded review
Section titled “Run a recorded review”- Start the run from a clean commit with
xpd data-prep start prep.py --check "python prep.py" --adapter columns.py. - Inspect findings and column questions with
xpd data-prep prep.py --adapter columns.py --format json. - Review the pipeline graph and measured columns. Confirm what sentinels, nulls, outliers, and duplicate rows mean before transforming them, and choose a time or group split when rows depend on each other.
- Record ordered fixes, accepted exceptions, and column answers with
xpd data-prep plan plan.json. Each checklist answer pairs anitemsuch asamount/outlier-meaningwith averdict(pass,na, oraccepted) and areason. Fixes addressing judgment items set"goal": "design"and cite their item IDs inquestions. - Run
xpd data-prep approve <fix-id>after approving an interface change, commit one fix, and verify it withxpd data-prep gate <fix-id>. Restore an abandoned edit before runningxpd data-prep drop <fix-id> --reason "<why>". - Resume across sessions with
xpd data-prep status, and close the run withxpd data-prep finishonce every fix, new finding, and checklist item is settled.
Scaling guidance
Section titled “Scaling guidance”Fit every scaler and imputer on training rows or inside a scikit-learn Pipeline.
| Measured distribution | Suggested transform |
|---|---|
| Heavy tails or high outlier share | RobustScaler or skrub.SquashingScaler (or feature_engine.outliers.Winsorizer for errors) |
| Right-skewed nonnegative target | TransformedTargetRegressor with log1p/expm1 or PowerTransformer(method="box-cox") |
| Right-skewed target with negative values | TransformedTargetRegressor(transformer=PowerTransformer(method="yeo-johnson")) |
| High-cardinality or dirty text / rare categories | skrub.TableVectorizer or feature_engine.encoding.RareLabelEncoder |
| Roughly symmetric numeric feature | StandardScaler |
Pure tree pipeline (model_family = "tree") |
No scaling required |
See the command reference for all adapter inputs, flags, and stage commands.