Repository navigation
Add Pipeline with nested get_params / set_params - #13
Merged
Merged
Conversation
ata-sesli
approved these changes
Oct 31, 2026
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.
Closes #5
Summary
Adds
Pipeline, aBasePreprocessorthat runs blocks in order and feeds each block's output into the next.(name, block)pairs. Unnamed blocks are named after their lowercase class name; repeated class names get-1,-2suffixes.fit_transformruns the chain once and reuses each step's output (instead offit().transform(), which would run every step twice and would be wrong for blocks whosefit_transformdiffers, such as a future cross-fitted target encoder).get_params/set_params(<name>__<param>), step replacement by name,named_steps, andget_feature_names_outchained through every step.Design decisions beyond the issue text:
fit,get_params,set_params,named_steps), not only infit:GridSearchCVcallsget_paramsbefore fitting, and duplicate names would otherwise silently merge two steps' parameters.__init__still does no validation."steps"is reserved as a step name (it would collide with thestepsparameter inget_params).ValueErrorinstead of renumbering, so adding a step never changes another step's address.(name, block), so its name and every<name>__<param>address stay the same. The user's list is never modified.set_paramsvalidates the whole call first, recursively through nested pipelines; an invalid call changes nothing.ValueError.How was it tested
tests/test_pipeline.py: 37 tests with small test blocks defined in the file (one renames columns, to coverget_feature_names_outchaining).ruff format --check .,ruff check .andpytestpass on all three CI configurations: Python 3.10 + scikit-learn 1.7.2 (106 passed), Python 3.13 + scikit-learn 1.9.1 (106 passed), Python 3.10 + scikit-learn 1.3.2 (105 passed, 1 skipped: tags API). Also 106 passed locally on Windows, Python 3.12.Pipeline([("imputer", MissingValueImputer()), FeatureScaler()])insidemake_pipeline(..., SVR())andGridSearchCVoverpipeline__imputer__strategyandpipeline__featurescaler__method.Checklist
ruff format .andruff check .passpytestpassesCONTRIBUTING.mdsklearncross_val_score