20.74 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=187165 (5622 observations deleted due to missingness)
##
## node), split, n, deviance, yval
## * denotes terminal node
##
## 1) root 187165 13730350.0 2.338704
## 2) humidity_3pm< 84.5 175182 5850274.0 1.528809
## 4) humidity_3pm< 67.5 146520 2837333.0 1.004309 *
## 5) humidity_3pm>=67.5 28662 2766579.0 4.210055 *
## 3) humidity_3pm>=84.5 11983 6085324.0 14.178720
## 6) rainfall< 27.5 10939 3655341.0 12.111930
## 12) min_temp< 11.75 5531 681840.4 8.008968 *
## 13) min_temp>=11.75 5408 2785162.0 16.308210 *
## 7) rainfall>=27.5 1044 1893649.0 35.834480
## 14) min_temp< 19.95 709 588138.8 26.436530 *
## 15) min_temp>=19.95 335 1110360.0 55.724480 *
Your donation will support ongoing availability 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-2022 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0