Skip to content

xpd modeling

Use xpd modeling to review model family choices, grouped or hierarchical predictors, validation splitters, CV hyperparameter optimization, asymmetric scoring, baseline comparisons, calibration, MAPIE conformal or quantile-forest uncertainty, and post-fit explanations (shap, fippy, effector) in Python. The list inventories named estimators, evaluation reports, and CV wrappers across scikit-learn, glum, quantile_forest, skore, scikit-lego, MAPIE, LightGBM, XGBoost, optuna_integration, skrub, Nixtla (MLForecast, StatsForecast), statsmodels, and linearmodels. It forwards selected pack reports (including glum, quantile_forest, skore, shap, fippy, effector, optuna, optuna_integration, sklego, skfolio, mlforecast, utilsforecast, mapie, sklearn, lightgbm, and xgboost) and adds local advisories about scaling, split conflicts, baseline comparisons, and quantile scoring.

Terminal window
xpd modeling [OPTIONS] [PATHS]...
xpd modeling <COMMAND>
Subcommand What it does
xpd modeling start Start a run: record the commit it starts from, the paths, line count, checks and optional benchmark of the project
xpd modeling plan Record the plan of a round: the fixes in order, and the findings that are right as they are
xpd modeling approve Record that the user said yes to a fix that changes what callers or users see
xpd modeling gate Gate a fix that is committed: run the checks, time --bench when set, count lines and compare the findings with the commit before it. Exit 1 when the fix is not kept
xpd modeling drop Record that a fix was given up, after its files were restored
xpd modeling status Print the run and the stage that comes next
xpd modeling finish End the run: compare findings, line count and benchmark timing with the start commit. Exit 1 while a fix is open or a new finding has no reason
Argument What it does
<PATHS>... Files or directories (directories respect .gitignore)
Option Default What it does
--kind <KIND> List only the findings of these kinds, separated by commas. Repeatable. Values: unscaled-model, grouped-predictor, cv-optimization, model-configuration, split-mismatch, test-set-tuning, baseline-not-observed, metric-loss-mismatch, conformal-leakage, validation-leakage, metric-response, validation-reproducibility, conformal-configuration, boosting-validation, model-explanation.
--limit <LIMIT> 20 The most findings to list of each kind, strongest first. 0 lists every finding.
--since <COMMIT> Count the findings at this commit too, and print each count beside the count of today.
--group-by <GROUP_BY> none Group findings and checklist items by owning module or shared cause. Values: none (Keep the default flat per-kind listing), module (Group findings and checklist items by owning module path), cause (Group related findings by shared kind and anchor files).
--packet <N> Emit one 1-indexed deterministic context-budgeted review packet for the Nth cluster.
--budget-lines <LINES> 300 Maximum source lines included across excerpts inside a --packet view.
--all-modules Include checklist review items for every surveyed module, not only modules with findings.
--format <FORMAT> Output format. Default: text on a terminal, json otherwise. Values: text, json.
--adapter <ADAPTER> Project Python adapter or shell command that emits model facts.
--questions Print the evidence catalog without surveying files.
Terminal window
$ xpd modeling --questions --format json | jq -c '[.questions[].id]'
["model-family","grouped-predictors","validation-scheme","cv-optimization","baseline-comparison","metric-and-loss","feature-exclusions","probability-calibration","uncertainty-and-conformal","first-failure","model-explanation","pipeline-evidence"]

The catalog includes measured facts, checklist questions, and MCP gate names. Listing the catalog runs no project code.

Run xpd modeling <paths> --limit 0 --format json to list findings, inventory, and checklist. Add --adapter adapter.py for runtime measurements. Repeat the recorded paths and adapter when listing during a run. read.models identifies each model by file and qualified binding. The stable model ID prefixes its checklist IDs. Resolved findings include a model ID. With no adapter, read.facts is null. Adapter errors appear under read.facts.error and leave the static list available. Recorded stages require valid measurements when an adapter is configured and enforce checklist evidence rules on plan, gate, and finish.

A Python adapter defines models() and returns an iterable of mappings.

Field Meaning
file, binding A selected Git-root-relative Python file and a qualified binding such as train.model. Give factories and adapter-only models distinct bindings.
X, y, estimator Row-aligned development data and an unfitted estimator. Exclude any final test set.
scorer, splitter A scikit-learn scorer name, callable (estimator, X, y) -> float (such as make_scorer(..., greater_is_better=False)), or (name, callable), plus the splitter name used to materialize folds. Higher is always better.
secondary_scorers Optional mapping of additional scorer names or callables evaluated on the exact same validation rows per fold.
folds Mappings with a unique string id, integer positional fit and validation indices, and optional early_stopping and calibration indices. Roles must be disjoint within each fold.
baseline Optional unfitted estimator. Defaults to a prior classifier or mean regressor. Both estimators use the exact same fit and validation rows.
candidates Optional mapping {name: unfitted_estimator} (or (estimator, fit_fold)) fitted and scored on the exact same folds and primary scorer to compare model families and grouped/hierarchical predictors directly.
groups, times Optional row-aligned group IDs and UTC timestamps. The report shows group intersections, time boundaries, purge/embargo gaps, conflicts, and per-group validation scores (group_performance).
positive_label Required to measure binary Brier loss, log-loss, ECE, and five reliability bins. Multiclass classifiers compute top-label reliability bins, multiclass Brier, log-loss, and ECE automatically.
fit_fold Optional callback taking (cloned_estimator, X_fit, y_fit, X_stop, y_stop) and returning the fitted estimator.
conformalize Optional split-conformal callback (fitted, X_cal, y_cal) requiring a nonempty calibration partition. Return an object with predict_interval, predict_set, or predict.
conformalize_fit Optional cross-conformal / jackknife+ / EnbPI / ACI callback (X_fit, y_fit) that requires no separate calibration partition. Return an object with predict_interval, predict_set, or predict.
confidence_levels Distinct confidence levels in (0, 1), required whenever conformalize or conformalize_fit is provided.

A shell adapter prints one JSON document with the same models array as the Python runner. Every measured model includes file, binding, scorer, splitter, baseline, estimator_profile, folds (with partitions.purge_gap, residuals, group_performance, and optional secondary_scores / candidates), spread, probability_calibration (Brier, log-loss, ECE, bins), interval_coverage (pooled and per-fold coverage, width/set size, Winkler/MWI score, SSC, singleton/empty set rates), and optional candidate_summary. Unavailable measurements include a reason.

Recorded Python adapters must be committed in the repository. Recorded adapters run from the root of the selected commit on both sides of a comparison. Project Python logs go to stderr.

Command Result
xpd modeling start Record the clean tracked baseline, paths, checks and optional adapter.
xpd modeling <paths> List current models, findings, facts and questions.
xpd modeling plan Record fixes, acceptance reasons and validated checklist verdicts.
xpd modeling gate Evaluate one committed fix against the last kept commit and invalidate stale answers.
xpd modeling finish Compare with the starting commit and close the run.
xpd modeling status Show the run and next stage.
xpd modeling approve Approve a fix that changes an interface.
xpd modeling drop Record why a fix was abandoned.

A quantile model predicts at 0.9. The score mistakenly uses a pinball loss at 0.1.

bad.py
from sklearn.ensemble import GradientBoostingRegressor
from sklearn.metrics import mean_pinball_loss
def score_quantile(x_fit, y_fit, x_validation, y_validation):
model = GradientBoostingRegressor(loss="quantile", alpha=0.9, random_state=7)
model.fit(x_fit, y_fit)
return mean_pinball_loss(y_validation, model.predict(x_validation), alpha=0.1)

The example initializes a scratch Git repository. It prints the next stage or fix outcome after each successful command and the refusal message when a fix or an answer is open.

Terminal window
$ git init -q && git -c user.name=Example -c user.email=example@example.com add bad.py && git -c user.name=Example -c user.email=example@example.com commit -qm initial
$ xpd modeling start bad.py --check "git diff --check" --format json | jq -r .next.stage
plan
$ xpd modeling bad.py --limit 0 --format json | jq -c '[.findings[].kind]'
["metric-loss-mismatch"]
$ xpd modeling bad.py --limit 0 --format json | jq '{fixes:[{id:"pinball",title:"Score the intended quantile",findings:[.findings[] | select(.kind == "metric-loss-mismatch") | .id]}]}' > plan.json
$ xpd modeling plan plan.json --format json | jq -r .next.stage
fix
$ xpd modeling finish --format json 2>&1 >/dev/null
xpd: the fix pinball is still open
$ python -c 'from pathlib import Path; p = Path("bad.py"); p.write_text(p.read_text().replace("alpha=0.1", "alpha=0.9"))' && git -c user.name=Example -c user.email=example@example.com commit -qam 'Score the intended quantile'
$ xpd modeling gate pinball --format json | jq -r '.run.rounds[-1][0].outcome'
kept
$ xpd modeling finish --format json 2>&1 >/dev/null | cut -d: -f1-2
xpd: these checklist items are unanswered
$ xpd modeling bad.py --format json | jq '{answered:[.checklist[] | {item:.id,verdict:"accepted",reason:"Scratch example with no deployment; validation design remains unverified."}]}' | xpd modeling plan - --format json | jq -r .next.stage
plan
$ xpd modeling finish --format json 2>/dev/null | jq -r .next.stage
finished

See the model review guide for the review sequence.

Status Meaning
0 A successful stage or list. JSON stage output contains run and next.
1 A rejected gate, open fix, unanswered question or unexplained new finding.
2 An invocation or adapter error.