Print
Plotting Decision Trees
Read It: Plotting Decision Trees for Classification
One way you can begin to interpret the results of the random forest model is to plot one of the trees, as demonstrated in the video below. Note that for a random forest, you are plotting only one of many trees and are not being shown the aggregated version of the model. In this sense, each tree will be slightly different, since it was created using slightly different data.
Watch It: Video - Classification Plotting Tree (5:08 minutes)
Try It: GOOGLE COLAB
- Click the Google Colab file used in the video here.
- Go to the Colab file and click "File" then "Save a copy in Drive", this will create a new Colab file that you can edit in your own Google Drive account.
- Once you have it saved in your Drive, try to edit the code from the previous section to plot a tree in your random forest model. Make sure to upload the data and rerun the model.
Note: You must be logged into your PSU Google Workspace in order to access the file.
# load the dataset recs = pd.read_csv(...) # rerun model here # plot decision tree tfdf.model_plotter.plot_model_in_colab(...)
Once you have implemented this code on your own, come back to this page to test your knowledge.