rparametersgrid-searchmlr3r-ranger

Grid Search Hyperparameter Tuning of Ranger model with mlr3 R library


I ran the following grid search model using mlr3verse with ranger model.

task <- TaskClassif$new("df_cont_train.binary", df_cont_train, target = "label", positive = "1")

ss = ps(
  max.depth  = p_int(lower = 5, upper = 10)
)

instance = ti(
  task = task,
  learner = lrn("classif.ranger"),
  resampling = rsmp("cv", folds = 3),
  search_space = ss,
  terminator=trm("none")
)

tnr("grid_search")$optimize(instance)

However the problem that I am facing is that I can not find a way to run grid search, but only for max.depth=5 and max.depth=10.

Instead the grid search iterates through the whole range from 5 to 10 inclusive, making this 6 candidates in total instead of only 2.

Is it possible to fix this?


Solution

  • One way of doing this is with a trafo function:

    p_int(lower = 1, upper = 2, trafo = function(x) return 5*x)