Visualizing your DecisionTreeClassifier() Split Nodes on Python

Rodrigo Dutcosky
1 min readJul 5, 2020

Hello there!

Today I'll make a quick complement from Tree Based Decision Model for Classification — Practical Implementation. If you didn't have the chance of reading it yet, you can find it below:

Last time we used Decision Tree Classifiers to predict an animal Class Type based on multiple numeric features.

We know some logic was used to determinate the classes each animal belongs to, but which was it? Where did the algorithm performed each split?

Today I want to show you a quick tip on how to visualize these Tree Nodes, and consequently, the path of decisions.

The libraries used to do so are the following:

Also, make sure you have a variable holding the names of the columns used on your model training. Something like…

DF is the name of your train/test dataset, of course.

Now all you have to do is apply the following lines of code:

TREE_MODEL_01 is the model object from my last post.

Hope you liked this quick tip and see you next time!

--

--