21.75 Regression Trees

The discussion so far has dwelt on classification trees. Regression trees are similarly well catered for in R.

We can plot regression trees as with classification trees, but the node information will be different and some options will not make sense. For example, extra= only makes sense for 100 and 101.

First we will build regression tree:

target <- "risk_mm"
vars <- c(inputs, target)
form <- formula(paste(target, "~ ."))
(model <- rpart(formula=form, data=ds[tr, vars]))
## n=120752 (2970 observations deleted due to missingness)
## 
## node), split, n, deviance, yval
##       * denotes terminal node
## 
##  1) root 120752 8396649.0  2.250833  
##    2) humidity_3pm< 83.5 112893 3666876.0  1.474243  
##      4) humidity_3pm< 67.5 95759 2007610.0  1.019008 *
##      5) humidity_3pm>=67.5 17134 1528510.0  4.018472 *
##    3) humidity_3pm>=83.5 7859 3683662.0 13.406400  
##      6) rainfall< 27.1 7204 2190981.0 11.411970  
##       12) min_temp< 12.45 3967  432678.8  7.780035 *
##       13) min_temp>=12.45 3237 1641845.0 15.862960 *
##      7) rainfall>=27.1 655 1148854.0 35.342140  
##       14) min_temp< 20.55 469  425843.0 26.937740 *
##       15) min_temp>=20.55 186  606353.3 56.533870 *


Your donation will support ongoing development and give you access to the PDF version of this book. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Popular open source software includes rattle, wajig, and mlhub. Hosted by Togaware, a pioneer of free and open source software since 1984.
Copyright © 1995-2021 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0.