LearnerSurvRpartCox {mlsurvlrnrs} | R Documentation |
LearnerSurvRpartCox R6 class
Description
This learner is a wrapper around rpart::rpart()
in order to fit recursive
partitioning and regression trees with survival data.
Details
Optimization metric: C-index * Can be used with
Implemented methods:
-
$fit
To fit the model. -
$predict
To predict new data with the model. -
$cross_validation
To perform a grid search (hyperparameter optimization). -
$bayesian_scoring_function
To perform a Bayesian hyperparameter optimization.
Parameters that are specified with parameter_grid
and / or learner_args
are forwarded to rpart
's argument control
(see
rpart::rpart.control()
for further details).
Super class
mlexperiments::MLLearnerBase
-> LearnerSurvRpartCox
Methods
Public methods
Inherited methods
Method new()
Create a new LearnerSurvRpartCox
object.
Usage
LearnerSurvRpartCox$new()
Details
This learner is a wrapper around rpart::rpart()
in order to fit
recursive partitioning and regression trees with survival data.
Examples
LearnerSurvRpartCox$new()
Method clone()
The objects of this class are cloneable with this method.
Usage
LearnerSurvRpartCox$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
See Also
rpart::rpart()
, c_index()
,
rpart::rpart.control()
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)]
ncores <- 2L
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_rpart_optimizer <- mlexperiments::MLCrossValidation$new(
learner = LearnerSurvRpartCox$new(),
fold_list = fold_list,
ncores = ncores,
seed = seed
)
surv_rpart_optimizer$learner_args <- list(
minsplit = 10L,
maxdepth = 20L,
cp = 0.03,
method = "exp"
)
surv_rpart_optimizer$performance_metric <- c_index
# set data
surv_rpart_optimizer$set_data(
x = train_x,
y = train_y
)
surv_rpart_optimizer$execute()
## ------------------------------------------------
## Method `LearnerSurvRpartCox$new`
## ------------------------------------------------
LearnerSurvRpartCox$new()