Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

predict

Model Prediction


Description

Predict outcomes with a fitted model.

Usage

## S3 method for class 'MLModelFit'
predict(
  object,
  newdata = NULL,
  times = NULL,
  type = c("response", "prob"),
  cutoff = MachineShop::settings("cutoff"),
  dist = NULL,
  method = NULL,
  ...
)

Arguments

object

model fit result.

newdata

optional data frame with which to obtain predictions. If not specified, the training data will be used by default.

times

numeric vector of follow-up times at which to predict survival events/probabilities or NULL for predicted survival means.

type

specifies prediction on the original outcome scale ("response") or on a probability distribution scale ("prob").

cutoff

numeric (0, 1) threshold above which binary factor probabilities are classified as events and below which survival probabilities are classified.

dist

character string specifying distributional approximations to estimated survival curves. Possible values are "empirical", "exponential", "rayleigh", or "weibull"; with defaults of "empirical" for predicted survival events/probabilities and "weibull" for predicted survival means.

method

character string specifying the empirical method of estimating baseline survival curves for Cox proportional hazards-based models. Choices are "breslow", "efron" (default), or "fleming-harrington".

...

arguments passed to model-specific prediction functions.

See Also

Examples

## Requires prior installation of suggested package gbm to run

## Survival response example
library(survival)

gbm_fit <- fit(Surv(time, status) ~ ., data = veteran, model = GBMModel)
predict(gbm_fit, newdata = veteran, times = c(90, 180, 360), type = "prob")

MachineShop

Machine Learning Models and Tools

v2.8.0
GPL-3
Authors
Brian J Smith [aut, cre]
Initial release
2021-04-16

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.