Skip to contents

Function to retrieve TuningSpace objects from mlr_tuning_spaces and further, allows a mlr3::Learner to be directly configured with a search space. This function belongs to mlr3::mlr_sugar family.

Usage

lts(x, ...)

# S3 method for class 'missing'
lts(x, ...)

# S3 method for class 'character'
lts(x, ...)

# S3 method for class 'Learner'
lts(x, ...)

ltss(x)

Arguments

x

(character() | mlr3::Learner)
If character, key passed the dictionary to retrieve the tuning space. If mlr3::Learner, default tuning space is added to the learner.

...

(named list of paradox::TuneToken | NULL)
Pass paradox::TuneToken to add or overwrite parameters in the tuning space. Use NULL to remove parameters (see examples).

Value

TuningSpace if x is character(). mlr3::Learner if x is mlr3::Learner. Or a list of objects for the ltss() function.

missing, mlr_tuning_spaces dictionary

a character, TuningSpace

a mlr3::Learner, mlr3::Learner with paradox::TuneToken

a list(), list of TuningSpace or mlr3::Learner

Examples

# load tuning space
lts("classif.rpart.default")
#> <TuningSpace:classif.rpart.default>: Classification Rpart with Default
#>           id lower upper levels logscale
#>       <char> <num> <num> <list>   <lgcl>
#> 1:  minsplit 2e+00 128.0            TRUE
#> 2: minbucket 1e+00  64.0            TRUE
#> 3:        cp 1e-04   0.1            TRUE

# load tuning space and add parameter
lts("classif.rpart.default", maxdepth = to_tune(1, 15))
#> <TuningSpace:classif.rpart.default>: Classification Rpart with Default
#>           id lower upper levels logscale
#>       <char> <num> <num> <list>   <lgcl>
#> 1:  minsplit 2e+00 128.0            TRUE
#> 2: minbucket 1e+00  64.0            TRUE
#> 3:        cp 1e-04   0.1            TRUE
#> 4:  maxdepth 1e+00  15.0           FALSE

# load tuning space and remove parameter
lts("classif.rpart.default", minsplit = NULL)
#> <TuningSpace:classif.rpart.default>: Classification Rpart with Default
#>           id lower upper levels logscale
#>       <char> <num> <num> <list>   <lgcl>
#> 1: minbucket 1e+00  64.0            TRUE
#> 2:        cp 1e-04   0.1            TRUE

# load tuning space and overwrite parameter
lts("classif.rpart.default", minsplit = to_tune(32, 128))
#> <TuningSpace:classif.rpart.default>: Classification Rpart with Default
#>           id   lower upper levels logscale
#>       <char>   <num> <num> <list>   <lgcl>
#> 1:  minsplit 32.0000 128.0           FALSE
#> 2: minbucket  1.0000  64.0            TRUE
#> 3:        cp  0.0001   0.1            TRUE

# load learner and apply tuning space in one go
lts(lrn("classif.rpart"))
#> <LearnerClassifRpart:classif.rpart>: Classification Tree
#> * Model: -
#> * Parameters: cp=<RangeTuneToken>, minbucket=<RangeTuneToken>,
#>   minsplit=<RangeTuneToken>, xval=0
#> * Packages: mlr3, rpart
#> * Predict Types:  [response], prob
#> * Feature Types: logical, integer, numeric, factor, ordered
#> * Properties: importance, missings, multiclass, selected_features,
#>   twoclass, weights

# load learner, overwrite parameter and apply tuning space
lts(lrn("classif.rpart"), minsplit = to_tune(32, 128))
#> <LearnerClassifRpart:classif.rpart>: Classification Tree
#> * Model: -
#> * Parameters: cp=<RangeTuneToken>, minbucket=<RangeTuneToken>,
#>   minsplit=<RangeTuneToken>, xval=0
#> * Packages: mlr3, rpart
#> * Predict Types:  [response], prob
#> * Feature Types: logical, integer, numeric, factor, ordered
#> * Properties: importance, missings, multiclass, selected_features,
#>   twoclass, weights

# load multiple tuning spaces
ltss(c("classif.rpart.default", "classif.ranger.default"))
#> [[1]]
#> <TuningSpace:classif.rpart.default>: Classification Rpart with Default
#>           id lower upper levels logscale
#>       <char> <num> <num> <list>   <lgcl>
#> 1:  minsplit 2e+00 128.0            TRUE
#> 2: minbucket 1e+00  64.0            TRUE
#> 3:        cp 1e-04   0.1            TRUE
#> 
#> [[2]]
#> <TuningSpace:classif.ranger.default>: Classification Ranger with Default
#>                 id lower upper levels logscale
#>             <char> <num> <num> <list>   <lgcl>
#> 1:      mtry.ratio   0.0     1           FALSE
#> 2:         replace    NA    NA           FALSE
#> 3: sample.fraction   0.1     1           FALSE
#> 4:       num.trees   1.0  2000           FALSE
#>