if (FALSE) {
# Example: Create a hyperparameter grid for GBM models.
predictors <- c("var1", "var2", "var3")
response <- "target"
# Define hyperparameter ranges
hyper_params <- list(
ntrees = seq(50, 150, by = 25),
max_depth = c(5, 10, 15),
learn_rate = c(0.01, 0.05, 0.1),
sample_rate = c(0.8, 1.0),
col_sample_rate = c(0.8, 1.0)
)
# Run the grid search
grid <- hmda.grid(
algorithm = "gbm",
x = predictors,
y = response,
training_frame = h2o.getFrame("hmda.train.hex"),
hyper_params = hyper_params,
nfolds = 10,
stopping_metric = "AUTO"
)
# Assess the performances of the models
grid_performance <- hmda.grid.analysis(grid)
# plot the metrics of models that are within 95% of the best models
# for each of the specified metrics
hmda.plot.metrics(grid_performance,
criteria = "distance_percentage",
distance_percentage = 0.95,
metrics = c("auc", "aucpr", "r2", "mcc", "f2"))
}
Run the code above in your browser using DataLab