Go to TogaWare.com Home Page. Data Science Desktop Survival Guide
by Graham Williams
Duck Duck Go

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=120710 (3012 observations deleted due to missingness)
## 
## node), split, n, deviance, yval
##       * denotes terminal node
## 
##  1) root 120710 8520917.0  2.250133  
##    2) humidity_3pm< 83.5 112949 3473217.0  1.466297  
##      4) humidity_3pm< 67.5 95894 1848947.0  1.004440 *
##      5) humidity_3pm>=67.5 17055 1488802.0  4.063149 *
##    3) humidity_3pm>=83.5 7761 3968362.0 13.657610  
##      6) rainfall< 23.1 6929 2035563.0 11.241620  
##       12) min_temp< 22.45 6552 1455940.0 10.268640 *
##       13) min_temp>=22.45 377  465620.4 28.151460 *
##      7) rainfall>=23.1 832 1555527.0 33.778250  
##       14) min_temp< 20.35 605  646342.8 25.438180 *
##       15) min_temp>=20.35 227  754946.3 56.006170  
##         30) humidity_3pm< 95.5 179  350412.6 45.052510 *
##         31) humidity_3pm>=95.5 48  302966.0 96.854170 *


Support further development by purchasing the PDF version of the book.
Other online resources include the GNU/Linux Desktop Survival Guide.
Books available on Amazon include Data Mining with Rattle and Essentials of Data Science.
Popular open source software includes rattle and wajig.
Hosted by Togaware, a pioneer of free and open source software since 1984.
Copyright © 2000-2020 Togaware Pty Ltd. . Creative Commons ShareAlike V4.