Skip to contents

Trains a Random Survival Forest (RSF) model using randomForestSRC.

Usage

rsf_pro(X, y_surv, tune = FALSE)

Arguments

X

A data frame of features.

y_surv

A survival::Surv object representing the survival outcome.

tune

Logical, whether to perform hyperparameter tuning (a simplified message is currently provided, full tuning with tune.rfsrc is recommended for advanced use).

Value

A list of class "train" containing the trained rfsrc model object, names of features used in training, and model type. The returned object also includes fitted_scores and y_surv.

Examples

# \donttest{
# Generate some dummy survival data
set.seed(42)
n_samples <- 50
n_features <- 5
X_data <- as.data.frame(matrix(rnorm(n_samples * n_features), ncol = n_features))
Y_surv_obj <- survival::Surv(
  time = runif(n_samples, 100, 1000),
  event = sample(0:1, n_samples, replace = TRUE)
)

# Train the model (ntree is small for a quick example)
rsf_model <- rsf_pro(X_data, Y_surv_obj)
print(rsf_model$finalModel)
#>                          Sample size: 50
#>                      Number of trees: 100
#>            Forest terminal node size: 5
#>        Average no. of terminal nodes: 7.18
#> No. of variables tried at each split: 1
#>               Total no. of variables: 5
#>        Resampling used to grow trees: swor
#>     Resample size used to grow trees: 32
#>                             Analysis: RF-R
#>                               Family: regr
#>                       Splitting rule: mse *random*
#>        Number of random split points: 10
#>                      (OOB) R squared: -0.10393684, 8821.58846775, 8821.58846775, -282736.47829368
#>    (OOB) Requested performance error: 71665.29551852
#> 
# }