我在一个包含8个数字列(预测变量)和1个因子(结果)的数据集上运行随机林.数据集中有1.2M行.当我做:
randomForest(outcome.f ~ a + b + c + d + e + f + g + h,data=mdata)),我收到一个错误:
"Error in randomForest.default(m, y, ...) :
long vectors (argument 26) are not supported in .Fortran"
Run Code Online (Sandbox Code Playgroud)
有什么方法可以防止这种情况吗?我不明白为什么包(显然)试图分配长度为2 ^ 31-1的向量.我使用的是Mac OS X 10.9.2,带有Intel Core i7(如果架构很重要).
会话信息
R version 3.1.0 (2014-04-10)
Platform: x86_64-apple-darwin13.1.0 (64-bit)
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] randomForest_4.6-7
loaded via a namespace (and not attached):
[1] tools_3.1.0
Run Code Online (Sandbox Code Playgroud)
小智 7
永远不要在训练集上运行带有太多行的randomforest.
rf1 <- randomForest(Outcome ~ ., train[1:600000,], ntree=500, norm.votes=FALSE, do.trace=10,importance=TRUE)
rf2 <- randomForest(Outcome ~ ., train[600001:1200000,], ntree=500, norm.votes=FALSE, do.trace=10,importance=TRUE)
rf.combined <- combine(rf1,rf2)
Run Code Online (Sandbox Code Playgroud)
如果仍然出现错误,请尝试减小训练集的大小(例如500000或100000),分为rf1,rf2和rf3,然后将它们组合起来.希望能帮助到你.