Trains and evaluates one or more registered prognostic models on a given dataset.
Usage
models_pro(
data,
model = "all_pro",
tune = FALSE,
seed = 123,
time_unit = "day",
years_to_evaluate = c(1, 3, 5)
)
Arguments
- data
A data frame for training. The first column must be the sample ID, the second column the event status (0/1), the third column the time, and subsequent columns the features.
- model
A character string or vector of character strings, specifying which models to run. Use "all_pro" to run all registered models.
- tune
Logical, whether to enable hyperparameter tuning for individual models.
- seed
An integer, for reproducibility of random processes.
- time_unit
A character string, the unit of time in the third column of
data
. Can be "day", "month", or "year".- years_to_evaluate
A numeric vector of specific years at which to calculate time-dependent AUROC.
Value
A named list, where each element corresponds to a run model and
contains its trained model_object
, sample_score
data frame, and
evaluation_metrics
.
Examples
# \donttest{
# NOTE: This example requires the 'train_pro' dataset to be exported by the package.
# If it is not, replace `data(train_pro)` with code to create a dummy dataframe.
# For demonstration, we assume `train_pro` is available.
if (requireNamespace("E2E", quietly = TRUE) &&
"train_pro" %in% utils::data(package = "E2E")$results[,3]) {
data(train_pro, package = "E2E")
# Initialize the modeling system
initialize_modeling_system_pro()
# Run selected models
results <- models_pro(
data = train_pro,
model = c("lasso_pro", "rsf_pro"), # Run only Lasso and RSF
years_to_evaluate = c(1, 3, 5),
seed = 42
)
# Print summaries
for (model_name in names(results)) {
print_model_summary_pro(model_name, results[[model_name]])
}
}
#> Prognosis modeling system already initialized.
#> Running model: lasso_pro
#> Warning: from glmnet C++ code (error code -30001); Numerical error at 1th lambda value; solutions for larger values of lambda returned
#> Warning: an empty model has been returned; probably a convergence issue
#> Warning: Cannot perform KM analysis due to constant, all NA, or non-varying scores.
#> Running model: rsf_pro
#>
#> --- lasso_pro Prognosis Model (on Training Data) Metrics ---
#> C-index: NA
#> Time-dependent AUROC (years 1, 3, 5): 0.5000, 0.5000, 0.5000
#> Average Time-dependent AUROC: 0.5000
#> KM Group Analysis: Not applicable or failed.
#> --------------------------------------------------
#>
#> --- rsf_pro Prognosis Model (on Training Data) Metrics ---
#> C-index: 0.8916
#> Time-dependent AUROC (years 1, 3, 5): 0.8476, 0.7541, 0.7163
#> Average Time-dependent AUROC: 0.7726
#> KM Group HR (High vs Low): 11.1166 (p-value: 4.204e-14, Cutoff: -1133.7492)
#> --------------------------------------------------
# }