Now that we have trained a decision tree model, we need to extract the insights from the model. In this section, we are going to use a package called graphviz. You can install this package by using the following command in your Terminal:
conda install python-graphviz
Once you have installed this package correctly, you should be able to import the package as follows:
import graphviz
Now that we have set up our environment with the new package, graphviz, let's take a look at the following code to see how we can visualize the trained decision tree:
dot_data = tree.export_graphviz( dt_model, feature_names=features, class_names=['0', '1'], filled=True, rounded=True, special_characters=True) graph = graphviz.Source(dot_data) ...