Aan de slagGa gratis aan de slag

Random search with h2o

Next, you will use random search. The h2o library and seeds_train_data have already been loaded for you and the following code has been run:

h2o.init()
seeds_train_data_hf <- as.h2o(seeds_train_data)

y <- "seed_type"
x <- setdiff(colnames(seeds_train_data_hf), y)

seeds_train_data_hf[, y] <- as.factor(seeds_train_data_hf[, y])

sframe <- h2o.splitFrame(seeds_train_data_hf, seed = 42)
train <- sframe[[1]]
valid <- sframe[[2]]

dl_params <- list(hidden = list(c(50, 50), c(100, 100)),
                  epochs = c(5, 10, 15),
                  rate = c(0.001, 0.005, 0.01))

Deze oefening maakt deel uit van de cursus

Hyperparameter Tuning in R

Cursus bekijken

Oefeninstructies

  • Define a search criteria object that defines random search with a maximum runtime of 10 seconds.
  • Add this search criteria object at the appropriate place in the h2o.grid function to train the random models.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Define search criteria
search_criteria <- list(strategy = ___, 
                        ___ = 10, # this is way too short & only used to keep runtime short!
                        seed = 42)

# Train with random search
dl_grid <- h2o.grid("deeplearning", 
                    grid_id = "dl_grid",
                    x = x, 
                    y = y,
                    training_frame = train,
                    validation_frame = valid,
                    seed = 42,
                    hyper_params = dl_params,
                    ___ = ___)
Code bewerken en uitvoeren