if (rlang::is_installed("ggplot2")) {
library(ggplot2)
# Most boosting methods can make many predictions across a number of trees
# from a single model fit object. Those are nearly free (computationally) so
# we would do many tree values for each of the other parameters.
# To illustrate, we'll only show four tree values:
boost_example <-
parameters(list(trees = trees(), learn_rate = learn_rate(), min_n = min_n()))
boost_example |>
grid_hybrid(reg_parameters = trees, sfd_size = 20, reg_levels = 4) |>
ggplot(aes(learn_rate, min_n)) +
geom_point() +
facet_wrap(~ trees, labeller = "label_both") +
scale_x_log10()
# In other cases, we have 1+ parameters with very few values. We can make a
# small regular grid over these and a much larger space-filling design
nnet_example <-
parameters(
list(
learn_rate = learn_rate(),
dropout = dropout(),
# Only a few values:
activation = activation(c("relu", "tanh", "elu")),
schedule = rate_schedule(c("none", "cyclic", "step")) # note different name
)
)
nnet_example |>
grid_hybrid(
reg_parameters = c(activation, schedule),
sfd_size = 20,
reg_levels = 3
) |>
ggplot(aes(learn_rate, dropout)) +
geom_point() +
facet_grid(activation ~ schedule, labeller = "label_both") +
scale_x_log10()
}
Run the code above in your browser using DataLab