I run a non-parallel randomForest object with no problem like this:
> rf <- randomForest(t2[,-c(1,2,7,12)],t2[,2],
+ ,sampsize=c(10000),do.trace=F,importance=TRUE,ntree=1,,forest=TRUE)
Warning message:
In randomForest.default(t2[, -c(1, 2, 7, 12)], t2[, 2], , sampsize = c(10000), :
The response has five or fewer unique values. Are you sure you want to do regression?
> rf
Call:
randomForest(x = t2[, -c(1, 2, 7, 12)], y = t2[, 2], ntree = 1, sampsize = c(10000), importance = TRUE, do.trace = F, forest = TRUE)
Type of random forest: regression
Number of trees: 1
No. of variables tried at each split: 2
Mean of squared residuals: 0.07444926
% Var explained: -19.36
> rf$rsq
[1] -0.1936248
Now I run the same code using parallel stuff and get no MSE or % Var Explained:
> library("foreach")
> library("doSNOW")
> registerDoSNOW(makeCluster(2, type="SOCK"))
>
>
>
> rf <- foreach(ntree = rep(1, 2), .combine = combine, .packages = "randomForest") %dopar%
+ randomForest(t2[,-c(1,2,7,12)],t2[,2],
+ ,sampsize=c(10000),do.trace=F,importance=TRUE,ntree=1,,forest=TRUE)
> rf
Call:
randomForest(x = t2[, -c(1, 2, 7, 12)], y = t2[, 2], ntree = 1, sampsize = c(10000), importance = TRUE, do.trace = F, forest = TRUE)
Type of random forest: regression
Number of trees: 2
No. of variables tried at each split: 2
> rf$rsq
NULL
Any idea what I’m doing wrong? Thanks.
Its not the parallel bits, its the use of
combinefrom the randomForest package. Quoting?combine:So you’ll have to calculate that stuff yourself using the predicted values.