Skip to content

feat: preprocessor registry and estimator→preprocessor mapping - #70

Merged
rxavier merged 1 commit into
mainfrom
feat/preprocessor-registry-mapping
Aug 3, 2026
Merged

rxavier merged 1 commit into
mainfrom
feat/preprocessor-registry-mapping

Conversation

@rxavier

@rxavier rxavier commented Aug 3, 2026

Copy link
Copy Markdown
Owner

Summary

Part 2, step 2 of the ML defaults improvements plan (docs/ml-defaults-improvements.md): the registry + mapping with "default" only — a mechanical refactor with byte-identical default behavior.

Changes

  • self.preprocessor becomes a property aliasing self.preprocessors["default"] (with a setter), so reassign_types, add_preprocessing_step, and external code keep working.
  • _make_pipeline is the single consumption point: it resolves prep_name = self.preprocessor_map.get(name, "default") and wraps that template. The pipeline step name stays "preprocessor", so tuning grid keys, get_estimator, and save/load are unaffected.
  • New API:
    • preprocessor_map constructor param (PoniardClassifier / PoniardRegressor).
    • add_preprocessor(name, template) registers a cloned template.
    • set_preprocessor(estimator, preprocessor) validates both names and rebuilds that estimator's pipeline.
    • Map values may be registered names or Pipeline/Transformer instances (auto-registered under a generated name).
  • add_preprocessing_step gains a preprocessor selector ("all" preserves the legacy global behavior); unknown names raise KeyError.
  • User-registered templates persist across re-configuration (setup → fit, reassign_types).
  • setup info lists non-default mappings when any exist.

Tests

New tests/test_preprocessor_map.py (11 tests): registry/mapping, mapped vs unmapped pipelines, validation errors, auto-registration, step targeting, reassign_types preservation, save/load round-trip, and tuning with preprocessor__... keys on a mapped pipeline.

All 263 tests pass; coverage 89.3% (gate 85%); ruff + format clean.

Mechanical refactor of the ML defaults improvements Part 2, step 2: the
single shared preprocessor becomes a registry of named templates plus an
estimator→preprocessor mapping, with byte-identical default behavior.

- self.preprocessor becomes a property aliasing preprocessors['default']
  (with a setter), so reassign_types, add_preprocessing_step and external
  code keep working
- _make_pipeline is the single consumption point: it resolves
  prep_name = preprocessor_map.get(name, 'default') and wraps that template;
  the pipeline step name stays 'preprocessor' so tuning grid keys,
  get_estimator and save/load are unaffected
- New API: preprocessor_map constructor param, add_preprocessor(name, tpl),
  set_preprocessor(estimator, prep) with validation; map values may be
  registered names or Pipeline/Transformer instances (auto-registered)
- add_preprocessing_step gains a preprocessor selector ('all' preserves the
  legacy global behavior); unknown names raise KeyError
- User-registered templates persist across re-configuration (setup→fit,
  reassign_types); setup info lists non-default mappings when any exist

Tests: registry/mapping, validation, auto-registration, step targeting,
reassign_types preservation, save/load round-trip, tuning on a mapped pipeline.
All 263 tests pass; coverage 89.3%.
@rxavier
rxavier merged commit ca6b7d7 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