Assembling your first ensemble
It's time to build your first ensemble model! The Pokémon dataset from the previous exercise has been loaded and split into train and test sets.
Your job is to leverage the voting ensemble technique using the sklearn API. It's up to you to instantiate the individual models and pass them as parameters to build your first voting classifier.
Questo esercizio fa parte del corso
Ensemble Methods in Python
Istruzioni dell'esercizio
- Instantiate a
KNeighborsClassifiercalledclf_knnwith 5 neighbors (specified usingn_neighbors). - Instantiate a
"balanced"LogisticRegressioncalledclf_lr(specified usingclass_weight). - Instantiate a
DecisionTreeClassifiercalledclf_dtwithmin_samples_leaf = 3andmin_samples_split = 9. - Build a
VotingClassifierusing the parameterestimatorsto specify the following list of (str, estimator) tuples:'knn',clf_knn,'lr',clf_lr, and'dt',clf_dt.
Esercizio pratico interattivo
Prova a risolvere questo esercizio completando il codice di esempio.
# Instantiate the individual models
clf_knn = ____
clf_lr = ____
clf_dt = ____(____, ____, random_state=500)
# Create and fit the voting classifier
clf_vote = ____(
estimators=[('____', ____), ('____', ____), ('____', ____)]
)
clf_vote.fit(X_train, y_train)