mlr3pipelines::PipeOp that trains a Learner and passes its predictions forward during training and prediction.

Post-process a learner prediction using multi-calibration. For more details, please refer to https://arxiv.org/pdf/1805.12317.pdf (Kim et al. 2018) or the help for MCBoost. If no init_predictor is provided, the preceding learner's predictions corresponding to the prediction slot are used as an initial predictor for MCBoost.

Format

R6Class inheriting from mlr3pipelines::PipeOp.

R6Class inheriting from mlr3pipelines::PipeOp.

Construction

PipeOpLearnerPred$new(learner, id = NULL, param_vals = list())

* `learner` :: [`Learner`][mlr3::Learner] \cr
  [`Learner`][mlr3::Learner] to  prediction, or a string identifying a
  [`Learner`][mlr3::Learner] in the [`mlr3::mlr_learners`] [`Dictionary`][mlr3misc::Dictionary].
* `id` :: `character(1)`
  Identifier of the resulting object, internally defaulting to the `id` of the [`Learner`][mlr3::Learner] being wrapped.
* `param_vals` :: named `list`\cr
  List of hyperparameter settings, overwriting the hyperparameter settings that would otherwise be set during construction. Default `list()`.


[mlr3::Learner]: R:mlr3::Learner
[mlr3::Learner]: R:mlr3::Learner
[mlr3::Learner]: R:mlr3::Learner
[`mlr3::mlr_learners`]: R:%60mlr3::mlr_learners%60
[mlr3misc::Dictionary]: R:mlr3misc::Dictionary
[mlr3::Learner]: R:mlr3::Learner

PipeOpMCBoost$new(id = "mcboost", param_vals = list())

  • id :: character(1) Identifier of the resulting object, default "threshold".

  • param_vals :: named list
    List of hyperparameter settings, overwriting the hyperparameter settings that would otherwise be set during construction. See MCBoost for a comprehensive description of all hyperparameters.

Input and Output Channels

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

PipeOpLearnerPred has one output channel named "output", producing a Task specific to the Learner type given to learner during construction; both during training and prediction.

During training, the input and output are "data" and "prediction", two TaskClassif. A PredictionClassif is required as input and returned as output during prediction.

State

The $state is a MCBoost Object as obtained from MCBoost$new().

Parameters

The $state is set to the $state slot of the Learner object, together with the $state elements inherited from mlr3pipelines::PipeOpTaskPreproc. It is a named list with the inherited members, as well as:

  • model :: any
    Model created by the Learner's $.train() 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.

  • max_iter :: integer
    A integer specifying the number of multi-calibration rounds. Defaults to 5.

Fields

Fields inherited from PipeOp, as well as:

  • learner :: Learner
    Learner that is being wrapped. Read-only.

  • learner_model :: Learner
    Learner that is being wrapped. This learner contains the model if the PipeOp is trained. Read-only.

Only fields inherited from mlr3pipelines::PipeOp.

Methods

Methods inherited from mlr3pipelines::PipeOpTaskPreproc/mlr3pipelines::PipeOp.

Only methods inherited from mlr3pipelines::PipeOp.

See also

https://mlr3book.mlr-org.com/list-pipeops.html

https://mlr3book.mlr-org.com/list-pipeops.html

Super classes

mlr3pipelines::PipeOp -> mlr3pipelines::PipeOpTaskPreproc -> PipeOpLearnerPred

Active bindings

learner

The wrapped learner.

learner_model

The wrapped learner's model(s).

Methods

Inherited methods


Method new()

Initialize a Learner Predictor PipeOp. Can be used to wrap trained or untrainted mlr3 learners.

Usage

PipeOpLearnerPred$new(learner, id = NULL, param_vals = list())

Arguments

learner

Learner
The learner that should be wrapped.

id

character
The PipeOp's id. Defaults to "mcboost".

param_vals

list
List of hyperparameters for the PipeOp.


Method clone()

The objects of this class are cloneable with this method.

Usage

PipeOpLearnerPred$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Super class

mlr3pipelines::PipeOp -> PipeOpMCBoost

Active bindings

predict_type

Predict type of the PipeOp.

Methods

Inherited methods


Method new()

Initialize a Multi-Calibration PipeOp.

Usage

PipeOpMCBoost$new(id = "mcboost", param_vals = list())

Arguments

id

character
The PipeOp's id. Defaults to "mcboost".

param_vals

list
List of hyperparameters for the PipeOp.


Method clone()

The objects of this class are cloneable with this method.

Usage

PipeOpMCBoost$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

if (FALSE) {
gr = gunion(list(
  "data" = po("nop"),
  "prediction" = po("learner_cv", lrn("classif.rpart"))
)) %>>%
  PipeOpMCBoost$new()
tsk = tsk("sonar")
tid = sample(1:208, 108)
gr$train(tsk$clone()$filter(tid))
gr$predict(tsk$clone()$filter(setdiff(1:208, tid)))
}