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 prune a regression tree in Python - Python Tutorial
From the course: Machine Learning with Python: Decision Trees
How to prune a regression tree in Python
- [Instructor] Before we get started, note that this video is the third in a three-video sequence that explains how to build, visualize and prune a regression tree in Python. If you have not done so, watch the previous two videos for a detailed walkthrough of the code in the cells above. Now that we've trained and visualized a regression tree, let's look into what we can do to improve its performance by pruning. Decision trees are prone to overfitting. One telltale sign that a tree has overfit is if it performs well on the training data but very poorly on the test data. Let's evaluate our tree to see if it overfit on the training data. To do this, we pass the training data to the score method of the model. Our model is able to explain 99% of the variability in the training data. Let's see how it does on the test data. Similarly, we pass the test data to the score method of the model. Our model is only able to…
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.