Learn R Programming

mlr3tuning (version 0.9.0)

tune: Function for Tuning

Description

Function to tune a mlr3::Learner.

Usage

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

Arguments

method

(character(1)) Key to retrieve tuner from mlr_tuners dictionary.

task

(mlr3::Task) Task to operate on.

learner
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. If NULL, mlr3's default measure is used.

term_evals

(integer(1)) Number of allowed evaluations.

term_time

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

search_space

(paradox::ParamSet) Hyperparameter search space. If NULL, the search space is constructed from the TuneToken in the ParamSet of the learner.

store_models

(logical(1)) If FALSE (default), the fitted models are not stored in the mlr3::BenchmarkResult. If store_benchmark_result = FALSE, the models are only stored temporarily and not accessible after the tuning. This combination might be useful for measures that require a model.

...

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

Value

TuningInstanceSingleCrit | TuningInstanceMultiCrit

Examples

Run this code
# NOT RUN {
learner = lrn("classif.rpart", cp = to_tune(1e-04, 1e-1, logscale = TRUE))

instance = tune(
  method = "random_search", 
  task = tsk("pima"), 
  learner = learner, 
  resampling = rsmp ("holdout"), 
  measures = msr("classif.ce"), 
  term_evals = 4) 

# apply hyperparameter values to learner
learner$param_set$values = instance$result_learner_param_vals
# }

Run the code above in your browser using DataLab