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



CLICK HERE TO VISIT THE UPDATED SURVIVAL GUIDE

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=120704 (3018 observations deleted due to missingness)
## 
## node), split, n, deviance, yval
##       * denotes terminal node
## 
##  1) root 120704 8785460.0  2.272201  
##    2) humidity_3pm< 83.5 112864 3791677.0  1.486089  
##      4) humidity_3pm< 66.5 94010 1731286.0  0.983856 *
##      5) humidity_3pm>=66.5 18854 1918441.0  3.990326 *
##    3) humidity_3pm>=83.5 7840 3919967.0 13.589010  
##      6) rainfall< 39.1 7439 2505518.0 11.983020  
##       12) min_temp< 15.95 5209  838540.7  9.100749 *
##       13) min_temp>=15.95 2230 1522622.0 18.715650 *
##      7) rainfall>=39.1 401 1039330.0 43.381800 *


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.