Uses a predicted distr
in a PredictionSurv to estimate (or 'compose') a crank
prediction.
Dictionary
This PipeOp can be instantiated via the
dictionary mlr3pipelines::mlr_pipeops or with the associated sugar
function mlr3pipelines::po()
:
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.
State
The $state
is left empty (list()
).
Parameters
method
::character(1)
Determines what method should be used to produce a continuous ranking from the distribution. One ofsum_haz
,median
,mode
, ormean
corresponding to the respective functions in the predicted survival distribution. Note that for models with a proportional hazards form, the ranking implied bymean
andmedian
will be identical (but not the value ofcrank
itself).sum_haz
(default) usessurvivalmodels::surv_to_risk()
.which
::numeric(1)
Ifmethod = "mode"
then specifies which mode to use if multi-modal, default is the first.response
::logical(1)
IfTRUE
then theresponse
predict type is estimated with the same values ascrank
.overwrite
::logical(1)
IfFALSE
(default) then if the "pred" input already has acrank
, the compositor only composes aresponse
type ifresponse = TRUE
and does not already exist. IfTRUE
then both thecrank
andresponse
are overwritten.
Internals
The median
, mode
, or mean
will use analytical expressions if possible but if not they are
calculated using methods from distr6. mean
requires cubature.
See also
Other survival compositors:
mlr_pipeops_compose_breslow_distr
,
mlr_pipeops_distrcompose
Super class
mlr3pipelines::PipeOp
-> PipeOpCrankCompositor
Methods
Method new()
Creates a new instance of this R6 class.
Usage
PipeOpCrankCompositor$new(id = "crankcompose", param_vals = list())
Arguments
id
(
character(1)
)
Identifier of the resulting object.param_vals
(
list()
)
List of hyperparameter settings, overwriting the hyperparameter settings that would otherwise be set during construction.
Examples
if (FALSE) {
if (requireNamespace("mlr3pipelines", quietly = TRUE)) {
library(mlr3)
library(mlr3pipelines)
task = tsk("rats")
learn = lrn("surv.coxph")$train(task)$predict(task)
poc = po("crankcompose", param_vals = list(method = "sum_haz"))
poc$predict(list(learn))[[1]]
if (requireNamespace("cubature", quietly = TRUE)) {
learn = lrn("surv.coxph")$train(task)$predict(task)
poc = po("crankcompose", param_vals = list(method = "sum_haz"))
poc$predict(list(learn))[[1]]
}
}
}