[R-sig-hpc] randomForest and foreach plotting issue

Liaw, Andy andy_liaw at merck.com
Mon Oct 8 13:58:31 CEST 2012


The plot() method for randomForest plots the sequence of MSEs as trees are added to the ensemble sequentially.  Such numbers are impossible to compute when trees are grown in parallel.  That's why the combine() function removes those numbers when combining several randomForest objects into one.

Best,
Andy 

-----Original Message-----
From: r-sig-hpc-bounces at r-project.org [mailto:r-sig-hpc-bounces at r-project.org] On Behalf Of Matthew Gilbert
Sent: Sunday, October 07, 2012 2:21 PM
To: r-sig-hpc at r-project.org
Subject: [R-sig-hpc] randomForest and foreach plotting issue

Hi,

When I run randomForest sequentially I am able to plot the errors using 
plot() however when I try to perform randomForest within a foreach loop 
the resulting object throws errors when I try to plot it. mse seems to 
not be returned in the parallel structure. Has anyone run into this 
problem before? Below is an example of the issue

Thanks,
Matt

library(randomForest)
library(foreach)
library(doMC)
registerDoMC()

data(mtcars)
rf <- randomForest(mpg ~ ., mtcars, keep.forest=FALSE, ntree=100)
plot(rf)

rf.par <- foreach(ntree=rep(50, 2), .combine=combine, 
.packages='randomForest') %dopar% randomForest(mpg ~ ., mtcars, 
keep.forest=FALSE, ntree=ntree)
plot(rf.par)

Error in array(x, c(length(x), 1L), if (!is.null(names(x))) 
list(names(x),  :
   attempt to set an attribute on NULL

traceback()

7: array(x, c(length(x), 1L), if (!is.null(names(x))) list(names(x),
        NULL) else NULL)
6: as.matrix.default(y)
5: as.matrix(y)
4: ncol(y <- as.matrix(y))
3: matplot(1:x$ntree, err, type = type, xlab = "trees", ylab = "Error",
        main = main, ...)
2: plot.randomForest(rf.par)
1: plot(rf.par)

_______________________________________________
R-sig-hpc mailing list
R-sig-hpc at r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-hpc
Notice:  This e-mail message, together with any attachme...{{dropped:11}}



More information about the R-sig-hpc mailing list