Uses a predicted distr in a PredictionSurv to estimate (or 'compose') a crank prediction.


R6Class inheriting from PipeOp.


PipeOpCrankCompositor$new(id = "crankcompose", param_vals = list(method = "mean"))
  • id :: character(1)
    Identifier of the resulting object, default "crankcompose".

  • param_vals :: named list
    List of hyperparameter settings, overwriting the hyperparameter settings that would otherwise be set during construction. Default list(method = "mean").

Input and Output Channels

PipeOpCrankCompositor has one input channel named "input", which takes NULL during training and PredictionSurv during prediction.

PipeOpCrankCompositor has one output channel named "output", producing NULL during training and a PredictionSurv during prediction.

The output during prediction is the PredictionSurv from the "pred" input but with the crank predict type overwritten by the given estimation method.


The $state is left empty (list()).


  • method :: character(1)
    Determines what method should be used to produce a continuous ranking from the distribution. One of median, mode, or mean corresponding to the respective functions in the predicted survival distribution. Note that for models with a proportional hazards form, the ranking implied by mean and median will be identical (but not the value of crank itself). Default is mean.


The median, mode, or mean will use analytical expressions if possible but if not they are calculated using distr6::median.Distribution, distr6::mode, or distr6::mean.Distribution respectively.


Only fields inherited from PipeOp.


Only methods inherited from PipeOp.

See also


library(mlr3) library(mlr3pipelines) set.seed(1) # Three methods to predict a `crank` from `surv.rpart` task = tgen("simsurv")$generate(30) # Method 1 - Train and predict separately then compose learn = lrn("surv.coxph")$train(task)$predict(task) poc = po("crankcompose", param_vals = list(method = "mean")) poc$predict(list(learn))
#> $output #> <PredictionSurv> for 30 observations: #> row_id time status crank distr lp #> 1 5.0000000 FALSE 1.4326828 <VectorDistribution> 0.01031299 #> 2 0.8433684 TRUE 1.6398177 <VectorDistribution> 0.26069368 #> 3 0.8070400 TRUE 1.0110342 <VectorDistribution> -0.50690465 #> --- #> 28 5.0000000 FALSE 1.3719301 <VectorDistribution> -0.06157584 #> 29 5.0000000 FALSE 0.8572003 <VectorDistribution> -0.72098848 #> 30 4.1997027 TRUE 1.6078754 <VectorDistribution> 0.22093276 #>
# Examples not run to save run-time. if (FALSE) { # Method 2 - Create a graph manually gr = Graph$new()$ add_pipeop(po("learner", lrn("surv.ranger")))$ add_pipeop(po("crankcompose"))$ add_edge("surv.ranger", "crankcompose") gr$train(task) gr$predict(task) # Method 3 - Syntactic sugar: Wrap the learner in a graph ranger.crank = crankcompositor(learner = lrn("surv.ranger"), method = "median") resample(task, ranger.crank, rsmp("cv", folds = 2))$predictions() }