Learn R Programming

mlr3proba (version 0.3.2)

as_prediction_surv: Convert to a Survival Prediction

Description

Convert object to a PredictionSurv.

Usage

as_prediction_surv(x, ...)

# S3 method for PredictionSurv as_prediction_surv(x, ...)

# S3 method for data.frame as_prediction_surv(x, ...)

Arguments

x

(any) Object to convert.

...

(any) Additional arguments.

Value

PredictionSurv.

Examples

Run this code
# NOT RUN {
library(mlr3)
task = tsk("rats")
learner = mlr_learners$get("surv.coxph")
learner$train(task)
p = learner$predict(task)

# convert to a data.table
tab = as.data.table(p)

# convert back to a Prediction
as_prediction_surv(tab)

# split data.table into a list of data.tables based
# on their survival times (ignoring censoring)
tabs = split(tab, cut(tab$time, 3))

# convert back to list of predictions
preds = lapply(tabs, as_prediction_surv)

# calculate performance in each group
sapply(preds, function(p) p$score())
# }

Run the code above in your browser using DataLab