pecs {mlr3proba}R Documentation

Prediction Error Curves for PredictionSurv and LearnerSurv

Description

Methods to plot prediction error curves (pecs) for either a PredictionSurv object or a list of trained LearnerSurvs.

Usage

pecs(x, measure = c("graf", "logloss"), times, n, eps = 1e-15, ...)

## S3 method for class 'list'
pecs(
  x,
  measure = c("graf", "logloss"),
  times,
  n,
  eps = 1e-15,
  task = NULL,
  row_ids = NULL,
  newdata,
  ...
)

## S3 method for class 'PredictionSurv'
pecs(x, measure = c("graf", "logloss"), times, n, eps = 1e-15, ...)

Arguments

x

(PredictionSurv or list of LearnerSurvs)

measure

(character(1))
Either "graf" for MeasureSurvGraf, or "logloss" for MeasureSurvIntLogloss

times

(numeric())
If provided then either a vector of time-points to evaluate measure or a range of time-points.

n

(integer())
If times is missing or given as a range, then n provide number of time-points to evaluate measure over.

eps

(numeric())
Small error value to pass to MeasureSurvIntLogloss to prevent errors resulting from a log(0) calculation.

...

Additional arguments.

task

(TaskSurv)

row_ids

(integer())
Passed to Learner$predict.

newdata

(data.frame())
If not missing Learner$predict_newdata is called instead of Learner$predict.

Details

If times and n are missing then measure is evaluated over all observed time-points from the PredictionSurv or TaskSurv object. If a range is provided for times without n, then all time-points between the range are returned.

Examples

## Not run: 
if (requireNamespace("ggplot2", quietly = TRUE)) {
#' library(mlr3)
task = tsk("rats")

# Prediction Error Curves for prediction object
learn = lrn("surv.coxph")
p = learn$train(task)$predict(task)
pecs(p)
pecs(p, measure = "logloss", times = c(20, 40, 60, 80)) +
  ggplot2::geom_point() +
  ggplot2::ggtitle("Logloss Prediction Error Curve for Cox PH")

# Access underlying data
x = pecs(p)
x$data

# Prediction Error Curves for fitted learners
learns = lrns(c("surv.kaplan", "surv.coxph"))
lapply(learns, function(x) x$train(task))
pecs(learns, task = task, measure = "logloss", times = c(20, 90), n = 10)
}

## End(Not run)


[Package mlr3proba version 0.2.6 Index]