[R] Random Forest

Liaw, Andy andy_liaw at merck.com
Mon Mar 1 16:14:26 CET 2010


From: Dror
> 
> Hi,
> I'm working with randomForest package and i have 2 questions:
> 1. how can i drop a specific tree from the forest?

Answered in another post.

> 2. i'm trying to get the voting of each tree in a prediction 
> datum using the
> folowing code
>   >  pr<-predict(RF,NewData,type="prob",predict.all=TRUE)
> my forest has 300 trees and i get lower number of votes:
> > length(pr$individual)
> [1] 275
>  > RF
> Call:
>  randomForest(formula = RFformula, data = adult, ntree = 300, 
>      mtry = 1,
> keep.forest = TRUE) 
>                Type of random forest: classification
>                      Number of trees: 300
> No. of variables tried at each split: 1
> Am i doing something wrong? how can i know which of the 300 
> trees didn't
> cast a vote?

Hope this example is clear:

R> iris.rf = randomForest(Species~., iris, ntree=148)
R> iris.p = predict(iris.rf, iris, predict.all=TRUE)
R> str(iris.p$individual)
 chr [1:150, 1:148] "setosa" "setosa" "setosa" "setosa" "setosa" ...
 - attr(*, "dimnames")=List of 2
  ..$ : chr [1:150] "1" "2" "3" "4" ...
  ..$ : NULL
R> length(iris.p$individual)
[1] 22200

Andy

 
> Thanks in advance
> Dror
> -- 
> View this message in context: 
> http://n4.nabble.com/Random-Forest-tp1557464p1571952.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> 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.
> 
Notice:  This e-mail message, together with any attachme...{{dropped:10}}



More information about the R-help mailing list