Generated by Bing Image Creator: Earth and Winds and Fire Landscape, photo
This post is following of the above post. In the previous post, I did linear regression with both traditional way and modern way.
In this post I will do tree-based regression.
First, I load rpart package.
Then, let's fit tree model
Next, I use plotcp() function to check if we need prune the tree or not.
It shows cp = 0.11 is the best cp. So I prune the tree with cp = 0.11.
Let's see the result.
I use rpart.plot library to visualize the result.
The result is quite simple, if Y2006 is greater than or equalt to 7.7, Chg_Net would be -0.15, otherwise, Chg_Net is 0.78.
That's it. Thank you!
Next post is
To read from the first post,