-
-
Notifications
You must be signed in to change notification settings - Fork 26.5k
FIX Validate estimators in Voting{Classifier,Regressor} #30649
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 Validate estimators in Voting{Classifier,Regressor} #30649
Conversation
OmarManzoor
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.
Otherwise LGTM. Thanks @thomasjpfan
Co-authored-by: Omar Salman <[email protected]>
sklearn/ensemble/_base.py
Outdated
| def _validate_estimators(self): | ||
| if len(self.estimators) == 0: | ||
| if len(self.estimators) == 0 or not all( | ||
| isinstance(item, tuple) and isinstance(item[0], str) |
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.
Not sure how much we care, but the previous code was working fine with lists rather than tuple and with this PR it would be an error, i.e. when using estimators=[['name', LogisticRegression()]] rather than estimators=[('name', LogisticRegression())]
I guess this is documented as a list of tuples but you never know people may be using list of lists in the wild ...
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'm +1 to silently allow lists as well.
For instance in Pipeling, ColumnTransformer, ... we silently allow tuples in addition to lists.
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.
Updated to allow list in: 56c8cad (#30649)
|
Thanks, let's merge this one! |
Reference Issues/PRs
Fixes #30622
What does this implement/fix? Explain your changes.
This PR adds a little more validation to make sure
estimatorsis correct inVotingClassiferandVotingRegressor.