[R-sig-hpc] randomForest and foreach plotting issue
Matthew Gilbert
matthew.douglas.gilbert at gmail.com
Sun Oct 7 20:20:54 CEST 2012
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)
More information about the R-sig-hpc
mailing list