Wraps an mlr3::Learner into a PipeOp.

Inherits the $param_set (and therefore $param_set$values) from the Learner it is constructed from.

Using PipeOpLearner, it is possible to embed mlr3::Learners into Graphs, which themselves can be turned into Learners using GraphLearner. This way, preprocessing and ensemble methods can be included into a machine learning pipeline which then can be handled as singular object for resampling, benchmarking and tuning.

Format

R6Class object inheriting from PipeOp.

Construction

PipeOpLearner$new(learner, id = if (is.character(learner)) learner else learner$id, param_vals = list())` \cr

Input and Output Channels

PipeOpLearner has one input channel named "input", taking a Task specific to the Learner type given to learner during construction; both during training and prediction.

PipeOpLearner has one output channel named "output", producing NULL during training and a Prediction subclass during prediction; this subclass is specific to the Learner type given to learner during construction.

The output during prediction is the Prediction on the prediction input data, produced by the Learner trained on the training input data.

State

The $state is set to the $state slot of the Learner object. It is a named list with members:

  • model :: any
    Model created by the Learner's $train_internal() function.

  • train_log :: data.table with columns class (character), msg (character)
    Errors logged during training.

  • train_time :: numeric(1)
    Training time, in seconds.

  • predict_log :: NULL | data.table with columns class (character), msg (character)
    Errors logged during prediction.

  • predict_time :: NULL | numeric(1) Prediction time, in seconds.

Parameters

The parameters are exactly the parameters of the Learner wrapped by this object.

Internals

The $state is currently not updated by prediction, so the $state$predict_log and $state$predict_time will always be NULL.

Fields

Fields inherited from PipeOp, as well as:

Methods

Methods inherited from PipeOp.

See also

Examples

library("mlr3") task = tsk("iris") learner = lrn("classif.rpart", cp = 0.1) lrn_po = mlr_pipeops$get("learner", learner) lrn_po$train(list(task))
#> $output #> NULL #>
lrn_po$predict(list(task))
#> $output #> <PredictionClassif> for 150 observations: #> row_id truth response #> 1 setosa setosa #> 2 setosa setosa #> 3 setosa setosa #> --- #> 148 virginica virginica #> 149 virginica virginica #> 150 virginica virginica #>