Skip to content

[MRG] API use drop a sentinel to disable estimators in voting - #13780

Merged
jnothman merged 17 commits into
scikit-learn:masterfrom
glemaitre:is/13771
May 7, 2019
Merged

jnothman merged 17 commits into
scikit-learn:masterfrom
glemaitre:is/13771

Conversation

@glemaitre

@glemaitre glemaitre commented May 3, 2019 •

Copy link
Copy Markdown
Member

closes #13771

For consistency, we should allow 'drop' to work the same as None to disable estimators in Voting estimators.

Need to merge #13777 before to have the bug fix regarding the None and the sample weight.

@glemaitre glemaitre changed the title API use drop a sentinel to disable estimators in voting [MRG] API use drop a sentinel to disable estimators in voting May 3, 2019

@jnothman jnothman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise lgtm.

When was the None support added? I'd be tempted to merge this for 0.21 and not support None if that was only just added now...

Comment thread sklearn/ensemble/tests/test_voting.py Outdated
# regression test for
# https://github.com/scikit-learn/scikit-learn/issues/13777
voter.fit(X, y, sample_weight=np.ones(y.shape))
voter.set_params(lr=None)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or drop?

Comment thread sklearn/ensemble/voting.py Outdated
return [w for est, w in zip(self.estimators,
self.weights) if est[1] is not None]
return [w for est, w in zip(self.estimators, self.weights)
if not(est[1] is None or est[1] == 'drop')]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use in (None, 'drop')?

@glemaitre

Copy link
Copy Markdown
Member Author

None was introduced in 0.19: #7674 I assume that we have to keep it then.

@glemaitre

Copy link
Copy Markdown
Member Author

@jnothman Do you want to merge this PR directly and I am closing #13777

I also incorporated the change required to avoid using has_fit_parameter. The only drawback is that it will fail a bit later in fit (meaning that we can spend time fitting some estimators before to fail).
WDYT?

@glemaitre

Copy link
Copy Markdown
Member Author

@qinhanmin2014 You can have a look a this now. I solved the conflicts.

@jnothman jnothman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise LGTM

Comment thread sklearn/ensemble/tests/test_voting.py Resolved
Comment thread sklearn/ensemble/voting.py Resolved
Comment thread sklearn/ensemble/tests/test_voting.py Resolved
Comment thread sklearn/ensemble/voting.py Resolved
Comment thread sklearn/ensemble/voting.py Resolved

@thomasjpfan thomasjpfan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@thomasjpfan

Copy link
Copy Markdown
Member

@jnothman Good to have in 0.21?

@jnothman
jnothman merged commit 1e2e847 into scikit-learn:master May 7, 2019
jnothman pushed a commit to jnothman/scikit-learn that referenced this pull request May 7, 2019
koenvandevelde pushed a commit to koenvandevelde/scikit-learn that referenced this pull request Jul 12, 2019
davidgegiya added a commit to davidgegiya/agent-orchestrator that referenced this pull request Nov 8, 2026
…imator in VotingClassifier/VotingRegressor

Pin 8d3b4ff3eec890396a3d7a806bbe944f55a89cb4 and its regression selectors for reproducible runs.

Source: scikit-learn/scikit-learn#13780
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Handle 'drop' together with None to drop estimator in VotingClassifier/VotingRegressor

3 participants