Skip to contents

Wrapper around PipeOpDistrCompositor or PipeOpBreslow to simplify Graph creation.

[Experimental]

Usage

pipeline_distrcompositor(
  learner,
  estimator = "kaplan",
  form = "aft",
  overwrite = FALSE,
  scale_lp = 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.

estimator

(character(1))
One of kaplan (default), nelson or breslow, corresponding to the Kaplan-Meier, Nelson-Aalen and Breslow estimators respectively. Used to estimate the baseline survival distribution.

form

(character(1))
One of aft (default), ph, or po, corresponding to accelerated failure time, proportional hazards, and proportional odds respectively. Used to determine the form of the composed survival distribution. Ignored if estimator is breslow.

overwrite

(logical(1))
If FALSE (default) then if the learner already has a distr, the compositor does nothing. If TRUE then the distr is overwritten by the compositor if already present, which may be required for changing the prediction distr from one model form to another.

scale_lp

(logical(1))
If TRUE and form is "aft", the linear predictor scores are scaled before the composition. Experimental option, see more details on PipeOpDistrCompositor. Default is FALSE.

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("distrcompositor")
ppl("distrcompositor")

Examples

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

  # let's change the distribution prediction of Cox (Breslow-based) to an AFT form:
  task = tsk("rats")
  grlrn = ppl(
    "distrcompositor",
    learner = lrn("surv.coxph"),
    estimator = "kaplan",
    form = "aft",
    overwrite = TRUE,
    graph_learner = TRUE
  )
  grlrn$train(task)
  grlrn$predict(task)
} # }