predict.dnnsurv: Predict Method for DNNSurv

View source: R/dnnsurv.R

predict.dnnsurvR Documentation

Predict Method for DNNSurv

Description

Predicted values from a fitted object of class dnnsurv.

Usage

## S3 method for class 'dnnsurv'
predict(
  object,
  newdata,
  batch_size = 32L,
  verbose = 0L,
  steps = NULL,
  callbacks = NULL,
  type = c("survival", "risk", "all"),
  distr6 = FALSE,
  ...
)

Arguments

object

(dnnsurv(1))
Object of class inheriting from "dnnsurv".

newdata

(data.frame(1))
Testing data of data.frame like object, internally is coerced with stats::model.matrix(). If missing then training data from fitted object is used.

batch_size

(integer(1))
Passed to keras::predict.keras.engine.training.Model, elements in each batch.

verbose

(integer(1))
Level of verbosity for printing, 0 or 1.

steps

(integer(1))
Number of batches before evaluation finished, see keras::predict.keras.engine.training.Model.

callbacks

(list())
Optional callbacks to apply during prediction.

type

(character(1))
Type of predicted value. Choices are survival probabilities over all time-points in training data ("survival") or a relative risk ranking ("risk"), which is the negative mean survival time so higher rank implies higher risk of event, or both ("all").

distr6

(logical(1))
If FALSE (default) and type is "survival" or "all" returns matrix of survival probabilities, otherwise returns a distr6::Matdist().

...

ANY
Currently ignored.

Value

A numeric if type = "risk", a distr6::Matdist() (if distr6 = TRUE) and type = "survival"; a matrix if (distr6 = FALSE) and type = "survival" where entries are survival probabilities with rows of observations and columns are time-points; or a list combining above if type = "all".

Examples


if (requireNamespaces(c("keras", "pseudo")))
  fit <- dnnsurv(data = simsurvdata(10))

  # predict survival matrix and relative risks
  predict(fit, simsurvdata(10), type = "all")

  # return as distribution
  if (requireNamespaces("distr6")) {
    predict(fit, simsurvdata(10), distr6 = TRUE)
  }



survivalmodels documentation built on March 24, 2022, 9:05 a.m.