gpt4 book ai didi

r - 如何从 h2o automl 保存所有模型

转载 作者:行者123 更新时间:2023-12-04 12:06:38 25 4
gpt4 key购买 nike

我正在尝试保存 全部 来自 h2o.automl 的模型作为 h2o 的一部分包裹。目前我可以使用 h2o.saveModel(aml@leader, path = "/home/data/user") 保存单个模型.

如何保存 全部 模型?

这是我对示例数据集的尝试:

 library(h2o)
h2o.init()
prostate.hex <- h2o.importFile(path = paste("https://raw.github.com",
"h2oai/h2o-2/master/smalldata/logreg/prostate.csv", sep = "/"),
destination_frame = "prostate.hex")

从 github 获取数据或通过 readr 导入:
 library(readr)
prostate <- read_csv("/home/data/user/prostate.csv")

prostate.hex<- as.h2o(prostate, "prostate.hex")

aml <- h2o.automl(y = "CAPSULE", x = c("AGE","RACE","PSA","DCAPS"),
training_frame = prostate.hex,
max_runtime_secs = 180,
exclude_algos = c("StackedEnsemble")
)

现在我正在尝试将模型保存在 aml 内:
mod_ids <- as_tibble(aml@leaderboard$model_id)

现在我不知道如何保存模型:
 for(i in 1:nrow(mod_ids)) {
print(mod_ids[i,])
#h2o.saveModel(object = aml@leaderboard[[i]], "/home/data/user/")
}

这是我尝试过的:

tutorial automl

H2O AUTOML: How to save reuse and build on top of existing automl models

最佳答案

试试这个,它会做你的工作:

 for(i in 1:nrow(mod_ids)) {

aml1 <- h2o.getModel(aml@leaderboard[i, 1]) # get model object in environment
h2o.saveModel(object = aml1, "C:/Users/sm/Documents/stack/models") # pass that model object to h2o.saveModel as an argument

}

关于r - 如何从 h2o automl 保存所有模型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52298858/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com