From the course: Machine Learning with Python: Decision Trees
Unlock the full course today
Join today to access over 24,700 courses taught by industry experts.
How to visualize a regression tree in Python - Python Tutorial
From the course: Machine Learning with Python: Decision Trees
How to visualize a regression tree in Python
- [Instructor] Before we get started, note that this video is the second in a three video sequence that explains how to build, visualize and prune a regression tree. So if you have not done so, watch the previous video for a detailed walkthrough of the code and the cells above. Now that we've trained on regression tree, let's visualize it to get a better understanding of the tree logic. First, we make sure that we import the tree object from the sklearn package. The figure method of Pyplot allows us to specify the size of our tree, feel free to adjust this to see how it impacts the size of your tree. Next, we'll use the plot tree method of the tree object to visualize the tree. The first argument we pass to this method is the regression tree model itself. Then we specify the dummy coded independent variables as a list. Finally, we specify that we want the nodes of the tree color field. Because of the depth, and…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.