Aan de slagGa gratis aan de slag

Define the AdaBoost classifier

In the following exercises you'll revisit the Indian Liver Patient dataset which was introduced in a previous chapter. Your task is to predict whether a patient suffers from a liver disease using 10 features including Albumin, age and gender. However, this time, you'll be training an AdaBoost ensemble to perform the classification task. In addition, given that this dataset is imbalanced, you'll be using the ROC AUC score as a metric instead of accuracy.

As a first step, you'll start by instantiating an AdaBoost classifier.

Deze oefening maakt deel uit van de cursus

Machine Learning with Tree-Based Models in Python

Cursus bekijken

Oefeninstructies

  • Import AdaBoostClassifier from sklearn.ensemble.

  • Instantiate a DecisionTreeClassifier with max_depth set to 2.

  • Instantiate an AdaBoostClassifier consisting of 180 trees and setting the base_estimator to dt.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Import DecisionTreeClassifier
from sklearn.tree import DecisionTreeClassifier

# Import AdaBoostClassifier
____

# Instantiate dt
dt = ____(____=____, random_state=1)

# Instantiate ada
ada = ____(base_estimator=____, n_estimators=____, random_state=1)
Code bewerken en uitvoeren