在R包rpart中,是什么决定了CP表中为决策树提供的树的大小?在下面的示例中,CP表默认仅显示具有1,2和5个节点的树(分别为nsplit = 0,1和4).
library(rpart)
fit <- rpart(Kyphosis ~ Age + Number + Start, method="class", data=kyphosis)
> printcp(fit)
Classification tree:
rpart(formula = Kyphosis ~ Age + Number + Start, data = kyphosis,
method = "class")
Variables actually used in tree construction:
[1] Age Start
Root node error: 17/81 = 0.20988
n= 81
CP nsplit rel error xerror xstd
1 0.176471 0 1.00000 1.00000 0.21559
2 0.019608 1 0.82353 0.94118 0.21078
3 0.010000 4 0.76471 0.94118 0.21078
Run Code Online (Sandbox Code Playgroud)
是否有一个固有的规则rpart()来确定要呈现的树木大小?并且是否可以强制printcp()返回所有可能大小的树的交叉验证统计信息,即对于上面的示例,还包括具有3和4个节点的树的行(nsplit …