How do I make my tree plot in R to be less messy, so I can see the outcomes of the visualization? (image provided)

883 views Asked by At

I am using the rpart package in r studio. I'm not sure if I need to reduce the font, spread the branches out more, or do some type of pruning?

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)

Unreadable tree

0

There are 0 answers