Hi @mbanghart!
If you'd like to tune over mtry with simulated annealing, you can:
- set
counts = TRUE and then define a custom parameter set to param_info, or
- leave the
counts argument as its default and initially tune over a grid to initialize those upper limits before using simulated annealing
Here's some example code demonstrating tuning on mtry with simulated annealing.
library(tidymodels)
library(finetune)
data(penguins, package = "modeldata")
# as a proportion:
bt_tune_prop <-
boost_tree(mtry = tune()) %>%
set_engine(engine = "xgboost", counts = FALSE) %>%
set_mode(mode = "classification")
grid_anneal_prop <-
tune_sim_anneal(
bt_tune_prop,
species ~ flipper_length_mm + island,
bootstraps(penguins),
param_info =
extract_parameter_set_dials(bt_tune_prop) %>%
update(mtry = mtry_prop())
)
#>
#> ❯ Generating a set of 1 initial parameter results
#> ✓ Initialization complete
#>
#> Optimizing roc_auc
#> Initial best: 0.95642
#> 1 ◯ accept suboptimal roc_auc=0.95613 (+/-0.00232)
#> 2 ♥ new best roc_auc=0.9568 (+/-0.002101)
#> 3 ◯ accept suboptimal roc_auc=0.95566 (+/-0.002179)
#> 4 ♥ new best roc_auc=0.96007 (+/-0.002062)
#> 5 ♥ new best roc_auc=0.96007 (+/-0.002045)
#> 6 ♥ new best roc_auc=0.96185 (+/-0.002087)
#> 7 ◯ accept suboptimal roc_auc=0.96165 (+/-0.002138)
#> 8 ◯ accept suboptimal roc_auc=0.96149 (+/-0.002164)
#> 9 ♥ new best roc_auc=0.96191 (+/-0.001738)
#> 10 ◯ accept suboptimal roc_auc=0.96098 (+/-0.001949)
autoplot(grid_anneal_prop)

# as a count:
bt_tune_count <-
boost_tree(mtry = tune()) %>%
set_engine(engine = "xgboost") %>%
set_mode(mode = "classification")
grid <-
tune_grid(
bt_tune_count,
species ~ flipper_length_mm + island,
bootstraps(penguins)
)
#> i Creating pre-processing data to finalize unknown parameter: mtry
grid_anneal <-
tune_sim_anneal(
bt_tune_count,
species ~ flipper_length_mm + island,
bootstraps(penguins),
initial = grid
)
#> Optimizing roc_auc
#> Initial best: 0.96087
#> 1 ◯ accept suboptimal roc_auc=0.95825 (+/-0.001964)
#> 2 ◯ accept suboptimal roc_auc=0.95396 (+/-0.001823)
#> 3 ◯ accept suboptimal roc_auc=0.94992 (+/-0.001875)
#> 4 + better suboptimal roc_auc=0.95342 (+/-0.001994)
#> 5 ◯ accept suboptimal roc_auc=0.94992 (+/-0.001875)
#> 6 + better suboptimal roc_auc=0.95342 (+/-0.002041)
#> 7 ◯ accept suboptimal roc_auc=0.94992 (+/-0.001875)
#> 8 ✖ restart from best roc_auc=0.95408 (+/-0.002)
#> 9 ◯ accept suboptimal roc_auc=0.95773 (+/-0.001989)
#> 10 ◯ accept suboptimal roc_auc=0.95432 (+/-0.002001)
autoplot(grid_anneal)

Created on 2022-07-14 by the reprex package (v2.0.1)
If this doesn't do the trick for you, could you modify this code to demonstrate the functionality you're hoping to see?
Thanks!