我喜欢使用R. https://cran.r-project.org/web/packages/h2o/h2o.pdf进行机器学习的h2o.ai
我喜欢随机森林,但我在一个循环中做了几千个预测。像这样的事情会让我的记忆变得混乱:

我不能把它们都保存在内存中。我让我那台非常好的电脑非常努力地工作。这意味着它没有能力一次将所有的球都举到空中。
如果我可以为预测指定一个目标帧名称,那么每个新帧都会覆盖旧帧。
在对象上执行"h2o.predict“时,如何分配目标帧名称?
我尝试过的东西都不起作用:
h2o.predict(object = rf.hex, newdata = test.hex, predictions_frame = "predict.hex")
h2o.predict(object = rf.hex, newdata = test.hex, destination_frame = "predict.hex")
h2o.predict(object = rf.hex, newdata = test.hex, model_id = "predict.hex")发布于 2019-08-01 16:36:56
据我所知没有办法。
但是作为另一种选择,在您的循环中,您可以在h2o.predict()的返回值上调用h2o.rm()。也值得调用h2o.gc()。类似于:
for(data in alldata){
# ... prepare newdata
p = h2o.predict(model, newdata)
# ... do something with p here
h2o.rm(p)
h2o.rm(newdata) # If also not needed any more
h2o.gc()
}旁白:你说“我在一个循环中做了几千个预测”。假设它们都是针对同一模型的,请记住,您可以对它们进行批量处理,并在单个newdata数据帧中给出所有数千个预测。一次调用包含1000个条目的h2o.predict()比进行1000个h2o.predict()调用(一次调用一个newdata条目)要高效得多。
https://stackoverflow.com/questions/57273916
复制相似问题