【发布时间】:2013-06-07 19:03:51
【问题描述】:
我正在使用具有 114954 行和 135 列(预测变量)的训练数据训练随机森林。我收到以下错误。
model <- randomForest(u_b_stars~. ,data=traindata,importance=TRUE,do.trace=100, keep.forest=TRUE, mtry=30)
Error: cannot allocate vector of size 877.0 Mb
In addition: Warning messages:
1: In randomForest.default(m, y, ...) :
The response has five or fewer unique values. Are you sure you want to do regression?
2: In matrix(double(nrnodes * nt), ncol = nt) :
Reached total allocation of 3958Mb: see help(memory.size)
3: In matrix(double(nrnodes * nt), ncol = nt) :
Reached total allocation of 3958Mb: see help(memory.size)
4: In matrix(double(nrnodes * nt), ncol = nt) :
Reached total allocation of 3958Mb: see help(memory.size)
5: In matrix(double(nrnodes * nt), ncol = nt) :
Reached total allocation of 3958Mb: see help(memory.size)
我想知道我该怎么做才能避免这个错误?我应该用更少的数据训练它吗?但这当然不好。有人可以提出一个替代方案,我不必从训练数据中提取更少的数据。我想使用完整的训练数据。
【问题讨论】:
-
您的数据太大而无法放入内存。因此:1) 购买内存,2) 将数据拆分并训练多个模型,最终预测可以计算为所有模型输出的平均值(在按专业投票分类的情况下)。
-
对于大型数据集,h20 显然是要走的路,r-bloggers.com/benchmarking-random-forest-implementations,您也可以从 R 中将它与 library(h2o) 一起使用
-
或者 xgboost,你也可以从 R 和 library(xgboost) 中使用它
标签: r machine-learning random-forest