Using entropy as a criterion

In this exercise, you'll train a classification tree on the Wisconsin Breast Cancer dataset using entropy as an information criterion. You'll do so using all the 30 features in the dataset, which is split into 80% train and 20% test.

X_train as well as the array of labels y_train are available in your workspace.

This exercise is part of the course

Machine Learning with Tree-Based Models in Python

View Course

Exercise instructions

  • Import DecisionTreeClassifier from sklearn.tree.

  • Instantiate a DecisionTreeClassifier dt_entropy with a maximum depth of 8.

  • Set the information criterion to 'entropy'.

  • Fit dt_entropy on the training set.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Import DecisionTreeClassifier from sklearn.tree
from ____.____ import ____

# Instantiate dt_entropy, set 'entropy' as the information criterion
dt_entropy = ____(____=____, ____='____', random_state=1)

# Fit dt_entropy to the training set
____.____(____, ____)