Computer scienceData scienceInstrumentsScikit-learnTraining ML models with scikit-learnClassification in scikit-learn

Decision tree with scikit-learn

Find the depth

Report a typo

Load the iris dataset with the code snippet below.

Train a DecisionTreeClassifier with random_state=42. Call the .get_depth() method on the trained classifier. The result of this call is the answer for this task.

from sklearn.model_selection import train_test_split
from sklearn.datasets import load_iris

X, y = load_iris(return_X_y=True)

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33, random_state=42)
Enter a number
___

Create a free account to access the full topic