[R] To get more digits in precision of predict function of randomForests

Uwe Ligges ligges at statistik.tu-dortmund.de
Mon Feb 25 10:56:15 CET 2008



Nagu wrote:
> Hi,
> 
> I am using randomForests for a classification problem. The predict
> function in the randomForest library, when asked to return the
> probabilities, has precision of two digits after the decimal. I need
> at least four digits of precision for the predicted probabilities. How
> do I achieve this?

For me it gives the desired precision, adapting the 
?predict.randomForest example:

data(iris)
set.seed(111)
ind <- sample(2, nrow(iris), replace = TRUE, prob=c(0.8, 0.2))
iris.rf <- randomForest(Species ~ ., data=iris[ind == 1,], ntree = 2000)
iris.pred <- predict(iris.rf, iris[ind == 2,], type = "prob")
iris.pred

Maybe you do not have much more than 1000 trees in your bag?

Uwe Ligges







> 
> Thank you,
> Nagu
> 
> ______________________________________________
> 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.



More information about the R-help mailing list