mlr_sugar {mlr3}R Documentation

Syntactic Sugar for Object Construction

Description

Functions to retrieve objects, set hyperparameters and assign to fields in one go. Relies on mlr3misc::dictionary_sugar_get() to extract objects from the respective mlr3misc::Dictionary:

Helper function to configure the ⁠$validate⁠ field(s) of a Learner.

This is especially useful for learners such as AutoTuner of mlr3tuning or GraphLearner of mlr3pipelines which have multiple levels of ⁠$validate⁠ fields., where the ⁠$validate⁠ fields need to be configured on multiple levels.

Usage

tsk(.key, ...)

tsks(.keys, ...)

tgen(.key, ...)

tgens(.keys, ...)

lrn(.key, ...)

lrns(.keys, ...)

rsmp(.key, ...)

rsmps(.keys, ...)

msr(.key, ...)

msrs(.keys, ...)

set_validate(learner, validate, ...)

Arguments

.key

(character(1))
Key passed to the respective dictionary to retrieve the object.

...

(any)
Additional arguments.

.keys

(character())
Keys passed to the respective dictionary to retrieve multiple objects.

learner

(any)
The learner.

validate

(numeric(1), "predefined", "test", or NULL)
Which validation set to use.

Value

R6::R6Class object of the respective type, or a list of R6::R6Class objects for the plural versions.

Modified Learner

Examples

# penguins task with new id
tsk("penguins", id = "penguins2")

# classification tree with different hyperparameters
# and predict type set to predict probabilities
lrn("classif.rpart", cp = 0.1, predict_type = "prob")

# multiple learners with predict type 'prob'
lrns(c("classif.featureless", "classif.rpart"), predict_type = "prob")
learner = lrn("classif.debug")
set_validate(learner, 0.2)
learner$validate

[Package mlr3 version 0.20.2 Index]