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

Skip to content

Conversation

@glemaitre
Copy link
Member

@glemaitre glemaitre commented Sep 24, 2019

closes #15056

Create a base class for Voting* and Stacking*. They both are an ensemble of multiple learners type.
They could share the get_params, set_params and validation of estimators (as well as the fitted attributes then).

This base class could be contrasted with the ensemble of single learner type such as boosting (adaboost, GBDT), RF and Bagging.

@glemaitre
Copy link
Member Author

@thomasjpfan @ogrisel @rth @adrinjalali

So the naming of the base class is terrible but I wanted to have a WIP PR such that we see what is in common and if it makes sense to merge code.

NB: the tests will fail because I did not add support for None to drop an estimator (only available in the voting and not in the stacking). This is easily fixed and would ease the deprecation.

WDYT?

Copy link
Member

@thomasjpfan thomasjpfan left a comment

Choose a reason for hiding this comment

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

I like this refactoring. The _BaseEnsembleHeterogeneousEstimator class has have well defined boundaries.

@glemaitre glemaitre changed the title [WIP] MAINT add base class for voting and stacking [MRG] MAINT add base class for voting and stacking Oct 1, 2019
@glemaitre
Copy link
Member Author

Good to be reviewed. I will open a PR to deprecate None support and use 'drop' instead.

@glemaitre
Copy link
Member Author

glemaitre commented Oct 2, 2019 via email

Copy link
Member

@NicolasHug NicolasHug left a comment

Choose a reason for hiding this comment

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

I guess I'm becoming increasingly skeptical about the relevance of inheritance in some cases (like here where all it does is set a single attribute). Makes the code easy to write, but often harder to understand.

But LGTM anyway.

- |Fix| Stacking and Voting estimators now ensure that their underlying
estimators are either all classifiers or all regressors.
We introduced a new base class
:class:`ensemble.base._BaseHeterogeneousEnsemble` to raise consistent error
Copy link
Member

Choose a reason for hiding this comment

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

Should we include a private class in the whats new? This can be something like:

Stacking and Voting estimators now raise consistent error messages.

Copy link
Member Author

Choose a reason for hiding this comment

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

I might be misunderstood what @NicolasHug meant by adding a link?
Did you mean mentioning the class or do you expect something else?

Copy link
Member

Choose a reason for hiding this comment

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

Since we are not generating a new API doc for _BaseHeterogeneousEnsemble, there is nothing to link to: https://76528-843222-gh.circle-artifacts.com/0/doc/whats_new/v0.22.html#sklearn-ensemble

Copy link
Member

Choose a reason for hiding this comment

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

The links referred to the Stacking and Voting estimators, sorry if that wasn't clear. I agree we shouldn't link a private class. (and I'm also fine not linking the estimators... it's just a nit)

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh ok make sense.


- |Fix| Stacking and Voting estimators now ensure that their underlying
estimators are either all classifiers or all regressors.
We introduced a new base class
Copy link
Member

Choose a reason for hiding this comment

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

We do not need a "new base class" part?

:class:ensemble.StackingClassifier, :class:ensemble.StackingRegressor, :class:ensemble.VotingClassifier, and :class:ensemeble.VotingRegressor now raise consistent error messages.

Copy link
Member Author

Choose a reason for hiding this comment

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

wrong edit

@thomasjpfan thomasjpfan merged commit 7dd03e0 into scikit-learn:master Oct 5, 2019
@thomasjpfan
Copy link
Member

Thank you @glemaitre !

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.

VotingClassifier and roc_auc TypeError: Cannot cast array data from dtype('float64') to dtype('int64') according to the rule 'safe' and

4 participants