Skip to contents

The hyper parameter grid can either be provided with this function or all at once later on with rpwf_augment()

Usage

set_r_grid(obj, grid_fun, hyper_par_fun = NULL, ...)

Arguments

obj

a model spec object generated by parsnip::set_engine() and parsnip::set_mode().

grid_fun

a dials::grid_<functions>, e.g., grid_random(), grid_latin_hypercube().

hyper_par_fun

update dials functions such as dials::penalty() and dials::cost() with a named list. See examples.

...

arguments to pass to grid_fun.

Value

Add the {dials} function and associated arguments to the model spec

Examples

m <- parsnip::boost_tree() |>
  parsnip::set_engine("xgboost") |>
  parsnip::set_mode("classification") |>
  set_r_grid(dials::grid_random, list(trees = dials::trees(range = c(2, 3))), size = 5)
m$grid_fun
#> function (x, ..., size = 5, original = TRUE, filter = NULL) 
#> {
#>     dots <- list(...)
#>     if (any(names(dots) == "levels")) {
#>         rlang::warn("`levels` is not an argument to `grid_random()`. Did you mean `size`?")
#>     }
#>     UseMethod("grid_random")
#> }
#> <bytecode: 0x563c732f81a0>
#> <environment: namespace:dials>
m$grid_fun_args
#> $size
#> [1] 5
#>