Regression and Classification with Decision Trees
We can solve regression and classification tasks with a multitude of machine learning algorithms. In the previous chapter, we used neural networks, and, in this chapter, we have used linear and logistic regression. In the next chapter, we will learn about decision trees and random forests, which can also be used for these tasks. While linear and logistic regression models are usually easier to interpret, random forests can sometimes be better at making predictions. In this section, we will apply random forests to our dataset and compare the results to our linear and logistic regression models.
As we have seen in Chapter 1, An Introduction to Machine Learning, a decision tree is basically a set of if/else statements arranged as an upside-down tree, where the leaf nodes contain the possible predictions. For a specific observation, we could end up with the following paths down a tree:
- If a home is larger than 1,500 sqft and it has more than...