使用 Automl - R 粘合和用于许多模型
Glue and For to many models with Automl - R
我想重现这段代码:
X_train_model1 <- data.table::fread("datasets_atualizados/dataset_y1.csv") %>%
h2o::as.h2o()
X_train_model2<- data.table::fread("datasets_atualizados/dataset_y2.csv") %>%
h2o::as.h2o()
#Model construction (20 different models)
model_automl <- h2o.automl(x = 1:11, y = 12, training_frame = X_train_model1,
max_models = 20, seed = 1)
# Save the model
# In this case the leaderboard model is StackedEnsemble_AllModels
model_path <- h2o.saveModel(object = model_automl@leader, path = "models", force=TRUE)
看起来像这样:
for (i in 1:2) {
#Exec the model
model_automl <- h2o.automl(x = 1:11, y = 12, training_frame = glue::glue("X_train_model", {i}),
max_models = 20, seed = 1)
#Saving the model
h2o.saveModel(object = model_automl@leader,
path = paste0("models", i),
force=TRUE)
}
我已经真诚地尝试了不同的形式,但我不总结这段代码。
你能帮帮我吗?
我认为 {i}
在您的代码中的位置不对,应该在字符串内:
for (i in 1:2) {
#Exec the model
model_automl <- h2o.automl(
x = 1:11,
y = 12,
training_frame = get(glue::glue("X_train_modelo{i}")),
max_models = 20,
seed = 1
)
#Saving the model
h2o.saveModel(object = model_automl@leader,
path = paste0("models", i),
force=TRUE)
}
我了解到您有多个 X_train_modelo
对象,因此您需要使用 get()
按名称引用它们。
我想重现这段代码:
X_train_model1 <- data.table::fread("datasets_atualizados/dataset_y1.csv") %>%
h2o::as.h2o()
X_train_model2<- data.table::fread("datasets_atualizados/dataset_y2.csv") %>%
h2o::as.h2o()
#Model construction (20 different models)
model_automl <- h2o.automl(x = 1:11, y = 12, training_frame = X_train_model1,
max_models = 20, seed = 1)
# Save the model
# In this case the leaderboard model is StackedEnsemble_AllModels
model_path <- h2o.saveModel(object = model_automl@leader, path = "models", force=TRUE)
看起来像这样:
for (i in 1:2) {
#Exec the model
model_automl <- h2o.automl(x = 1:11, y = 12, training_frame = glue::glue("X_train_model", {i}),
max_models = 20, seed = 1)
#Saving the model
h2o.saveModel(object = model_automl@leader,
path = paste0("models", i),
force=TRUE)
}
我已经真诚地尝试了不同的形式,但我不总结这段代码。 你能帮帮我吗?
我认为 {i}
在您的代码中的位置不对,应该在字符串内:
for (i in 1:2) {
#Exec the model
model_automl <- h2o.automl(
x = 1:11,
y = 12,
training_frame = get(glue::glue("X_train_modelo{i}")),
max_models = 20,
seed = 1
)
#Saving the model
h2o.saveModel(object = model_automl@leader,
path = paste0("models", i),
force=TRUE)
}
我了解到您有多个 X_train_modelo
对象,因此您需要使用 get()
按名称引用它们。