Convert a dials-style grid to greedy CI controls
Source:R/predict_ci_tree_terminal_mean.R
ci_dials_grid.RdConverts 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, aminsplitcolumn is used when present; otherwise2 * minbucketis used.- minbucket
Optional child-node sizes. If
NULL, aminbucketcolumn or dialsmin_ncolumn is used.- minprob
Minimum child-node weight proportions.
- maxdepth
Optional maximum tree depths. If
NULL, amaxdepthcolumn or dialstree_depthcolumn is used, falling back to theci_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, anmtrycolumn is used when present.- ntree
Optional numbers of trees for forest tuning. If
NULL, anntreeor dialstreescolumn is used when present.
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