Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
[MRG] MAINT add base class for voting and stacking #15084
Create a base class for Voting* and Stacking*. They both are an ensemble of multiple learners type.
This base class could be contrasted with the ensemble of single learner type such as boosting (adaboost, GBDT), RF and Bagging.
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
Having the init make it explicit that the estimators parameter is the common denominator for all inherited classes. I am fine keeping it.…
On Wed, 2 Oct 2019 at 13:07, Nicolas Hug ***@***.***> wrote: *@NicolasHug* commented on this pull request. ------------------------------ In sklearn/ensemble/base.py <#15084 (comment)> : > @@ -178,3 +182,76 @@ def _partition_estimators(n_estimators, n_jobs): starts = np.cumsum(n_estimators_per_job) return n_jobs, n_estimators_per_job.tolist(),  + starts.tolist() + + +class _BaseHeterogeneousEnsemble(MetaEstimatorMixin, _BaseComposition, + metaclass=ABCMeta): + """Base class for ensemble learners based on heterogeneous estimators.""" + _required_parameters = ['estimators'] + + @Property + def named_estimators(self): + return Bunch(**dict(self.estimators)) + + @AbstractMethod + def __init__(self, estimators): + self.estimators = estimators i'm suggesting to not have the init method — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <#15084?email_source=notifications&email_token=ABY32P6RROAFMVM32WZOLMTQMR6FTA5CNFSM4I2CTMN2YY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCGTRNOY#discussion_r330490319>, or mute the thread <https://github.com/notifications/unsubscribe-auth/ABY32PYGSAUSWSRVBIUX6RLQMR6FTANCNFSM4I2CTMNQ> .
-- Guillaume Lemaitre Scikit-learn @ Inria Foundation https://glemaitre.github.io/
NicolasHug left a comment
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.