Introduction to Scikit-learn
Chapter 6: Classification
Training a Decision Tree classifier
Here is another example. This time we will train a Decision Tree classifier.
>>> from sklearn.tree import DecisionTreeClassifier
>>> dt_classifier = DecisionTreeClassifier(criterion="entropy", max_depth=5, min_samples_split=5)
>>> dt_classifier.fit(x_train, y_train)
After fitting the model, you will again have access to many different attributes, including a .tree_
attribute that allows you to analyse your resulting decision tree. Again, see the official documentation for DecisionTreeClassifier
for more details.