The AutoTuner is a mlr3::Learner which auto-tunes by first tuning the hyperparameters of its encapsulated learner on the training data, then setting the optimal configuration in the learner, then finally fitting the model on the complete training data. Note that this class allows to perform nested resampling by passing an AutoTuner object to mlr3::resample() or mlr3::benchmark().

Format

R6::R6Class object inheriting from mlr3::Learner.

Construction

at = AutoTuner$new(learner, resampling, measures, tune_ps, terminator, tuner, bm_args = list())

Fields

All fields from Learner, and additionally:

  • instance_args :: list All arguments from construction to create the TuningInstance.

  • tuner :: Tuner; from construction.

  • store_tuning_instance :: logical(1)
    If TRUE, stores the internally created TuningInstance with all intermediate results in slot $tuning_instance. By default, this is TRUE.

  • learner :: mlr3::Learner Trained learner

  • tuning_instance :: TuningInstance
    Internally created tuning instance with all intermediate results.

  • tuning_result :: named list
    Short-cut to result from TuningInstance.

Methods

All methods from Learner, and additionally:

Examples

library(mlr3) library(paradox) task = tsk("iris") learner = lrn("classif.rpart") resampling = rsmp("holdout") measures = msr("classif.ce") param_set = ParamSet$new( params = list(ParamDbl$new("cp", lower = 0.001, upper = 0.1))) terminator = term("evals", n_evals = 5) tuner = tnr("grid_search") at = AutoTuner$new(learner, resampling, measures, param_set, terminator, tuner) at$store_tuning_instance = TRUE at$train(task) at$model
#> $learner #> <LearnerClassifRpart:classif.rpart> #> * Model: rpart #> * Parameters: xval=0, cp=0.045 #> * Packages: rpart #> * Predict Type: response #> * Feature types: logical, integer, numeric, factor, ordered #> * Properties: importance, missings, multiclass, selected_features, #> twoclass, weights #> #> $tuning_instance #> <TuningInstance> #> * Task: <TaskClassif:iris> #> * Learner: <LearnerClassifRpart:classif.rpart> #> * Measures: classif.ce #> * Resampling: <ResamplingHoldout> #> * Terminator: <TerminatorEvals> #> * bm_args: list() #> ParamSet: #> id class lower upper levels default value #> 1: cp ParamDbl 0.001 0.1 <NoDefault> #> Archive: #> nr batch_nr resample_result task_id learner_id resampling_id iters #> 1: 1 1 <ResampleResult> iris classif.rpart holdout 1 #> 2: 2 2 <ResampleResult> iris classif.rpart holdout 1 #> 3: 3 3 <ResampleResult> iris classif.rpart holdout 1 #> 4: 4 4 <ResampleResult> iris classif.rpart holdout 1 #> 5: 5 5 <ResampleResult> iris classif.rpart holdout 1 #> params tune_x warnings errors classif.ce #> 1: <list> <list> 0 0 0.06 #> 2: <list> <list> 0 0 0.06 #> 3: <list> <list> 0 0 0.06 #> 4: <list> <list> 0 0 0.06 #> 5: <list> <list> 0 0 0.06 #>
at$learner
#> <LearnerClassifRpart:classif.rpart> #> * Model: rpart #> * Parameters: xval=0, cp=0.045 #> * Packages: rpart #> * Predict Type: response #> * Feature types: logical, integer, numeric, factor, ordered #> * Properties: importance, missings, multiclass, selected_features, #> twoclass, weights