A first attempt with mlxtend
It's time to start working with mlxtend! You'll continue using the app ratings dataset. As you have already built a stacked ensemble model using scikit-learn, you have a basis to compare with the model you'll now build with mlxtend.
The dataset is loaded and available to you as apps.
Let's see if mlxtend can build a model as good as or better than the scikit-learn ensemble classifier.
Diese Übung ist Teil des Kurses
Ensemble Methods in Python
Anleitung zur Übung
- Instantiate a decision tree classifier with
min_samples_leaf = 3andmin_samples_split = 9. - Instantiate a 5-nearest neighbors classifier using the
'ball_tree'algorithm. - Build a
StackingClassifierpassing: the list of classifiers, the meta classifier,use_probas=True(to use probabilities), anduse_features_in_secondary = False(to only use the individual predictions). - Evaluate the performance by computing the accuracy score.
Interaktive Übung
Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.
# Instantiate the first-layer classifiers
clf_dt = ____(____, ____, random_state=500)
clf_knn = ____
# Instantiate the second-layer meta classifier
clf_meta = LogisticRegression()
# Build the Stacking classifier
clf_stack = ____
clf_stack.____
# Evaluate the performance of the Stacking classifier
pred_stack = ____
print("Accuracy: {:0.4f}".format(accuracy_score(y_test, pred_stack)))