Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Grid search with early stopping in h2o GLM
# Define hyperparameter spaces and search criteria for random grid search
GLM_params1 <- list(alpha = seq(0,1,.05),lambda = 10^seq(-7,3,0.5)) # array of values for both alpha and lambda
GLM_searchCriteria1 <- list(strategy = "RandomDiscrete", max_runtime_secs = 300) # randomly choose combinations, train no longer than 5mins
# Train models using the parameters above until the runtime limit is reached
# Save the models and their prediction scores on the validation frame in a grid, for access later
GLMgrid <- h2o.grid(algorithm = "glm", grid_id = "GLM_grid1", x = x,
y = y, training_frame = train, validation_frame = valid,
hyper_params = GLM_params1, search_criteria = GLM_searchCriteria1, seed = 1234)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment