Skip to contents

This class defines a tuning space for hyperparameter tuning.

For tuning, it is important to create a search space that defines the range over which hyperparameters should be tuned. TuningSpace object consists of search spaces from peer-reviewed articles which work well for a wide range of data sets.

The $values field stores a list of paradox::TuneToken which define the search space. These tokens can be assigned to the $values slot of a learner's paradox::ParamSet. When the learner is tuned, the tokens are used to create the search space.

S3 Methods

  • as.data.table.TuningSpace(x)
    Returns a tabular view of the tuning space.
    TuningSpace -> data.table::data.table()

    • x (TuningSpace)

Public fields

id

(character(1))
Identifier of the object.

values

(list())
List of paradox::TuneToken that describe the tuning space and fixed parameter values.

tags

(character())
Arbitrary tags to group and filter tuning space e.g. "classification" or "regression".

learner

(character(1))
mlr3::Learner of the tuning space.

package

(character(1))
Packages which provide the mlr3::Learner, e.g. mlr3learners for the learner mlr3learners::LearnerClassifRanger which interfaces the ranger package.

label

(character(1))
Label for this object. Can be used in tables, plot and text output instead of the ID.

man

(character(1))
String in the format [pkg]::[topic] pointing to a manual page for this object. The referenced help package can be opened via method $help().

Methods


Method new()

Creates a new instance of this R6 class.

Usage

TuningSpace$new(
  id,
  values,
  tags,
  learner,
  package = character(),
  label = NA_character_,
  man = NA_character_
)

Arguments

id

(character(1))
Identifier for the new instance.

values

(list())
List of paradox::TuneToken that describe the tuning space and fixed parameter values.

tags

(character())
Tags to group and filter tuning spaces e.g. "classification" or "regression".

learner

(character(1))
mlr3::Learner of the tuning space.

package

(character())
Packages which provide the mlr3::Learner, e.g. mlr3learners for the learner mlr3learners::LearnerClassifRanger which interfaces the ranger package.

label

(character(1))
Label for the new instance. Can be used in tables, plot and text output instead of the ID.

man

(character(1))
String in the format [pkg]::[topic] pointing to a manual page for for the new instance. The referenced help package can be opened via method $help().


Method get_learner()

Returns a learner with paradox::TuneToken set in parameter set.

Usage

TuningSpace$get_learner(...)

Arguments

...

(named ‘list()’)
Passed to mlr3::lrn(). Named arguments passed to the constructor, to be set as parameters in the paradox::ParamSet, or to be set as public field. See mlr3misc::dictionary_sugar_get() for more details.

Returns

mlr3::Learner


Method format()

Helper for print outputs.

Usage

TuningSpace$format(...)

Arguments

...

(ignored).


Method help()

Opens the corresponding help page referenced by field $man.

Usage

TuningSpace$help()


Method print()

Printer.

Usage

TuningSpace$print(...)

Arguments

...

(ignored).


Method clone()

The objects of this class are cloneable with this method.

Usage

TuningSpace$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

library(mlr3tuning)

# Get default tuning space of rpart learner
tuning_space = lts("classif.rpart.default")

# Set tuning space
learner = lrn("classif.rpart")
learner$param_set$values = tuning_space$values

# Tune learner
instance = tune(
  tnr("random_search"),
  task = tsk("pima"),
  learner = learner,
  resampling = rsmp ("holdout"),
  measure = msr("classif.ce"),
  term_evals = 10)

instance$result
#>           cp minbucket minsplit learner_param_vals  x_domain classif.ce
#>        <num>     <num>    <num>             <list>    <list>      <num>
#> 1: -3.619915  3.851142 3.505744          <list[3]> <list[3]>  0.2148438

library(mlr3pipelines)

# Set tuning space in a pipeline
graph_learner = as_learner(po("subsample") %>>%
  lts(lrn("classif.rpart")))