3.1 Hyperparameter Tuning

Hyperparameters are second-order parameters of machine learning models that, while often not explicitly optimized during the model estimation process, can have important impacts on the outcome and predictive performance of a model. Typically, hyperparameters are fixed before training a model. However, because the output of a model can be sensitive to the specification of hyperparameters, it is often recommended to make an informed decision about which hyperparameter settings may yield better model performance. In many cases, hyperparameter settings may be chosen a priori, but it can be advantageous to try different settings before fitting your model on the training data. This process is often called ‘tuning’ your model.

Hyperparameter tuning is supported via the extension package mlr3tuning. Below you can find an illustration of the process:

At the heart of mlr3tuning are the R6 classes:

3.1.1 The TuningInstance Classes

The following sub-section examines the optimization of a simple classification tree on the Pima Indian Diabetes data set.

## <TaskClassif:pima> (768 x 9)
## * Target: diabetes
## * Properties: twoclass
## * Features (8):
##   - dbl (8): age, glucose, insulin, mass, pedigree, pregnant, pressure,
##     triceps

We use the classification tree from rpart and choose a subset of the hyperparameters we want to tune. This is often referred to as the “tuning space”.

## <ParamSet>
##                id    class lower upper levels     default value
## 1:       minsplit ParamInt     1   Inf                 20      
## 2:      minbucket ParamInt     1   Inf        <NoDefault>      
## 3:             cp ParamDbl     0     1               0.01      
## 4:     maxcompete ParamInt     0   Inf                  4      
## 5:   maxsurrogate ParamInt     0   Inf                  5      
## 6:       maxdepth ParamInt     1    30                 30      
## 7:   usesurrogate ParamInt     0     2                  2      
## 8: surrogatestyle ParamInt     0     1                  0      
## 9:           xval ParamInt     0   Inf                 10     0

Here, we opt to tune two parameters:

  • The complexity cp
  • The termination criterion minsplit

The tuning space has to be bound, therefore one has to set lower and upper bounds:

## <ParamSet>
##          id    class lower upper levels     default value
## 1:       cp ParamDbl 0.001   0.1        <NoDefault>      
## 2: minsplit ParamInt 1.000  10.0        <NoDefault>

Next, we need to specify how to evaluate the performance. For this, we need to choose a resampling strategy and a performance measure.

Finally, one has to select the budget available, to solve this tuning instance. This is done by selecting one of the available Terminators:

For this short introduction, we specify a budget of 20 evaluations and then put everything together into a TuningInstanceSingleCrit:

## <TuningInstanceSingleCrit>
## * State:  Not optimized
## * Objective: <ObjectiveTuning:classif.rpart_on_pima>
## * Search Space:
## <ParamSet>
##          id    class lower upper levels     default value
## 1:       cp ParamDbl 0.001   0.1        <NoDefault>      
## 2: minsplit ParamInt 1.000  10.0        <NoDefault>      
## * Terminator: <TerminatorEvals>
## * Terminated: FALSE
## * Archive:
## <Archive>
## Null data.table (0 rows and 0 cols)

To start the tuning, we still need to select how the optimization should take place. In other words, we need to choose the optimization algorithm via the Tuner class.

3.1.2 The Tuner Class

The following algorithms are currently implemented in mlr3tuning:

In this example, we will use a simple grid search with a grid resolution of 5.

Since we have only numeric parameters, TunerGridSearch will create an equidistant grid between the respective upper and lower bounds. As we have two hyperparameters with a resolution of 5, the two-dimensional grid consists of \(5^2 = 25\) configurations. Each configuration serves as hyperparameter setting for the previously defined Learner and triggers a 3-fold cross validation on the task. All configurations will be examined by the tuner (in a random order), until either all configurations are evaluated or the Terminator signals that the budget is exhausted.

3.1.3 Triggering the Tuning

To start the tuning, we simply pass the TuningInstanceSingleCrit to the $optimize() method of the initialized Tuner. The tuner proceeds as follows:

  1. The Tuner proposes at least one hyperparameter configuration (the Tuner may propose multiple points to improve parallelization, which can be controlled via the setting batch_size).
  2. For each configuration, the given Learner is fitted on the Task using the provided Resampling. All evaluations are stored in the archive of the TuningInstanceSingleCrit.
  3. The Terminator is queried if the budget is exhausted. If the budget is not exhausted, restart with 1) until it is.
  4. Determine the configuration with the best observed performance.
  5. Store the best configurations as result in the instance object. The best hyperparameter settings ($result_learner_param_vals) and the corresponding measured performance ($result_y) can be acessed from the instance.
## INFO  [01:49:39.853] Starting to optimize 2 parameter(s) with '<OptimizerGridSearch>' and '<TerminatorEvals>' 
## INFO  [01:49:39.885] Evaluating 1 configuration(s) 
## INFO  [01:49:40.022] Result of batch 1: 
## INFO  [01:49:40.024]   cp minsplit classif.ce  resample_result 
## INFO  [01:49:40.024]  0.1        5     0.2891 <ResampleResult> 
## INFO  [01:49:40.025] Evaluating 1 configuration(s) 
## INFO  [01:49:40.101] Result of batch 2: 
## INFO  [01:49:40.103]       cp minsplit classif.ce  resample_result 
## INFO  [01:49:40.103]  0.02575        3     0.2539 <ResampleResult> 
## INFO  [01:49:40.104] Evaluating 1 configuration(s) 
## INFO  [01:49:40.149] Result of batch 3: 
## INFO  [01:49:40.150]       cp minsplit classif.ce  resample_result 
## INFO  [01:49:40.150]  0.07525        1     0.2891 <ResampleResult> 
## INFO  [01:49:40.152] Evaluating 1 configuration(s) 
## INFO  [01:49:40.198] Result of batch 4: 
## INFO  [01:49:40.199]     cp minsplit classif.ce  resample_result 
## INFO  [01:49:40.199]  0.001        1     0.2734 <ResampleResult> 
## INFO  [01:49:40.201] Evaluating 1 configuration(s) 
## INFO  [01:49:40.248] Result of batch 5: 
## INFO  [01:49:40.249]   cp minsplit classif.ce  resample_result 
## INFO  [01:49:40.249]  0.1        8     0.2891 <ResampleResult> 
## INFO  [01:49:40.251] Evaluating 1 configuration(s) 
## INFO  [01:49:40.295] Result of batch 6: 
## INFO  [01:49:40.297]       cp minsplit classif.ce  resample_result 
## INFO  [01:49:40.297]  0.07525        3     0.2891 <ResampleResult> 
## INFO  [01:49:40.298] Evaluating 1 configuration(s) 
## INFO  [01:49:40.343] Result of batch 7: 
## INFO  [01:49:40.345]   cp minsplit classif.ce  resample_result 
## INFO  [01:49:40.345]  0.1        1     0.2891 <ResampleResult> 
## INFO  [01:49:40.346] Evaluating 1 configuration(s) 
## INFO  [01:49:40.395] Result of batch 8: 
## INFO  [01:49:40.397]      cp minsplit classif.ce  resample_result 
## INFO  [01:49:40.397]  0.0505        1     0.2891 <ResampleResult> 
## INFO  [01:49:40.399] Evaluating 1 configuration(s) 
## INFO  [01:49:40.446] Result of batch 9: 
## INFO  [01:49:40.448]     cp minsplit classif.ce  resample_result 
## INFO  [01:49:40.448]  0.001        8     0.2891 <ResampleResult> 
## INFO  [01:49:40.449] Evaluating 1 configuration(s) 
## INFO  [01:49:40.497] Result of batch 10: 
## INFO  [01:49:40.499]   cp minsplit classif.ce  resample_result 
## INFO  [01:49:40.499]  0.1       10     0.2891 <ResampleResult> 
## INFO  [01:49:40.501] Evaluating 1 configuration(s) 
## INFO  [01:49:40.549] Result of batch 11: 
## INFO  [01:49:40.551]       cp minsplit classif.ce  resample_result 
## INFO  [01:49:40.551]  0.02575       10     0.2539 <ResampleResult> 
## INFO  [01:49:40.552] Evaluating 1 configuration(s) 
## INFO  [01:49:40.597] Result of batch 12: 
## INFO  [01:49:40.598]   cp minsplit classif.ce  resample_result 
## INFO  [01:49:40.598]  0.1        3     0.2891 <ResampleResult> 
## INFO  [01:49:40.600] Evaluating 1 configuration(s) 
## INFO  [01:49:40.645] Result of batch 13: 
## INFO  [01:49:40.646]      cp minsplit classif.ce  resample_result 
## INFO  [01:49:40.646]  0.0505        8     0.2891 <ResampleResult> 
## INFO  [01:49:40.648] Evaluating 1 configuration(s) 
## INFO  [01:49:40.695] Result of batch 14: 
## INFO  [01:49:40.696]       cp minsplit classif.ce  resample_result 
## INFO  [01:49:40.696]  0.07525       10     0.2891 <ResampleResult> 
## INFO  [01:49:40.698] Evaluating 1 configuration(s) 
## INFO  [01:49:40.743] Result of batch 15: 
## INFO  [01:49:40.745]       cp minsplit classif.ce  resample_result 
## INFO  [01:49:40.745]  0.02575        1     0.2539 <ResampleResult> 
## INFO  [01:49:40.746] Evaluating 1 configuration(s) 
## INFO  [01:49:40.792] Result of batch 16: 
## INFO  [01:49:40.797]      cp minsplit classif.ce  resample_result 
## INFO  [01:49:40.797]  0.0505        5     0.2891 <ResampleResult> 
## INFO  [01:49:40.799] Evaluating 1 configuration(s) 
## INFO  [01:49:40.844] Result of batch 17: 
## INFO  [01:49:40.845]     cp minsplit classif.ce  resample_result 
## INFO  [01:49:40.845]  0.001        5     0.2852 <ResampleResult> 
## INFO  [01:49:40.847] Evaluating 1 configuration(s) 
## INFO  [01:49:40.893] Result of batch 18: 
## INFO  [01:49:40.895]     cp minsplit classif.ce  resample_result 
## INFO  [01:49:40.895]  0.001        3     0.2773 <ResampleResult> 
## INFO  [01:49:40.897] Evaluating 1 configuration(s) 
## INFO  [01:49:40.945] Result of batch 19: 
## INFO  [01:49:40.947]      cp minsplit classif.ce  resample_result 
## INFO  [01:49:40.947]  0.0505       10     0.2891 <ResampleResult> 
## INFO  [01:49:40.948] Evaluating 1 configuration(s) 
## INFO  [01:49:40.992] Result of batch 20: 
## INFO  [01:49:40.993]       cp minsplit classif.ce  resample_result 
## INFO  [01:49:40.993]  0.02575        5     0.2539 <ResampleResult> 
## INFO  [01:49:40.998] Finished optimizing after 20 evaluation(s) 
## INFO  [01:49:40.999] Result: 
## INFO  [01:49:41.000]       cp minsplit learner_param_vals x_domain classif.ce 
## INFO  [01:49:41.000]  0.02575        3             <list>   <list>     0.2539
## $xval
## [1] 0
## 
## $cp
## [1] 0.02575
## 
## $minsplit
## [1] 3
## classif.ce 
##     0.2539

One can investigate all resamplings which were undertaken, as they are stored in the archive of the TuningInstanceSingleCrit and can be accessed through $data() method:

##          cp minsplit classif.ce  resample_result x_domain           timestamp
##  1: 0.10000        5     0.2891 <ResampleResult>   <list> 2020-07-12 01:49:40
##  2: 0.02575        3     0.2539 <ResampleResult>   <list> 2020-07-12 01:49:40
##  3: 0.07525        1     0.2891 <ResampleResult>   <list> 2020-07-12 01:49:40
##  4: 0.00100        1     0.2734 <ResampleResult>   <list> 2020-07-12 01:49:40
##  5: 0.10000        8     0.2891 <ResampleResult>   <list> 2020-07-12 01:49:40
##  6: 0.07525        3     0.2891 <ResampleResult>   <list> 2020-07-12 01:49:40
##  7: 0.10000        1     0.2891 <ResampleResult>   <list> 2020-07-12 01:49:40
##  8: 0.05050        1     0.2891 <ResampleResult>   <list> 2020-07-12 01:49:40
##  9: 0.00100        8     0.2891 <ResampleResult>   <list> 2020-07-12 01:49:40
## 10: 0.10000       10     0.2891 <ResampleResult>   <list> 2020-07-12 01:49:40
## 11: 0.02575       10     0.2539 <ResampleResult>   <list> 2020-07-12 01:49:40
## 12: 0.10000        3     0.2891 <ResampleResult>   <list> 2020-07-12 01:49:40
## 13: 0.05050        8     0.2891 <ResampleResult>   <list> 2020-07-12 01:49:40
## 14: 0.07525       10     0.2891 <ResampleResult>   <list> 2020-07-12 01:49:40
## 15: 0.02575        1     0.2539 <ResampleResult>   <list> 2020-07-12 01:49:40
## 16: 0.05050        5     0.2891 <ResampleResult>   <list> 2020-07-12 01:49:40
## 17: 0.00100        5     0.2852 <ResampleResult>   <list> 2020-07-12 01:49:40
## 18: 0.00100        3     0.2773 <ResampleResult>   <list> 2020-07-12 01:49:40
## 19: 0.05050       10     0.2891 <ResampleResult>   <list> 2020-07-12 01:49:40
## 20: 0.02575        5     0.2539 <ResampleResult>   <list> 2020-07-12 01:49:40
##     batch_nr
##  1:        1
##  2:        2
##  3:        3
##  4:        4
##  5:        5
##  6:        6
##  7:        7
##  8:        8
##  9:        9
## 10:       10
## 11:       11
## 12:       12
## 13:       13
## 14:       14
## 15:       15
## 16:       16
## 17:       17
## 18:       18
## 19:       19
## 20:       20

In sum, the grid search evaluated 20/25 different configurations of the grid in a random order before the Terminator stopped the tuning.

Now the optimized hyperparameters can take the previously created Learner, set the returned hyperparameters and train it on the full dataset.

The trained model can now be used to make a prediction on external data. Note that predicting on observations present in the task, should be avoided. The model has seen these observations already during tuning and therefore results would be statistically biased. Hence, the resulting performance measure would be over-optimistic. Instead, to get statistically unbiased performance estimates for the current task, nested resampling is required.

3.1.4 Automating the Tuning

The AutoTuner wraps a learner and augments it with an automatic tuning for a given set of hyperparameters. Because the AutoTuner itself inherits from the Learner base class, it can be used like any other learner. Analogously to the previous subsection, a new classification tree learner is created. This classification tree learner automatically tunes the parameters cp and minsplit using an inner resampling (holdout). We create a terminator which allows 10 evaluations, and use a simple random search as tuning algorithm:

## <AutoTuner:classif.rpart.tuned>
## * Model: -
## * Parameters: xval=0
## * Packages: rpart
## * Predict Type: response
## * Feature types: logical, integer, numeric, factor, ordered
## * Properties: importance, missings, multiclass, selected_features,
##   twoclass, weights

We can now use the learner like any other learner, calling the $train() and $predict() method. This time however, we pass it to benchmark() to compare the tuner to a classification tree without tuning. This way, the AutoTuner will do its resampling for tuning on the training set of the respective split of the outer resampling. The learner then undertakes predictions using the test set of the outer resampling. This yields unbiased performance measures, as the observations in the test set have not been used during tuning or fitting of the respective learner. This is called nested resampling.

To compare the tuned learner with the learner using its default, we can use benchmark():

## INFO  [01:49:41.371] Starting to optimize 2 parameter(s) with '<OptimizerRandomSearch>' and '<TerminatorEvals>' 
## INFO  [01:49:41.396] Evaluating 1 configuration(s) 
## INFO  [01:49:41.446] Result of batch 1: 
## INFO  [01:49:41.448]       cp minsplit classif.ce  resample_result 
## INFO  [01:49:41.448]  0.07206       10     0.2632 <ResampleResult> 
## INFO  [01:49:41.451] Evaluating 1 configuration(s) 
## INFO  [01:49:41.496] Result of batch 2: 
## INFO  [01:49:41.498]       cp minsplit classif.ce  resample_result 
## INFO  [01:49:41.498]  0.03488        1     0.2632 <ResampleResult> 
## INFO  [01:49:41.502] Evaluating 1 configuration(s) 
## INFO  [01:49:41.551] Result of batch 3: 
## INFO  [01:49:41.553]        cp minsplit classif.ce  resample_result 
## INFO  [01:49:41.553]  0.006268        1      0.269 <ResampleResult> 
## INFO  [01:49:41.556] Evaluating 1 configuration(s) 
## INFO  [01:49:41.601] Result of batch 4: 
## INFO  [01:49:41.602]       cp minsplit classif.ce  resample_result 
## INFO  [01:49:41.602]  0.06615        3     0.2632 <ResampleResult> 
## INFO  [01:49:41.606] Evaluating 1 configuration(s) 
## INFO  [01:49:41.652] Result of batch 5: 
## INFO  [01:49:41.654]       cp minsplit classif.ce  resample_result 
## INFO  [01:49:41.654]  0.07302        4     0.2632 <ResampleResult> 
## INFO  [01:49:41.657] Evaluating 1 configuration(s) 
## INFO  [01:49:41.706] Result of batch 6: 
## INFO  [01:49:41.707]       cp minsplit classif.ce  resample_result 
## INFO  [01:49:41.707]  0.01462        7     0.2573 <ResampleResult> 
## INFO  [01:49:41.711] Evaluating 1 configuration(s) 
## INFO  [01:49:41.757] Result of batch 7: 
## INFO  [01:49:41.758]        cp minsplit classif.ce  resample_result 
## INFO  [01:49:41.758]  0.006415        3      0.269 <ResampleResult> 
## INFO  [01:49:41.762] Evaluating 1 configuration(s) 
## INFO  [01:49:41.836] Result of batch 8: 
## INFO  [01:49:41.837]       cp minsplit classif.ce  resample_result 
## INFO  [01:49:41.837]  0.04727        7     0.2632 <ResampleResult> 
## INFO  [01:49:41.841] Evaluating 1 configuration(s) 
## INFO  [01:49:41.886] Result of batch 9: 
## INFO  [01:49:41.887]       cp minsplit classif.ce  resample_result 
## INFO  [01:49:41.887]  0.03343        6     0.2632 <ResampleResult> 
## INFO  [01:49:41.891] Evaluating 1 configuration(s) 
## INFO  [01:49:41.936] Result of batch 10: 
## INFO  [01:49:41.937]       cp minsplit classif.ce  resample_result 
## INFO  [01:49:41.937]  0.02929        6     0.2632 <ResampleResult> 
## INFO  [01:49:41.944] Finished optimizing after 10 evaluation(s) 
## INFO  [01:49:41.944] Result: 
## INFO  [01:49:41.946]       cp minsplit learner_param_vals x_domain classif.ce 
## INFO  [01:49:41.946]  0.01462        7             <list>   <list>     0.2573 
## INFO  [01:49:42.026] Starting to optimize 2 parameter(s) with '<OptimizerRandomSearch>' and '<TerminatorEvals>' 
## INFO  [01:49:42.040] Evaluating 1 configuration(s) 
## INFO  [01:49:42.092] Result of batch 1: 
## INFO  [01:49:42.094]       cp minsplit classif.ce  resample_result 
## INFO  [01:49:42.094]  0.06121        2     0.2924 <ResampleResult> 
## INFO  [01:49:42.097] Evaluating 1 configuration(s) 
## INFO  [01:49:42.143] Result of batch 2: 
## INFO  [01:49:42.144]       cp minsplit classif.ce  resample_result 
## INFO  [01:49:42.144]  0.02942        7     0.2924 <ResampleResult> 
## INFO  [01:49:42.148] Evaluating 1 configuration(s) 
## INFO  [01:49:42.193] Result of batch 3: 
## INFO  [01:49:42.194]     cp minsplit classif.ce  resample_result 
## INFO  [01:49:42.194]  0.015        9     0.3275 <ResampleResult> 
## INFO  [01:49:42.198] Evaluating 1 configuration(s) 
## INFO  [01:49:42.247] Result of batch 4: 
## INFO  [01:49:42.249]       cp minsplit classif.ce  resample_result 
## INFO  [01:49:42.249]  0.07151        4     0.2924 <ResampleResult> 
## INFO  [01:49:42.252] Evaluating 1 configuration(s) 
## INFO  [01:49:42.297] Result of batch 5: 
## INFO  [01:49:42.299]       cp minsplit classif.ce  resample_result 
## INFO  [01:49:42.299]  0.03808        8     0.2924 <ResampleResult> 
## INFO  [01:49:42.302] Evaluating 1 configuration(s) 
## INFO  [01:49:42.352] Result of batch 6: 
## INFO  [01:49:42.354]       cp minsplit classif.ce  resample_result 
## INFO  [01:49:42.354]  0.03153        1     0.2924 <ResampleResult> 
## INFO  [01:49:42.357] Evaluating 1 configuration(s) 
## INFO  [01:49:42.403] Result of batch 7: 
## INFO  [01:49:42.405]       cp minsplit classif.ce  resample_result 
## INFO  [01:49:42.405]  0.01085        6     0.3216 <ResampleResult> 
## INFO  [01:49:42.408] Evaluating 1 configuration(s) 
## INFO  [01:49:42.454] Result of batch 8: 
## INFO  [01:49:42.455]       cp minsplit classif.ce  resample_result 
## INFO  [01:49:42.455]  0.05106        3     0.2924 <ResampleResult> 
## INFO  [01:49:42.459] Evaluating 1 configuration(s) 
## INFO  [01:49:42.509] Result of batch 9: 
## INFO  [01:49:42.511]       cp minsplit classif.ce  resample_result 
## INFO  [01:49:42.511]  0.04757        9     0.2924 <ResampleResult> 
## INFO  [01:49:42.514] Evaluating 1 configuration(s) 
## INFO  [01:49:42.560] Result of batch 10: 
## INFO  [01:49:42.562]       cp minsplit classif.ce  resample_result 
## INFO  [01:49:42.562]  0.07516        7     0.2924 <ResampleResult> 
## INFO  [01:49:42.569] Finished optimizing after 10 evaluation(s) 
## INFO  [01:49:42.570] Result: 
## INFO  [01:49:42.571]       cp minsplit learner_param_vals x_domain classif.ce 
## INFO  [01:49:42.571]  0.06121        2             <list>   <list>     0.2924 
## INFO  [01:49:42.620] Starting to optimize 2 parameter(s) with '<OptimizerRandomSearch>' and '<TerminatorEvals>' 
## INFO  [01:49:42.631] Evaluating 1 configuration(s) 
## INFO  [01:49:42.681] Result of batch 1: 
## INFO  [01:49:42.682]        cp minsplit classif.ce  resample_result 
## INFO  [01:49:42.682]  0.001552        3     0.3216 <ResampleResult> 
## INFO  [01:49:42.686] Evaluating 1 configuration(s) 
## INFO  [01:49:42.738] Result of batch 2: 
## INFO  [01:49:42.740]       cp minsplit classif.ce  resample_result 
## INFO  [01:49:42.740]  0.02475        3     0.2515 <ResampleResult> 
## INFO  [01:49:42.744] Evaluating 1 configuration(s) 
## INFO  [01:49:42.790] Result of batch 3: 
## INFO  [01:49:42.791]       cp minsplit classif.ce  resample_result 
## INFO  [01:49:42.791]  0.02201        5     0.2865 <ResampleResult> 
## INFO  [01:49:42.795] Evaluating 1 configuration(s) 
## INFO  [01:49:42.841] Result of batch 4: 
## INFO  [01:49:42.843]       cp minsplit classif.ce  resample_result 
## INFO  [01:49:42.843]  0.09922        4     0.2515 <ResampleResult> 
## INFO  [01:49:42.847] Evaluating 1 configuration(s) 
## INFO  [01:49:42.898] Result of batch 5: 
## INFO  [01:49:42.900]       cp minsplit classif.ce  resample_result 
## INFO  [01:49:42.900]  0.08303        6     0.2515 <ResampleResult> 
## INFO  [01:49:42.903] Evaluating 1 configuration(s) 
## INFO  [01:49:42.950] Result of batch 6: 
## INFO  [01:49:42.952]       cp minsplit classif.ce  resample_result 
## INFO  [01:49:42.952]  0.05242        1     0.2515 <ResampleResult> 
## INFO  [01:49:42.955] Evaluating 1 configuration(s) 
## INFO  [01:49:43.007] Result of batch 7: 
## INFO  [01:49:43.008]       cp minsplit classif.ce  resample_result 
## INFO  [01:49:43.008]  0.03149        1     0.2515 <ResampleResult> 
## INFO  [01:49:43.012] Evaluating 1 configuration(s) 
## INFO  [01:49:43.058] Result of batch 8: 
## INFO  [01:49:43.060]       cp minsplit classif.ce  resample_result 
## INFO  [01:49:43.060]  0.03393        7     0.2515 <ResampleResult> 
## INFO  [01:49:43.063] Evaluating 1 configuration(s) 
## INFO  [01:49:43.110] Result of batch 9: 
## INFO  [01:49:43.111]       cp minsplit classif.ce  resample_result 
## INFO  [01:49:43.111]  0.05322        4     0.2515 <ResampleResult> 
## INFO  [01:49:43.119] Evaluating 1 configuration(s) 
## INFO  [01:49:43.165] Result of batch 10: 
## INFO  [01:49:43.167]       cp minsplit classif.ce  resample_result 
## INFO  [01:49:43.167]  0.05324       10     0.2515 <ResampleResult> 
## INFO  [01:49:43.174] Finished optimizing after 10 evaluation(s) 
## INFO  [01:49:43.175] Result: 
## INFO  [01:49:43.176]       cp minsplit learner_param_vals x_domain classif.ce 
## INFO  [01:49:43.176]  0.02475        3             <list>   <list>     0.2515
##    nr  resample_result task_id          learner_id resampling_id iters
## 1:  1 <ResampleResult>    pima classif.rpart.tuned            cv     3
## 2:  2 <ResampleResult>    pima       classif.rpart            cv     3
##    classif.ce time_train
## 1:     0.2500   0.597000
## 2:     0.2565   0.005333

Note that we do not expect any differences compared to the non-tuned approach for multiple reasons:

  • the task is too easy
  • the task is rather small, and thus prone to overfitting
  • the tuning budget (10 evaluations) is small
  • rpart does not benefit that much from tuning

References

Bergstra, James, and Yoshua Bengio. 2012. “Random Search for Hyper-Parameter Optimization.” J. Mach. Learn. Res. 13. JMLR.org: 281–305.