I want to train a classification model by random forest with the help of h2o on R studio. I want to find an optimum grid using h2o.grid
during hyperparameter tuning. But I was answered like this:
ERROR MESSAGES: Illegal argument: training_frame of function: grid: Cannot append new models to a grid with different training input
My codes are as follows:
{r}
h2o.init(max_mem_size="8g")
n_features <- length(setdiff(names(GDM_train),'label'))
train_h2o <- as.h2o(GDM_train)
response <- "label"
preds <- setdiff(colnames(GDM_train),response)
hyper_grid <- list(
mtries=floor(n_features*c(0.15,0.16,0.17,0.18,0.20)),
min_rows=c(1,3,5,10),
max_depth=c(10,20,30),
sample_rate=c(0.6,0.65,0.7,0.75)
)
#random grid search strategy
search_criteria <- list(
strategy="RandomDiscrete",
stopping_metric="mse",
stopping_tolerance=0.01,
stopping_rounds=10,
max_runtime_secs=60*90
)
#perform grid search
random_grid <- h2o.grid(
algorithm="randomForest",
grid_id="rf_random_grid",
x=preds,
y=response,
training_frame=train_h2o,
hyper_params=hyper_grid,
ntrees=n_features*10,
seed=20230412,
stopping_metric="mse",
stopping_rounds=10,
stopping_tolerance=0.01,
search_criteria=search_criteria
)
How can I fix this problem?
Thanks for answering.