21.19 Complexity Parameter
We can print a table of optimal prunings based on a complexity
parameter using rpart::printcp(). The data is actually stored as
model$cptable
.
printcp(model)
##
## Classification tree:
## rpart(formula = form, data = ds[tr, vars], model = TRUE)
##
## Variables actually used in tree construction:
## [1] humidity_3pm rainfall
##
## Root node error: 28166/134001 = 0.21019
##
## n= 134001
##
## CP nsplit rel error xerror xstd
## 1 0.144252 0 1.00000 1.00000 0.0052954
## 2 0.039587 1 0.85575 0.85277 0.0049849
## 3 0.033764 2 0.81616 0.82479 0.0049200
## 4 0.010000 3 0.78240 0.78368 0.0048208
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.