繁体   English   中英

并行随机森林缺少MSE和R平方

[英]Parallel random Forest missing MSE and R-squared

我运行一个非并行randomForest对象,没有这样的问题:

> 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或%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

知道我在做什么错吗? 谢谢。

它不是并行位,其使用的combine从随机森林包。 引用?combine

组合对象的混淆,err.rate,mse和rsq组件(以及测试组件中的相应组件,如果存在)将为NULL。

因此,您必须使用预测值自己计算出这些东西。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM