Exercise

Prepare the ground

In the following exercises, you'll compare the OOB accuracy to the test set accuracy of a bagging classifier trained on the Indian Liver Patient dataset.

In sklearn, you can evaluate the OOB accuracy of an ensemble classifier by setting the parameter oob_score to True during instantiation. After training the classifier, the OOB accuracy can be obtained by accessing the .oob_score_ attribute from the corresponding instance.

In your environment, we have made available the class DecisionTreeClassifier from sklearn.tree.

Instructions

100 XP
  • Import BaggingClassifier from sklearn.ensemble.

  • Instantiate a DecisionTreeClassifier with min_samples_leaf set to 8.

  • Instantiate a BaggingClassifier consisting of 50 trees and set oob_score to True.