Ensemble Methods in Python
Román de las Heras
Data Scientist, Appodeal

How to provide a good estimate?
Actual Value ~ mean(estimates)
Properties
Averaging Classifier
from sklearn.ensemble import VotingClassifierclf_voting = VotingClassifier( estimators=[ ('label1', clf_1), ('label2', clf_2), ... ('labelN', clf_N)], voting='soft', weights=[w_1, w_2, ..., w_N] )
Averaging Regressor
from sklearn.ensemble import VotingRegressorreg_voting = VotingRegressor( estimators=[ ('label1', reg_1), ('label2', reg_2), ... ('labelN', reg_N)], weights=[w_1, w_2, ..., w_N] )
# Instantiate the individual models
clf_knn = KNeighborsClassifier(5)
clf_dt = DecisionTreeClassifier()
clf_lr = LogisticRegression()
# Create an averaging classifier
clf_voting = VotingClassifier(
    estimators=[
       ('knn', clf_knn), 
       ('dt', clf_dt), 
       ('lr', clf_lr)],
    voting='soft',
    weights=[1, 2, 1]
)
Target:
Features:

Ensemble Methods in Python