Skip to content

EasyEnsemble should be a meta-estimator #252

Closed
@amueller

Description

@amueller

I'm not entirely sure how EasyEnsemble should be used, but I feel like it might be easier if it was a meta-estimator.
Let's say I want to implement a random forest using EasyEnsemble as an estimator. I have no idea how to do that easily. If it was a meta-estimator, I could just do EasyEnsemble(DecisionTreeClassifier(max_features="auto")), which would be nice. Ideally this would set the random seeds, too.

I ended up with this solution, which works, but is verbose and probably inefficient:

from sklearn.ensemble import VotingClassifier
from sklearn.tree import DecisionTreeClassifier
def make_resample_tree(random_state=0):
    tree = make_imb_pipeline(RandomUnderSampler(random_state=random_state, replacement=True),
                             DecisionTreeClassifier(max_features='auto', random_state=random_state))
    return "tree_i".format(random_state), tree
classifiers = [make_resample_tree(i) for i in range(100)]
resampled_rf = VotingClassifier(classifiers, voting='soft')

[Though it is kinda neat that I can write it down like that ;]

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions