apply_pro: Apply a Trained Prognostic Model to New Data

View source: R/prognosis.R

apply_proR Documentation

Apply a Trained Prognostic Model to New Data

Description

Applies a previously trained prognostic model (or ensemble) to a new, unseen dataset to generate prognostic scores.

Usage

apply_pro(trained_model_object, new_data, time_unit = "day")

Arguments

trained_model_object

A trained model object, as returned by models_pro, bagging_pro, or stacking_pro.

new_data

A data frame containing the new data for prediction. It should follow the same structure as the training data: ID, Outcome, Time, Features. The outcome and time columns are used for data preparation and can be included in the output, but the model's prediction only uses the features. If outcome/time are unknown, they can be filled with NA.

time_unit

A character string, the unit of time in the third column of new_data.

Value

A data frame with ID, outcome, time, and predicted score for the new data.

See Also

evaluate_model_pro

Examples


# NOTE: This example requires 'train_pro' and 'test_pro' datasets.
if (requireNamespace("E2E", quietly = TRUE) &&
    "train_pro" %in% utils::data(package = "E2E")$results[,3] &&
    "test_pro" %in% utils::data(package = "E2E")$results[,3]) {

  data(train_pro, package = "E2E")
  data(test_pro, package = "E2E")
  initialize_modeling_system_pro()

  train_results <- models_pro(data = train_pro, model = "lasso_pro")
  trained_lasso_model <- train_results$lasso_pro$model_object

  # Apply the trained model to new data
  new_data_predictions <- apply_pro(
    trained_model_object = trained_lasso_model,
    new_data = test_pro,
    time_unit = "day" # Specify time unit of test_pro
  )
  utils::head(new_data_predictions)
}


E2E documentation built on Aug. 27, 2025, 1:09 a.m.