Search code examples
rtidyversetidymodels

Creating a grid for hyperparameter tunning fixing some parameters


I have a grid_regular for a dt like this:

tree_grid <- grid_regular(cost_complexity(), tree_depth(), min_n())

However, I only want to use tree_depth in a certain range of values, let's say, 4 to 6, so the model can be easily plotted.

Basically fixing the top and bottom values for the min_n() parameter.

Is there any way to do it with tidymodels?


Solution

  • Inside the grid definition, you can easily set ranges for any parameter like this:

    tree_grid <- grid_regular(cost_complexity(),
                              tree_depth(
                                range = c(4L, 6L)
                                ),
                              min_n()
                              )