Skip to contents

Wrapper around PipeOpResponseCompositor to simplify Graph creation.

Usage

pipeline_responsecompositor(
  learner,
  method = "rmst",
  tau = NULL,
  add_crank = FALSE,
  overwrite = FALSE,
  graph_learner = FALSE
)

Arguments

learner

[mlr3::Learner]|[mlr3pipelines::PipeOp]|[mlr3pipelines::Graph]
Either a Learner which will be wrapped in mlr3pipelines::PipeOpLearner, a PipeOp which will be wrapped in mlr3pipelines::Graph or a Graph itself. Underlying Learner should be LearnerSurv.

method

(character(1))
Determines what method should be used to produce a survival time (response) from the survival distribution. Available methods are "rmst" and "median", corresponding to the restricted mean survival time and the median survival time respectively.

tau

(numeric(1))
Determines the time point up to which we calculate the restricted mean survival time (works only for the "rmst" method). If NULL (default), all the available time points in the predicted survival distribution will be used.

add_crank

(logical(1))
If TRUE then crank predict type will be set as -response (as higher survival times correspond to lower risk). Works only if overwrite is TRUE.

overwrite

(logical(1))
If FALSE (default) and the prediction already has a response prediction, then the compositor returns the input prediction unchanged. If TRUE, then the response (and the crank, if add_crank is TRUE) will be overwritten.

graph_learner

(logical(1))
If TRUE returns wraps the Graph as a GraphLearner otherwise (default) returns as a Graph.

Dictionary

This Graph can be instantiated via the dictionary mlr_graphs or with the associated sugar function ppl():

mlr_graphs$get("responsecompositor")
ppl("responsecompositor")

Examples

if (FALSE) { # \dontrun{
  library("mlr3")
  library("mlr3pipelines")

  task = tsk("lung")
  part = partition(task)

  # add survival time prediction type to the predictions of a Cox model
  grlrn = ppl(
    "responsecompositor",
    learner = lrn("surv.coxph"),
    method = "rmst",
    overwrite = TRUE,
    graph_learner = TRUE
  )
  grlrn$train(task, part$train)
  grlrn$predict(task, part$test)
} # }