2011-10-24 87 views
1

我運行一個非平行隨機森林的對象,像這樣沒有問題:並行隨機森林失蹤MSE和R平方

> 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 

現在我使用並行的東西運行相同的代碼,並沒有得到MSE或%無功解釋:

> 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 

任何想法我做錯了什麼?謝謝。

回答

7

它不是平行位,它使用randomForest包中的combine。引述?combine

混亂,err.rate,MSE和RSQ部件(以及在測試構成元素的 相應的部件,如果存在的話)的組合 對象將是NULL。

所以你必須使用預測值自己計算這些東西。

+0

非常感謝。 – screechOwl