[R] Fw: rpart

David Winsemius dwinsemius at comcast.net
Tue Jan 29 04:31:54 CET 2013


On Jan 28, 2013, at 9:06 PM, carol white wrote:

> Should I understand that this message was received?

It's always possible to check the Archives for this question.

--  
David.
>
> Thanks
>
>
> ----- Forwarded Message -----
> From: carol white <wht_crl at yahoo.com>
> To: "r-help at stat.math.ethz.ch" <r-help at stat.math.ethz.ch>
> Sent: Sunday, January 27, 2013 8:31 PM
> Subject: rpart
>
>
> Hi,
> When I look at the summary of an rpart object run on my data, I get  
> 7 nodes but when I plot the rpart object, I get only 3 nodes. Should  
> the number of nodes not match in the results of the 2 functions  
> (summary and plot) or it is not always the same?
>
> Look forward to your reply,
>
> Carol
> --------------------------------------------
>  summary(rpart.res)
> Call:
> rpart(formula = mydata$class ~ ., data = as.data.frame(t(mydata)))
>   n= 62
>
>          CP nsplit rel error    xerror      xstd
> 1 0.6363636      0 1.0000000 1.0000000 0.1712469
> 2 0.1363636      1 0.3636364 0.6818182 0.1532767
> 3 0.0100000      2 0.2272727 0.7727273 0.1596659
>
> Variable importance
>   Hsa.627   Hsa.692 Hsa.692.2  Hsa.3306   Hsa.601   Hsa.831  Hsa. 
> 1832  Hsa.2456
>        19
> 13        11        10        10         8         6         6
>  Hsa.8147  Hsa.1131 Hsa.692.1
>         6         5         5
>
> Node number 1: 62 observations,    complexity param=0.6363636
>   predicted class=t  expected loss=0.3548387  P(node) =1
>     class counts:    22    40
>    probabilities: 0.355 0.645
>   left son=2 (14 obs) right son=3 (48 obs)
>   Primary splits:
>       Hsa.627   < 59.83    to the left,  improve=15.05376, (0
> missing)
>       Hsa.8147  < 1696.23  to the right, improve=14.46790, (0 missing)
>       Hsa.37937 < 379.39   to the right, improve=13.75358, (0 missing)
>       Hsa.692.2 < 842.305  to the right, improve=12.38710, (0 missing)
>       Hsa.1832  < 735.805  to the right, improve=11.90495, (0 missing)
>   Surrogate splits:
>       Hsa.692.2 < 1086.655 to the right, agree=0.903, adj=0.571, (0  
> split)
>       Hsa.3306  < 170.515  to the left,  agree=0.887, adj=0.500, (0  
> split)
>       Hsa.601   < 88.065   to the left,  agree=0.887, adj=0.500, (0  
> split)
>       Hsa.692   < 1251.99  to the right, agree=0.871, adj=0.429, (0
> split)
>       Hsa.831   < 281.54   to the left,  agree=0.871, adj=0.429, (0  
> split)
>
> Node number 2: 14 observations
>   predicted class=n  expected loss=0  P(node) =0.2258065
>     class counts:    14     0
>    probabilities: 1.000 0.000
>
> Node number 3: 48 observations,    complexity param=0.1363636
>   predicted class=t  expected loss=0.1666667  P(node) =0.7741935
>     class counts:     8    40
>    probabilities: 0.167 0.833
>   left son=6 (7 obs) right son=7 (41 obs)
>   Primary splits:
>       Hsa.8147  < 1722.605 to the right, improve=4.915215, (0 missing)
>       Hsa.1832  < 681.145  to the right, improve=4.915215, (0
> missing)
>       Hsa.1410  < 49.985   to the left,  improve=4.915215, (0 missing)
>       Hsa.2456  < 186.195  to the right, improve=4.915215, (0 missing)
>       Hsa.11616 < 969.085  to the right, improve=4.915215, (0 missing)
>   Surrogate splits:
>       Hsa.1832  < 681.145  to the right, agree=1.000, adj=1.000, (0  
> split)
>       Hsa.2456  < 186.195  to the right, agree=1.000, adj=1.000, (0  
> split)
>       Hsa.692   < 1048.375 to the right, agree=0.979, adj=0.857, (0  
> split)
>       Hsa.692.1 < 1136.75  to the right, agree=0.979, adj=0.857, (0  
> split)
>       Hsa.1131  < 1679.54  to the right, agree=0.979, adj=0.857, (0  
> split)
>
> Node
> number 6: 7 observations
>   predicted class=n  expected loss=0.2857143  P(node) =0.1129032
>     class counts:     5     2
>    probabilities: 0.714 0.286
>
> Node number 7: 41 observations
>   predicted class=t  expected loss=0.07317073  P(node) =0.6612903
>     class counts:     3    38
>    probabilities: 0.073 0.927  
> <rpart.png>______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius, MD
Alameda, CA, USA



More information about the R-help mailing list