BaşlayınÜcretsiz Başlayın

Building the stacking classifier

Now you'll work on the next two steps.

Step 3: Append the predictions to the dataset: this is internally handled by the StackingClassifier class, but we'll do our part by preparing the list of first-level classifiers, which you built in the previous exercise. These are available as: clf_dt and clf_knn.

Step 4: Build the second-layer meta estimator: for this purpose you'll use the default LogisticRegression. This will take as input features the individual predictions from the base estimators.

With both levels of estimators ready you can build the stacking classifier.

Bu egzersiz

Ensemble Methods in Python

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Prepare the list of tuples with the first-layer classifiers: clf_dt and clf_knn (specifying the appropriate labels and order).
  • Instantiate the second-layer meta estimator: a LogisticRegression.
  • Build the stacking classifier passing: the list of tuples, the meta classifier, with stack_method='predict_proba' (to use class probabilities), and passthrough = False (to only use predictions as features).

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Prepare the list of tuples with the first-layer classifiers
classifiers = [
	____,
    ____
]

# Instantiate the second-layer meta estimator
clf_meta = ____

# Build the stacking classifier
clf_stack = ____(
   ____,
   ____,
   ____,
   ____)
Kodu Düzenle ve Çalıştır