Repository navigation
feat: preprocessor registry and estimator→preprocessor mapping - #70
Merged
Merged
Conversation
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%.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.preprocessorbecomes a property aliasingself.preprocessors["default"](with a setter), soreassign_types,add_preprocessing_step, and external code keep working._make_pipelineis the single consumption point: it resolvesprep_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.preprocessor_mapconstructor param (PoniardClassifier/PoniardRegressor).add_preprocessor(name, template)registers a cloned template.set_preprocessor(estimator, preprocessor)validates both names and rebuilds that estimator's pipeline.add_preprocessing_stepgains apreprocessorselector ("all"preserves the legacy global behavior); unknown names raiseKeyError.setup→fit,reassign_types).setupinfo 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_typespreservation, save/load round-trip, and tuning withpreprocessor__...keys on a mapped pipeline.All 263 tests pass; coverage 89.3% (gate 85%); ruff + format clean.