Function to tune a mlr3::Learner.

## Usage

tune(
method,
learner,
resampling,
measures = NULL,
term_evals = NULL,
term_time = NULL,
search_space = NULL,
store_models = FALSE,
allow_hotstart = FALSE,
keep_hotstart_stack = FALSE,
...
)

## Arguments

method

(character(1) | Tuner)
Key to retrieve tuner from mlr_tuners dictionary or Tuner object.

learner

(mlr3::Learner)
Learner to tune.

resampling

(mlr3::Resampling)
Resampling that is used to evaluated the performance of the hyperparameter configurations. Uninstantiated resamplings are instantiated during construction so that all configurations are evaluated on the same data splits. Already instantiated resamplings are kept unchanged. Specialized Tuner change the resampling e.g. to evaluate a hyperparameter configuration on different data splits. This field, however, always returns the resampling passed in construction.

measures

(list of mlr3::Measure)
Measures to optimize.

term_evals

(integer(1))
Number of allowed evaluations.

term_time

(integer(1))
Maximum allowed time in seconds.

search_space

Hyperparameter search space. If NULL (default), the search space is constructed from the TuneToken of the learner's parameter set (learner$param_set). store_models (logical(1)) If TRUE, fitted models are stored in the benchmark result (archive$benchmark_result). If store_benchmark_result = FALSE, models are only stored temporarily and not accessible after the tuning. This combination is needed for measures that require a model.

allow_hotstart

(logical(1))
Allow to hotstart learners with previously fitted models. See also mlr3::HotstartStack. The learner must support hotstarting. Sets store_models = TRUE.

keep_hotstart_stack

(logical(1))
If TRUE, mlr3::HotstartStack is kept in $objective$hotstart_stack after tuning.

...

(named list())
Named arguments to be set as parameters of the tuner.

## Value

TuningInstanceSingleCrit | TuningInstanceMultiCrit

## Examples

learner = lrn("classif.rpart", cp = to_tune(1e-04, 1e-1, logscale = TRUE))

instance = tune(
method = "random_search",
learner$param_set$values = instance\$result_learner_param_vals