Skip to contents

Converts a data frame produced by tools such as dials::grid_regular() into the control-grid columns expected by tune_ci_tree() and tune_ci_forest(). The helper keeps ineqTrees independent of tidymodels while making common dials names usable in package tuning workflows.

Recognized input columns are min_n or minbucket, tree_depth or maxdepth, mtry, trees or ntree, minsplit, minprob, and min_gain, and min_relative_gain. When minsplit is not supplied, it defaults to twice the child node size (minbucket), which is a common starting point for binary splits.

Usage

ci_dials_grid(
  grid,
  minsplit = NULL,
  minbucket = NULL,
  minprob = 0.01,
  maxdepth = NULL,
  min_gain = 0,
  min_relative_gain = 0,
  mtry = NULL,
  ntree = NULL
)

Arguments

grid

A data frame or tibble, typically from dials::grid_regular().

minsplit

Optional parent-node sizes. If NULL, a minsplit column is used when present; otherwise 2 * minbucket is used.

minbucket

Optional child-node sizes. If NULL, a minbucket column or dials min_n column is used.

minprob

Minimum child-node weight proportions.

maxdepth

Optional maximum tree depths. If NULL, a maxdepth column or dials tree_depth column is used, falling back to the ci_tree_control() default.

min_gain

Minimum concentration-index gains required for a split.

min_relative_gain

Local split-stopping thresholds: minimum concentration-index gains as a share of parent-node impurity required for a split.

mtry

Optional numbers of variables sampled at each split. If NULL, an mtry column is used when present.

ntree

Optional numbers of trees for forest tuning. If NULL, an ntree or dials trees column is used when present.

Value

A data.table with one row per candidate control setting.

Examples

if (requireNamespace("dials", quietly = TRUE)) {
  dials_grid <- dials::grid_regular(
    dials::mtry(range = c(2L, 4L)),
    dials::min_n(range = c(20L, 60L)),
    dials::tree_depth(range = c(2L, 3L)),
    levels = 2L
  )

  ci_dials_grid(dials_grid, minprob = 0.05, ntree = 10L)
}
#>    minsplit minbucket minprob maxdepth min_gain min_relative_gain  mtry ntree
#>       <int>     <int>   <num>    <int>    <num>             <num> <int> <int>
#> 1:       40        20    0.05        2        0                 0     2    10
#> 2:       40        20    0.05        2        0                 0     4    10
#> 3:      120        60    0.05        2        0                 0     2    10
#> 4:      120        60    0.05        2        0                 0     4    10
#> 5:       40        20    0.05        3        0                 0     2    10
#> 6:       40        20    0.05        3        0                 0     4    10
#> 7:      120        60    0.05        3        0                 0     2    10
#> 8:      120        60    0.05        3        0                 0     4    10