ComenzarEmpieza gratis

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.

Este ejercicio forma parte del curso

Ensemble Methods in Python

Ver curso

Instrucciones del ejercicio

  • Instantiate a decision tree classifier with min_samples_leaf = 3 and min_samples_split = 9.
  • Instantiate a 5-nearest neighbors classifier using the 'ball_tree' algorithm.
  • Build a StackingClassifier passing: the list of classifiers, the meta classifier, use_probas=True (to use probabilities), and use_features_in_secondary = False (to only use the individual predictions).
  • Evaluate the performance by computing the accuracy score.

Ejercicio interactivo práctico

Prueba este ejercicio y completa el código de muestra.

# 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)))
Editar y ejecutar código