FIX handle empty steps in Pipeline#30203
Merged
glemaitre merged 19 commits intoscikit-learn:mainfrom Nov 8, 2024
Merged
Conversation
adrinjalali
reviewed
Nov 5, 2024
Member
adrinjalali
left a comment
There was a problem hiding this comment.
we should also add a test to make sure repr and html repr of the empty pipeline don't raise.
Co-authored-by: Adrin Jalali <adrin.jalali@gmail.com>
…replace direct _estimator_type checks with is_classifier() and is_regressor() assertions.
adrinjalali
reviewed
Nov 6, 2024
Co-authored-by: Adrin Jalali <adrin.jalali@gmail.com>
Co-authored-by: Adrin Jalali <adrin.jalali@gmail.com>
Contributor
Author
|
Hey @adrinjalali, the PR is completed on my end. Please let me know if any further reviews are needed. Thank you! |
adrinjalali
approved these changes
Nov 7, 2024
Member
adrinjalali
left a comment
There was a problem hiding this comment.
LGTM. cc @glemaitre for the second review.
glemaitre
reviewed
Nov 7, 2024
Member
glemaitre
left a comment
There was a problem hiding this comment.
So here a couple comments just to simplify a bit the tests but otherwise it looks good.
Co-authored-by: Guillaume Lemaitre <guillaume@probabl.ai>
Co-authored-by: Guillaume Lemaitre <guillaume@probabl.ai>
Co-authored-by: Guillaume Lemaitre <guillaume@probabl.ai>
Co-authored-by: Guillaume Lemaitre <guillaume@probabl.ai>
Co-authored-by: Guillaume Lemaitre <guillaume@probabl.ai>
Contributor
Author
|
I have committed the suggestions, thank you very much! |
glemaitre
approved these changes
Nov 8, 2024
Member
glemaitre
left a comment
There was a problem hiding this comment.
I just pushed a small fix to make the linter happy by removing a trailing space.
Pipeline
Member
|
Enabling auto-merge |
Member
|
adding the label "To Backport" and the milestone to not forget this PR. |
glemaitre
added a commit
that referenced
this pull request
Nov 8, 2024
Member
|
Backported in 1.6.X |
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.
Reference Issues/PRs
Fixes #30197
This pull request addresses the issue reported in scikit-learn issue #30197, where an
IndexErroroccurs when attempting to access the last estimator in an empty Pipeline.The current implementation raises an "out of range" error when the steps attribute is empty, which does not provide sufficient context for users.
Changes
Modified sklearn/pipeline.py:
Added tests in sklearn/tests/test_pipeline.py: