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=141892 (4054 observations deleted due to missingness)
##
## node), split, n, deviance, yval
## * denotes terminal node
##
## 1) root 141892 10136960 2.299120
## 2) humidity_3pm< 84.5 132975 4530675 1.519646
## 4) humidity_3pm< 68.5 113539 2283099 1.039171 *
## 5) humidity_3pm>=68.5 19436 2068247 4.326430 *
## 3) humidity_3pm>=84.5 8917 4320662 13.923060
## 6) rainfall< 27.9 8173 2446015 11.837640
## 12) min_temp< 18.55 6704 1245281 9.940453 *
## 13) min_temp>=18.55 1469 1066485 20.495710 *
## 7) rainfall>=27.9 744 1448642 36.831850
## 14) min_temp< 17.65 359 218956 23.629530 *
## 15) min_temp>=17.65 385 1108763 49.142600 *
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