Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@thomasjpfan
Copy link
Member

Reference Issues/PRs

Fixes #30622

What does this implement/fix? Explain your changes.

This PR adds a little more validation to make sure estimators is correct in VotingClassifer and VotingRegressor.

@github-actions
Copy link

github-actions bot commented Jan 15, 2025

✔️ Linting Passed

All linting checks passed. Your pull request is in excellent shape! ☀️

Generated for commit: 56c8cad. Link to the linter CI: here

Copy link
Contributor

@OmarManzoor OmarManzoor left a 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

@OmarManzoor OmarManzoor added Quick Review For PRs that are quick to review Waiting for Second Reviewer First reviewer is done, need a second one! labels Jan 17, 2025
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)
Copy link
Member

@lesteve lesteve Jan 17, 2025

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 ...

Copy link
Member

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.

Copy link
Member Author

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)

@lesteve
Copy link
Member

lesteve commented Jan 21, 2025

Thanks, let's merge this one!

@lesteve lesteve merged commit f09c7d9 into scikit-learn:main Jan 21, 2025
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module:ensemble Quick Review For PRs that are quick to review Waiting for Second Reviewer First reviewer is done, need a second one!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Validate estimators argument of VotingClassifier

4 participants