我在r studio中使用rpart包。我不确定是否需要减少字体,扩展分支,或进行某种类型的修剪?
c.tree1 <- rpart(certified ~ grade + forum.posts + assignment,
method="class", data=M1,
control=rpart.control(minsplit=1,minbucket=1, cp=0.001))
>
> #Check the results from the classifcation tree using the printcp() command
> printcp(c.tree1)
Classification tree:
rpart(formula = certified ~ grade + forum.posts + assignment,
data = M1, method = "class", control = rpart.control(minsplit = 1,
minbucket = 1, cp = 0.001))`
Variables actually used in tree construction:
[1] assignment forum.posts grade
Root node error: 204/1000 = 0.204
n= 1000
CP nsplit rel error xerror xstd
1 0.0044563 0 1.00000 1.0000 0.062466
2 0.0039216 20 0.90196 1.1373 0.065433
3 0.0036765 36 0.83333 1.2549 0.067651
4 0.0032680 40 0.81863 1.3088 0.068577
5 0.0029412 53 0.77451 1.3627 0.069448
6 0.0028011 65 0.73529 1.3627 0.069448
7 0.0024510 100 0.61765 1.4657 0.070968
8 0.0016340 198 0.37255 1.4853 0.071237
9 0.0012255 250 0.27451 1.6029 0.072720
10 0.0010000 262 0.25980 1.6324 0.073056
> #Plot your tree
> plot(c.tree1)
> text(c.tree1)