-
-
Notifications
You must be signed in to change notification settings - Fork 26.5k
FIX handle empty steps in Pipeline
#30203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FIX handle empty steps in Pipeline
#30203
Conversation
adrinjalali
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <[email protected]>
…replace direct _estimator_type checks with is_classifier() and is_regressor() assertions.
Co-authored-by: Adrin Jalali <[email protected]>
Co-authored-by: Adrin Jalali <[email protected]>
|
Hey @adrinjalali, the PR is completed on my end. Please let me know if any further reviews are needed. Thank you! |
adrinjalali
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. cc @glemaitre for the second review.
glemaitre
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So here a couple comments just to simplify a bit the tests but otherwise it looks good.
Co-authored-by: Guillaume Lemaitre <[email protected]>
Co-authored-by: Guillaume Lemaitre <[email protected]>
Co-authored-by: Guillaume Lemaitre <[email protected]>
Co-authored-by: Guillaume Lemaitre <[email protected]>
Co-authored-by: Guillaume Lemaitre <[email protected]>
|
I have committed the suggestions, thank you very much! |
glemaitre
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just pushed a small fix to make the linter happy by removing a trailing space.
Pipeline
|
Enabling auto-merge |
|
adding the label "To Backport" and the milestone to not forget this PR. |
Co-authored-by: Adrin Jalali <[email protected]> Co-authored-by: Guillaume Lemaitre <[email protected]>
|
Backported in 1.6.X |
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: