LearnerSurvCoxPHCox {mlsurvlrnrs} | R Documentation |
R6 Class to construct a Cox proportional hazards survival learner
Description
The LearnerSurvCoxPHCox
class is the interface to perform a Cox
regression with the survival
R package for use with the mlexperiments
package.
Details
Can be used with
Super class
mlexperiments::MLLearnerBase
-> LearnerSurvCoxPHCox
Methods
Public methods
Inherited methods
Method new()
Create a new LearnerSurvCoxPHCox
object.
Usage
LearnerSurvCoxPHCox$new()
Returns
A new LearnerSurvCoxPHCox
R6 object.
Examples
LearnerSurvCoxPHCox$new()
Method clone()
The objects of this class are cloneable with this method.
Usage
LearnerSurvCoxPHCox$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
See Also
Examples
# survival analysis
dataset <- survival::colon |>
data.table::as.data.table() |>
na.omit()
dataset <- dataset[get("etype") == 2, ]
seed <- 123
surv_cols <- c("status", "time", "rx")
feature_cols <- colnames(dataset)[3:(ncol(dataset) - 1)]
split_vector <- splitTools::multi_strata(
df = dataset[, .SD, .SDcols = surv_cols],
strategy = "kmeans",
k = 4
)
train_x <- model.matrix(
~ -1 + .,
dataset[, .SD, .SDcols = setdiff(feature_cols, surv_cols[1:2])]
)
train_y <- survival::Surv(
event = (dataset[, get("status")] |>
as.character() |>
as.integer()),
time = dataset[, get("time")],
type = "right"
)
fold_list <- splitTools::create_folds(
y = split_vector,
k = 3,
type = "stratified",
seed = seed
)
surv_coxph_cox_optimizer <- mlexperiments::MLCrossValidation$new(
learner = LearnerSurvCoxPHCox$new(),
fold_list = fold_list,
ncores = 1L,
seed = seed
)
surv_coxph_cox_optimizer$performance_metric <- c_index
# set data
surv_coxph_cox_optimizer$set_data(
x = train_x,
y = train_y
)
surv_coxph_cox_optimizer$execute()
## ------------------------------------------------
## Method `LearnerSurvCoxPHCox$new`
## ------------------------------------------------
LearnerSurvCoxPHCox$new()
[Package mlsurvlrnrs version 0.0.4 Index]