H2ML¶
A 4-step AutoML pipeline for tabular data that wraps sklearn-compatible estimators. Given a feature matrix and target, it screens all registered models, reduces features via SHAP importance and correlation filtering, and tunes the winner with Optuna — all in one call.
from h2ml import H2MLPipeline, PipelineConfig, PipelineData
store = PipelineData.from_frame(X, y=y_arr)
pipeline = H2MLPipeline(config=PipelineConfig(task_type="classification", metric="AUC"))
result = pipeline.run(store)
print(result.summary())
final = result.build_final_model() # refit on the full training set
How it works¶
| Step | What happens |
|---|---|
| 1 | K-fold CV all models (× optional y-transforms) on all features |
| 2 | SHAP importance → correlation-based feature drop (optional VIF filter) |
| 3 | K-fold CV all models on reduced features (winning transform only); compare vs step 1 |
| 4 | Optuna HPO on the winning (model, stage, transform); skipped if the winner has no enabled search space |
The pipeline can also be run partially: run_step1_only() screens models, and run_from_step3() / run_step4_only() resume from a previous result. With holdout_frac > 0, rows are set aside before step 1 and the final configuration is scored once on them.
Features¶
Core pipeline¶
- Model screening — a curated set of sklearn classifiers and regressors in one parallel CV pass
- Optional boosting — LightGBM, XGBoost, CatBoost registered when installed
- Custom models — your own estimators, a subset of the registry, or different search spaces
- SHAP feature selection — out-of-fold SHAP avoids leaking importance scores
- Cross-validation — stratified k-fold for classification and k-fold for regression, or spatial block and AHC-based splitters when
store.coordsis set - y-transform sweep — log, sqrt, and winsorized variants evaluated jointly
- Persistence — Parquet + npy + joblib; reload a run and resume from step 3 or 4
Trustworthy selection¶
- Ranking robustness — paired-fold ties and per-metric ranks, with an optional 1-SE rule favouring reduced features
- Per-fold feature selection — an unbiased default-vs-reduced comparison
- Outer holdout — one score no selection step has seen
- Nested CV — how well the whole pipeline generalises
- Seed stability — how much a run depends on its seed
- Metric comparison — compare selection metrics while sharing CV work
Before and after the pipeline¶
- EDA — dataset profiling and pipeline readiness checks
- Conformal prediction — distribution-free intervals and prediction sets, calibrated on OOF or holdout predictions, with optional spatio-temporal local widths
- Area of applicability — flags predictions outside the feature space the model was trained on
- Delta model — P(present) × E(count | present) for presence/abundance data
- Geo prediction — mapped predictions over gridded data through
h2mare