Skip to content

feat: native preprocessing profile for HistGradientBoosting - #71

Merged
rxavier merged 1 commit into
mainfrom
feat/native-preprocessor-profile
Aug 3, 2026
Merged

rxavier merged 1 commit into
mainfrom
feat/native-preprocessor-profile

Conversation

@rxavier

@rxavier rxavier commented Aug 3, 2026

Copy link
Copy Markdown
Owner

Summary

Part 2, step 3 of the ML defaults improvements plan (docs/ml-defaults-improvements.md): the "native" profile + HGB wiring.

PoniardPreprocessor

  • New profile parameter ("default" | "native").
  • Native profile: numeric + datetime pass through untouched (NaN preserved), categoricals (low and high cardinality) ordinal-encoded to pandas category dtype via a small _ToCategorical transformer. No imputation, no scaling, no VarianceThreshold.
  • NaN semantics verified (the plan's open question): HistGradientBoosting with categorical_features="from_dtype" treats NaN in categorical columns as missing and handles them natively.

Estimator wiring

  • preprocessor_map can reference "native"; the profile is built with the shared feature_types (inference runs exactly once; reassign_types propagates to every PoniardPreprocessor-backed profile).
  • set_preprocessor(est, "native") builds the profile on demand after setup.
  • _make_pipeline (single consumption point) couples "native" to HistGradientBoosting* estimators only — mapping it to anything else raises ValueError — and auto-sets categorical_features="from_dtype" on the cloned estimator (documented side effect).
  • Guide documents the profile and the side effect.

Tests (12 new/updated)

Mapped + on-demand native, non-HGB rejection (both API paths), NaN-categorical E2E, reassign_types shared inference, step targeting on native, save/load round-trip, tuning with preprocessor__... keys, and the native PoniardPreprocessor profile directly.

All 272 tests pass; coverage 89.7% (gate 85%); ruff + format clean.

Implements the ML defaults improvements Part 2, step 3.

PoniardPreprocessor gains a profile parameter (default | native):
- native leaves numeric and datetime features untouched (NaN passthrough)
  and ordinal-encodes categoricals to pandas category dtype via a small
  _ToCategorical transformer, preserving NaN as missing
- native skips imputation, scaling and VarianceThreshold
- verified NaN semantics: HistGradientBoosting with
  categorical_features="from_dtype" treats NaN in categorical columns as
  missing and splits on them natively

Estimator wiring:
- preprocessor_map can reference "native"; the profile is built with the
  shared feature_types (inference runs once, reassign_types propagates to
  every PoniardPreprocessor profile)
- set_preprocessor(est, "native") builds the profile on demand after setup
- _make_pipeline couples "native" to HistGradientBoosting estimators only
  (ValueError otherwise) and auto-sets categorical_features="from_dtype"
- guide documents the profile and the side effect

Tests: mapped/on-demand native, non-HGB rejection, NaN-categorical E2E,
reassign_types shared inference, step targeting, save/load round-trip,
tuning, and the PoniardPreprocessor native profile. All 272 tests pass.
@rxavier
rxavier merged commit a52c46f into main Aug 3, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant