I'm trying to save all the models from an h2o.automl
as part of the h2o
package. Currently I am able to save a single model using h2o.saveModel(aml@leader, path = "/home/data/user")
.
How can I save all the models?
Here is my attempt on a sample dataset:
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")
Get data from github or import via 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")
)
Now I'm trying to save the models within aml
:
mod_ids <- as_tibble(aml@leaderboard$model_id)
Now I can't figure out how to save the models:
for(i in 1:nrow(mod_ids)) {
print(mod_ids[i,])
#h2o.saveModel(object = aml@leaderboard[[i]], "/home/data/user/")
}
Here is what I've tried:
H2O AUTOML: How to save reuse and build on top of existing automl models