Title: | Probabilistic Supervised Learning for 'mlr3' |
---|---|
Description: | Provides extensions for probabilistic supervised learning for 'mlr3'. This includes extending the regression task to probabilistic and interval regression, adding a survival task, and other specialized models, predictions, and measures. |
Authors: | Raphael Sonabend [aut] , Franz Kiraly [aut], Michel Lang [aut] , Nurul Ain Toha [ctb], Andreas Bender [ctb] , John Zobolas [cre, aut] , Lukas Burk [ctb] , Philip Studener [aut], Maximilian Muecke [ctb] |
Maintainer: | John Zobolas <[email protected]> |
License: | LGPL-3 |
Version: | 0.7.0 |
Built: | 2024-11-21 05:55:23 UTC |
Source: | https://github.com/mlr-org/mlr3proba |
Provides extensions for probabilistic supervised learning for 'mlr3'. This includes extending the regression task to probabilistic and interval regression, adding a survival task, and other specialized models, predictions, and measures.
Maintainer: John Zobolas [email protected] (ORCID)
Authors:
Raphael Sonabend [email protected] (ORCID)
Franz Kiraly [email protected]
Michel Lang [email protected] (ORCID)
Philip Studener [email protected]
Other contributors:
Nurul Ain Toha [email protected] [contributor]
Andreas Bender [email protected] (ORCID) [contributor]
Lukas Burk [email protected] (ORCID) [contributor]
Maximilian Muecke [email protected] (ORCID) [contributor]
Useful links:
Report bugs at https://github.com/mlr-org/mlr3proba/issues
Internal helper function to easily return the correct survival predict types.
.surv_return( times = NULL, surv = NULL, crank = NULL, lp = NULL, response = NULL, which.curve = NULL )
.surv_return( times = NULL, surv = NULL, crank = NULL, lp = NULL, response = NULL, which.curve = NULL )
times |
( |
surv |
( |
crank |
( |
lp |
( |
response |
( |
which.curve |
Which curve (3rd dimension) should the |
Sonabend, Raphael, Bender, Andreas, Vollmer, Sebastian (2022). “Avoiding C-hacking when evaluating survival distribution predictions with discrimination measures.” Bioinformatics. ISSN 1367-4803, doi:10.1093/BIOINFORMATICS/BTAC451, https://academic.oup.com/bioinformatics/advance-article/doi/10.1093/bioinformatics/btac451/6640155.
n = 10 # number of observations k = 50 # time points # Create the matrix with random values between 0 and 1 mat = matrix(runif(n * k, min = 0, max = 1), nrow = n, ncol = k) # transform it to a survival matrix surv_mat = t(apply(mat, 1L, function(row) sort(row, decreasing = TRUE))) # crank is expected mortality, distr is the survival matrix .surv_return(times = 1:k, surv = surv_mat) # if crank is set, it's not overwritten .surv_return(times = 1:k, surv = surv_mat, crank = rnorm(n)) # lp = crank .surv_return(lp = rnorm(n)) # if response is set and no crank, crank = -response .surv_return(response = sample(1:100, n)) # if both are set, they are not overwritten .surv_return(crank = rnorm(n), response = sample(1:100, n))
n = 10 # number of observations k = 50 # time points # Create the matrix with random values between 0 and 1 mat = matrix(runif(n * k, min = 0, max = 1), nrow = n, ncol = k) # transform it to a survival matrix surv_mat = t(apply(mat, 1L, function(row) sort(row, decreasing = TRUE))) # crank is expected mortality, distr is the survival matrix .surv_return(times = 1:k, surv = surv_mat) # if crank is set, it's not overwritten .surv_return(times = 1:k, surv = surv_mat, crank = rnorm(n)) # lp = crank .surv_return(lp = rnorm(n)) # if response is set and no crank, crank = -response .surv_return(response = sample(1:100, n)) # if both are set, they are not overwritten .surv_return(crank = rnorm(n), response = sample(1:100, n))
actg dataset from Hosmer et al. (2008)
actg
actg
Identification Code
Time to AIDS diagnosis or death (days).
Event indicator. 1 = AIDS defining diagnosis, 0 = Otherwise.
Time to death (days)
Event indicator for death (only). 1 = Death, 0 = Otherwise.
Treatment indicator. 1 = Treatment includes IDV, 0 = Control group.
Treatment group indicator. 1 = ZDV + 3TC. 2 = ZDV + 3TC + IDV. 3 = d4T + 3TC. 4 = d4T + 3TC + IDV.
CD4 stratum at screening. 0 = CD4 <= 50. 1 = CD4 > 50.
0 = Male. 1 = Female.
Race/Ethnicity. 1 = White Non-Hispanic. 2 = Black Non-Hispanic. 3 = Hispanic. 4 = Asian, Pacific Islander. 5 = American Indian, Alaskan Native. 6 = Other/unknown.
IV drug use history. 1 = Never. 2 = Currently. 3 = Previously.
Hemophiliac. 1 = Yes. 0 = No.
Karnofsky Performance Scale. 100 = Normal; no complaint no evidence of disease. 90 = Normal activity possible; minor signs/symptoms of disease. 80 = Normal activity with effort; some signs/symptoms of disease. 70 = Cares for self; normal activity/active work not possible.
Baseline CD4 count (Cells/Milliliter).
Months of prior ZDV use (months).
Age at Enrollment (years).
https://onlinelibrary.wiley.com/doi/book/10.1002/9780470258019
Hosmer, D.W. and Lemeshow, S. and May, S. (2008) Applied Survival Analysis: Regression Modeling of Time to Event Data: Second Edition, John Wiley and Sons Inc., New York, NY
Convert object to a PredictionDens.
as_prediction_dens(x, ...) ## S3 method for class 'PredictionDens' as_prediction_dens(x, ...) ## S3 method for class 'data.frame' as_prediction_dens(x, ...)
as_prediction_dens(x, ...) ## S3 method for class 'PredictionDens' as_prediction_dens(x, ...) ## S3 method for class 'data.frame' as_prediction_dens(x, ...)
x |
(any) |
... |
(any) |
library(mlr3) task = tsk("precip") learner = lrn("dens.hist") learner$train(task) p = learner$predict(task) # convert to a data.table tab = as.data.table(p) # convert back to a Prediction as_prediction_dens(tab)
library(mlr3) task = tsk("precip") learner = lrn("dens.hist") learner$train(task) p = learner$predict(task) # convert to a data.table tab = as.data.table(p) # convert back to a Prediction as_prediction_dens(tab)
Convert object to a PredictionSurv.
as_prediction_surv(x, ...) ## S3 method for class 'PredictionSurv' as_prediction_surv(x, ...) ## S3 method for class 'data.frame' as_prediction_surv(x, ...)
as_prediction_surv(x, ...) ## S3 method for class 'PredictionSurv' as_prediction_surv(x, ...) ## S3 method for class 'data.frame' as_prediction_surv(x, ...)
x |
(any) |
... |
(any) |
library(mlr3) task = tsk("rats") learner = lrn("surv.coxph") learner$train(task) p = learner$predict(task) # convert to a data.table tab = as.data.table(p) # convert back to a Prediction as_prediction_surv(tab)
library(mlr3) task = tsk("rats") learner = lrn("surv.coxph") learner$train(task) p = learner$predict(task) # convert to a data.table tab = as.data.table(p) # convert back to a Prediction as_prediction_surv(tab)
Convert object to a density task (TaskDens).
as_task_dens(x, ...) ## S3 method for class 'TaskDens' as_task_dens(x, clone = FALSE, ...) ## S3 method for class 'data.frame' as_task_dens(x, id = deparse(substitute(x)), ...) ## S3 method for class 'DataBackend' as_task_dens(x, id = deparse(substitute(x)), ...)
as_task_dens(x, ...) ## S3 method for class 'TaskDens' as_task_dens(x, clone = FALSE, ...) ## S3 method for class 'data.frame' as_task_dens(x, id = deparse(substitute(x)), ...) ## S3 method for class 'DataBackend' as_task_dens(x, id = deparse(substitute(x)), ...)
x |
( |
... |
( |
clone |
( |
id |
( |
Convert object to a survival task (TaskSurv).
as_task_surv(x, ...) ## S3 method for class 'TaskSurv' as_task_surv(x, clone = FALSE, ...) ## S3 method for class 'data.frame' as_task_surv( x, time = "time", event = "event", time2, type = "right", id = deparse(substitute(x)), ... ) ## S3 method for class 'DataBackend' as_task_surv( x, time = "time", event = "event", time2, type = "right", id = deparse(substitute(x)), ... ) ## S3 method for class 'formula' as_task_surv(x, data, id = deparse(substitute(data)), ...)
as_task_surv(x, ...) ## S3 method for class 'TaskSurv' as_task_surv(x, clone = FALSE, ...) ## S3 method for class 'data.frame' as_task_surv( x, time = "time", event = "event", time2, type = "right", id = deparse(substitute(x)), ... ) ## S3 method for class 'DataBackend' as_task_surv( x, time = "time", event = "event", time2, type = "right", id = deparse(substitute(x)), ... ) ## S3 method for class 'formula' as_task_surv(x, data, id = deparse(substitute(data)), ...)
x |
( |
... |
( |
clone |
( |
time |
( |
event |
( |
time2 |
( |
type |
( |
id |
( |
data |
( |
Asserts x
is a survival::Surv object with added checks
assert_surv( x, len = NULL, any.missing = TRUE, null.ok = FALSE, .var.name = vname(x) )
assert_surv( x, len = NULL, any.missing = TRUE, null.ok = FALSE, .var.name = vname(x) )
x |
Object to check |
len |
If non-NULL checks object is length |
any.missing |
If |
null.ok |
If |
.var.name |
Optional variable name to return if assertion fails |
Asserts if the given input matrix is a (discrete) survival probabilities matrix using Rcpp code. The following checks are performed:
All values are probabilities, i.e.
Column names correspond to time-points and should therefore be coercable to
numeric
and increasing
Per row/observation, the survival probabilities decrease non-strictly, i.e.
assert_surv_matrix(x)
assert_surv_matrix(x)
x |
( |
if the assertion fails an error occurs, otherwise NULL
is returned
invisibly.
x = matrix(data = c(1,0.6,0.4,0.8,0.8,0.7), nrow = 2, ncol = 3, byrow = TRUE) colnames(x) = c(12, 34, 42) x assert_surv_matrix(x)
x = matrix(data = c(1,0.6,0.4,0.8,0.8,0.7), nrow = 2, ncol = 3, byrow = TRUE) colnames(x) = c(12, 34, 42) x assert_surv_matrix(x)
Generates plots for PredictionSurv, depending on argument type
:
"calib"
(default): Calibration plot comparing the average predicted survival distribution
to a Kaplan-Meier prediction, this is not a comparison of a stratified crank
or lp
prediction. object
must have distr
prediction. geom_line()
is used for comparison split
between the prediction (Pred
) and Kaplan-Meier estimate (KM
). In addition labels are added
for the x (T
) and y (S(T)
) axes.
"dcalib"
: Distribution calibration plot. A model is D-calibrated if X% of deaths occur before
the X/100 quantile of the predicted distribution, e.g. if 50% of observations die before their
predicted median survival time. A model is D-calibrated if the resulting plot lies on x = y.
"preds"
: Matplots the survival curves for all predictions
## S3 method for class 'PredictionSurv' autoplot( object, type = "calib", task = NULL, row_ids = NULL, times = NULL, xyline = TRUE, cuts = 11L, theme = theme_minimal(), extend_quantile = FALSE, ... )
## S3 method for class 'PredictionSurv' autoplot( object, type = "calib", task = NULL, row_ids = NULL, times = NULL, xyline = TRUE, cuts = 11L, theme = theme_minimal(), extend_quantile = FALSE, ... )
object |
|
type |
( |
task |
(TaskSurv) |
row_ids |
( |
times |
( |
xyline |
( |
cuts |
( |
theme |
( |
extend_quantile |
|
... |
( |
Haider H, Hoehn B, Davis S, Greiner R (2020). “Effective Ways to Build and Evaluate Individual Survival Distributions.” Journal of Machine Learning Research, 21(85), 1-63. https://jmlr.org/papers/v21/18-772.html.
library(mlr3) library(mlr3proba) library(mlr3viz) learn = lrn("surv.coxph") task = tsk("unemployment") p = learn$train(task, row_ids = 1:300)$predict(task, row_ids = 301:400) # calibration by comparison of average prediction to Kaplan-Meier autoplot(p, type = "calib", task = task, row_ids = 301:400) # Distribution-calibration (D-Calibration) autoplot(p, type = "dcalib") # Predictions autoplot(p, type = "preds")
library(mlr3) library(mlr3proba) library(mlr3viz) learn = lrn("surv.coxph") task = tsk("unemployment") p = learn$train(task, row_ids = 1:300)$predict(task, row_ids = 301:400) # calibration by comparison of average prediction to Kaplan-Meier autoplot(p, type = "calib", task = task, row_ids = 301:400) # Distribution-calibration (D-Calibration) autoplot(p, type = "dcalib") # Predictions autoplot(p, type = "preds")
Generates plots for TaskDens.
## S3 method for class 'TaskDens' autoplot(object, type = "dens", theme = theme_minimal(), ...)
## S3 method for class 'TaskDens' autoplot(object, type = "dens", theme = theme_minimal(), ...)
object |
(TaskDens). |
type |
(
|
theme |
( |
... |
( |
ggplot2::ggplot()
object.
library(mlr3) library(mlr3proba) library(mlr3viz) library(ggplot2) task = tsk("precip") head(fortify(task)) autoplot(task, bins = 15) autoplot(task, type = "freq", bins = 15) autoplot(task, type = "overlay", bins = 15) autoplot(task, type = "freqpoly", bins = 15)
library(mlr3) library(mlr3proba) library(mlr3viz) library(ggplot2) task = tsk("precip") head(fortify(task)) autoplot(task, bins = 15) autoplot(task, type = "freq", bins = 15) autoplot(task, type = "overlay", bins = 15) autoplot(task, type = "freqpoly", bins = 15)
Generates plots for TaskSurv, depending on argument type
:
"target"
: Calls GGally::ggsurv()
on a survival::survfit()
object.
This computes the Kaplan-Meier survival curve for the observations if this task.
"duo"
: Passes data and additional arguments down to GGally::ggduo()
.
columnsX
is target, columnsY
is features.
"pairs"
: Passes data and additional arguments down to
GGally::ggpairs()
.
Color is set to target column.
## S3 method for class 'TaskSurv' autoplot( object, type = "target", theme = theme_minimal(), reverse = FALSE, ... )
## S3 method for class 'TaskSurv' autoplot( object, type = "target", theme = theme_minimal(), reverse = FALSE, ... )
object |
(TaskSurv). |
type |
( |
theme |
( |
reverse |
( |
... |
( |
ggplot2::ggplot()
object.
library(mlr3) library(mlr3viz) library(mlr3proba) library(ggplot2) task = tsk("lung") head(fortify(task)) autoplot(task) # KM autoplot(task) # KM of the censoring distribution autoplot(task, rhs = "sex") autoplot(task, type = "duo")
library(mlr3) library(mlr3viz) library(mlr3proba) library(ggplot2) task = tsk("lung") head(fortify(task)) autoplot(task) # KM autoplot(task) # KM of the censoring distribution autoplot(task, rhs = "sex") autoplot(task, type = "duo")
Helper function to compose a survival distribution (or cumulative hazard)
from the relative risk predictions (linear predictors, lp
) of a
proportional hazards model (e.g. a Cox-type model).
breslow(times, status, lp_train, lp_test, eval_times = NULL, type = "surv")
breslow(times, status, lp_train, lp_test, eval_times = NULL, type = "surv")
times |
( |
status |
( |
lp_train |
( |
lp_test |
( |
eval_times |
( |
type |
( |
We estimate the survival probability of individual (from the test set),
at time point
as follows:
where:
is the cumulative hazard function for individual
is Breslow's estimator for the cumulative baseline
hazard. Estimation requires the training set's
times
and status
as well
the risk predictions (lp_train
).
is the risk prediction (linear predictor) of individual
on the test set.
Breslow's approach uses a non-parametric maximum likelihood estimation of the cumulative baseline hazard function:
where:
is the vector of time points (unique and sorted, from the train set)
is number of events (train set)
is the vector of event times (train set)
is the status indicator (1 = event or 0 = censored)
is the risk set (number of individuals at risk just before
event
)
is the risk prediction (linear predictor) of individual
(who is part of the risk set
) on the train set.
We employ constant interpolation to estimate the cumulative baseline hazards,
extending from the observed unique event times to the specified evaluation
times (eval_times
).
Any values falling outside the range of the estimated times are assigned as
follows:
and
Note that in the rare event of lp
predictions being Inf
or -Inf
, the
resulting cumulative hazard values become NaN
, which we substitute with
Inf
(and corresponding survival probabilities take the value of ).
For similar implementations, see gbm::basehaz.gbm()
, C060::basesurv()
and
xgboost.surv::sgb_bhaz()
.
a matrix
(obs x times). Number of columns is equal to eval_times
and number of rows is equal to the number of test observations (i.e. the
length of the lp_test
vector). Depending on the type
argument, the matrix
can have either survival probabilities (0-1) or cumulative hazard estimates
(0-Inf
).
Cox DR (1972). “Regression Models and Life-Tables.” Journal of the Royal Statistical Society: Series B (Methodological), 34(2), 187–202. doi:10.1111/j.2517-6161.1972.tb00899.x.
Lin, Y. D (2007). “On the Breslow estimator.” Lifetime Data Analysis, 13(4), 471-480. doi:10.1007/s10985-007-9048-y.
task = tsk("rats") part = partition(task, ratio = 0.8) learner = lrn("surv.coxph") learner$train(task, part$train) p_train = learner$predict(task, part$train) p_test = learner$predict(task, part$test) surv = breslow(times = task$times(part$train), status = task$status(part$train), lp_train = p_train$lp, lp_test = p_test$lp) head(surv)
task = tsk("rats") part = partition(task, ratio = 0.8) learner = lrn("surv.coxph") learner$train(task, part$train) p_train = learner$predict(task, part$train) p_test = learner$predict(task, part$test) surv = breslow(times = task$times(part$train), status = task$status(part$train), lp_train = p_train$lp, lp_test = p_test$lp) head(surv)
gbcs dataset from Hosmer et al. (2008)
gbcs
gbcs
Identification Code
Date of diagnosis.
Date of recurrence free survival.
Date of death.
Age at diagnosis (years).
Menopausal status. 1 = Yes, 0 = No.
Hormone therapy. 1 = Yes. 0 = No.
Tumor size (mm).
Tumor grade (1-3).
Number of lymph nodes.
Number of progesterone receptors.
Number of estrogen receptors.
Time to recurrence (days).
Recurrence status. 1 = Recurrence. 0 = Censored.
Time to death (days).
Censoring status. 1 = Death. 0 = Censored.
https://onlinelibrary.wiley.com/doi/book/10.1002/9780470258019
Hosmer, D.W. and Lemeshow, S. and May, S. (2008) Applied Survival Analysis: Regression Modeling of Time to Event Data: Second Edition, John Wiley and Sons Inc., New York, NY
Many methods can be used to reduce a discrete survival distribution prediction (i.e. matrix) to a relative risk / ranking prediction, see Sonabend et al. (2022).
This function calculates a relative risk score as the sum of the predicted cumulative hazard function, also called ensemble/expected mortality. This risk score can be loosely interpreted as the expected number of deaths for patients with similar characteristics, see Ishwaran et al. (2008) and has no model or survival distribution assumptions.
get_mortality(x)
get_mortality(x)
x |
( |
a numeric
vector of the mortality risk scores, one per row of the
input survival matrix.
Sonabend, Raphael, Bender, Andreas, Vollmer, Sebastian (2022). “Avoiding C-hacking when evaluating survival distribution predictions with discrimination measures.” Bioinformatics. ISSN 1367-4803, doi:10.1093/BIOINFORMATICS/BTAC451, https://academic.oup.com/bioinformatics/advance-article/doi/10.1093/bioinformatics/btac451/6640155.
Ishwaran, Hemant, Kogalur, B U, Blackstone, H E, Lauer, S M, others (2008). “Random survival forests.” The Annals of applied statistics, 2(3), 841–860.
n = 10 # number of observations k = 50 # time points # Create the matrix with random values between 0 and 1 mat = matrix(runif(n * k, min = 0, max = 1), nrow = n, ncol = k) # transform it to a survival matrix surv_mat = t(apply(mat, 1L, function(row) sort(row, decreasing = TRUE))) colnames(surv_mat) = 1:k # time points # get mortality scores (the larger, the more risk) mort = get_mortality(surv_mat) mort
n = 10 # number of observations k = 50 # time points # Create the matrix with random values between 0 and 1 mat = matrix(runif(n * k, min = 0, max = 1), nrow = n, ncol = k) # transform it to a survival matrix surv_mat = t(apply(mat, 1L, function(row) sort(row, decreasing = TRUE))) colnames(surv_mat) = 1:k # time points # get mortality scores (the larger, the more risk) mort = get_mortality(surv_mat) mort
grace dataset from Hosmer et al. (2008)
grace
grace
Identification Code
Follow up time.
Censoring indicator. 1 = Death. 0 = Censored.
Revascularization Performed. 1 = Yes. 0 = No.
Days to revascularization after admission.
Length of hospital stay (days).
Age at admission (years).
Systolic blood pressure on admission (mm Hg).
ST-segment deviation on index ECG. 1 = Yes. 0 = No.
https://onlinelibrary.wiley.com/doi/book/10.1002/9780470258019
Hosmer, D.W. and Lemeshow, S. and May, S. (2008) Applied Survival Analysis: Regression Modeling of Time to Event Data: Second Edition, John Wiley and Sons Inc., New York, NY
This Learner specializes Learner for density estimation problems:
task_type
is set to "dens"
Creates Predictions of class PredictionDens.
Possible values for predict_types
are:
"pdf"
: Evaluates estimated probability density function for each value in the test set.
"cdf"
: Evaluates estimated cumulative distribution function for each value in the test set.
mlr3::Learner
-> LearnerDens
new()
Creates a new instance of this R6 class.
LearnerDens$new( id, param_set = ps(), predict_types = "cdf", feature_types = character(), properties = character(), packages = character(), label = NA_character_, man = NA_character_ )
id
(character(1)
)
Identifier for the new instance.
param_set
(paradox::ParamSet)
Set of hyperparameters.
predict_types
(character()
)
Supported predict types. Must be a subset of mlr_reflections$learner_predict_types
.
feature_types
(character()
)
Feature types the learner operates on. Must be a subset of mlr_reflections$task_feature_types
.
properties
(character()
)
Set of properties of the Learner.
Must be a subset of mlr_reflections$learner_properties
.
The following properties are currently standardized and understood by learners in mlr3:
"missings"
: The learner can handle missing values in the data.
"weights"
: The learner supports observation weights.
"importance"
: The learner supports extraction of importance scores, i.e. comes with an $importance()
extractor function (see section on optional extractors in Learner).
"selected_features"
: The learner supports extraction of the set of selected features, i.e. comes with a $selected_features()
extractor function (see section on optional extractors in Learner).
"oob_error"
: The learner supports extraction of estimated out of bag error, i.e. comes with a oob_error()
extractor function (see section on optional extractors in Learner).
packages
(character()
)
Set of required packages.
A warning is signaled by the constructor if at least one of the packages is not installed,
but loaded (not attached) later on-demand via requireNamespace()
.
label
(character(1)
)
Label for the new instance.
man
(character(1)
)
String in the format [pkg]::[topic]
pointing to a manual page for this object.
The referenced help package can be opened via method $help()
.
clone()
The objects of this class are cloneable with this method.
LearnerDens$clone(deep = FALSE)
deep
Whether to make a deep clone.
Other Learner:
LearnerSurv
library(mlr3) # get all density learners from mlr_learners: lrns = mlr_learners$mget(mlr_learners$keys("^dens")) names(lrns) # get a specific learner from mlr_learners: mlr_learners$get("dens.hist") lrn("dens.hist")
library(mlr3) # get all density learners from mlr_learners: lrns = mlr_learners$mget(mlr_learners$keys("^dens")) names(lrns) # get a specific learner from mlr_learners: mlr_learners$get("dens.hist") lrn("dens.hist")
This Learner specializes Learner for survival problems:
task_type
is set to "surv"
Creates Predictions of class PredictionSurv.
Possible values for predict_types
are:
"distr"
: Predicts a probability distribution for each observation in the test set,
uses distr6.
"lp"
: Predicts a linear predictor for each observation in the test set.
"crank"
: Predicts a continuous ranking for each observation in the test set.
"response"
: Predicts a survival time for each observation in the test set.
mlr3::Learner
-> LearnerSurv
new()
Creates a new instance of this R6 class.
LearnerSurv$new( id, param_set = ps(), predict_types = "distr", feature_types = character(), properties = character(), packages = character(), label = NA_character_, man = NA_character_ )
id
(character(1)
)
Identifier for the new instance.
param_set
(paradox::ParamSet)
Set of hyperparameters.
predict_types
(character()
)
Supported predict types. Must be a subset of mlr_reflections$learner_predict_types
.
feature_types
(character()
)
Feature types the learner operates on. Must be a subset of mlr_reflections$task_feature_types
.
properties
(character()
)
Set of properties of the Learner.
Must be a subset of mlr_reflections$learner_properties
.
The following properties are currently standardized and understood by learners in mlr3:
"missings"
: The learner can handle missing values in the data.
"weights"
: The learner supports observation weights.
"importance"
: The learner supports extraction of importance scores, i.e. comes with an $importance()
extractor function (see section on optional extractors in Learner).
"selected_features"
: The learner supports extraction of the set of selected features, i.e. comes with a $selected_features()
extractor function (see section on optional extractors in Learner).
"oob_error"
: The learner supports extraction of estimated out of bag error, i.e. comes with a oob_error()
extractor function (see section on optional extractors in Learner).
packages
(character()
)
Set of required packages.
A warning is signaled by the constructor if at least one of the packages is not installed,
but loaded (not attached) later on-demand via requireNamespace()
.
label
(character(1)
)
Label for the new instance.
man
(character(1)
)
String in the format [pkg]::[topic]
pointing to a manual page for this object.
The referenced help package can be opened via method $help()
.
clone()
The objects of this class are cloneable with this method.
LearnerSurv$clone(deep = FALSE)
deep
Whether to make a deep clone.
Other Learner:
LearnerDens
library(mlr3) # get all survival learners from mlr_learners: lrns = mlr_learners$mget(mlr_learners$keys("^surv")) names(lrns) # get a specific learner from mlr_learners: mlr_learners$get("surv.coxph") lrn("surv.coxph")
library(mlr3) # get all survival learners from mlr_learners: lrns = mlr_learners$mget(mlr_learners$keys("^surv")) names(lrns) # get a specific learner from mlr_learners: mlr_learners$get("surv.coxph") lrn("surv.coxph")
This measure specializes Measure for survival problems.
task_type
is set to "dens"
.
Possible values for predict_type
are "pdf"
and "cdf"
.
Predefined measures can be found in the dictionary mlr3::mlr_measures.
mlr3::Measure
-> MeasureDens
new()
Creates a new instance of this R6 class.
MeasureDens$new( id, param_set = ps(), range, minimize = NA, aggregator = NULL, properties = character(), predict_type = "pdf", task_properties = character(), packages = character(), label = NA_character_, man = NA_character_ )
id
(character(1)
)
Identifier for the new instance.
param_set
(paradox::ParamSet)
Set of hyperparameters.
range
(numeric(2)
)
Feasible range for this measure as c(lower_bound, upper_bound)
.
Both bounds may be infinite.
minimize
(logical(1)
)
Set to TRUE
if good predictions correspond to small values,
and to FALSE
if good predictions correspond to large values.
If set to NA
(default), tuning this measure is not possible.
aggregator
(function(x)
)
Function to aggregate individual performance scores x
where x
is a numeric vector.
If NULL
, defaults to mean()
.
properties
(character()
)
Properties of the measure.
Must be a subset of mlr_reflections$measure_properties.
Supported by mlr3
:
"requires_task"
(requires the complete Task),
"requires_learner"
(requires the trained Learner),
"requires_train_set"
(requires the training indices from the Resampling), and
"na_score"
(the measure is expected to occasionally return NA
or NaN
).
predict_type
(character(1)
)
Required predict type of the Learner.
Possible values are stored in mlr_reflections$learner_predict_types.
task_properties
(character()
)
Required task properties, see Task.
packages
(character()
)
Set of required packages.
A warning is signaled by the constructor if at least one of the packages is not installed,
but loaded (not attached) later on-demand via requireNamespace()
.
label
(character(1)
)
Label for the new instance.
man
(character(1)
)
String in the format [pkg]::[topic]
pointing to a manual page for this object.
The referenced help package can be opened via method $help()
.
Default density measures: dens.logloss
Other Measure:
MeasureSurv
This measure specializes Measure for survival problems.
task_type
is set to "surv"
.
Possible values for predict_type
are "distr"
, "lp"
, "crank"
, and "response"
.
Predefined measures can be found in the dictionary mlr3::mlr_measures.
mlr3::Measure
-> MeasureSurv
new()
Creates a new instance of this R6 class.
MeasureSurv$new( id, param_set = ps(), range, minimize = NA, aggregator = NULL, properties = character(), predict_type = "distr", task_properties = character(), packages = character(), label = NA_character_, man = NA_character_, se = FALSE )
id
(character(1)
)
Identifier for the new instance.
param_set
(paradox::ParamSet)
Set of hyperparameters.
range
(numeric(2)
)
Feasible range for this measure as c(lower_bound, upper_bound)
.
Both bounds may be infinite.
minimize
(logical(1)
)
Set to TRUE
if good predictions correspond to small values,
and to FALSE
if good predictions correspond to large values.
If set to NA
(default), tuning this measure is not possible.
aggregator
(function(x)
)
Function to aggregate individual performance scores x
where x
is a numeric vector.
If NULL
, defaults to mean()
.
properties
(character()
)
Properties of the measure.
Must be a subset of mlr_reflections$measure_properties.
Supported by mlr3
:
"requires_task"
(requires the complete Task),
"requires_learner"
(requires the trained Learner),
"requires_train_set"
(requires the training indices from the Resampling), and
"na_score"
(the measure is expected to occasionally return NA
or NaN
).
predict_type
(character(1)
)
Required predict type of the Learner.
Possible values are stored in mlr_reflections$learner_predict_types.
task_properties
(character()
)
Required task properties, see Task.
packages
(character()
)
Set of required packages.
A warning is signaled by the constructor if at least one of the packages is not installed,
but loaded (not attached) later on-demand via requireNamespace()
.
label
(character(1)
)
Label for the new instance.
man
(character(1)
)
String in the format [pkg]::[topic]
pointing to a manual page for this object.
The referenced help package can be opened via method $help()
.
se
If TRUE
then returns standard error of the
measure otherwise returns the mean (default).
print()
Printer.
MeasureSurv$print()
Default survival measures: surv.cindex
Other Measure:
MeasureDens
This is an abstract class that should not be constructed directly.
integrated
(logical(1)
)
If TRUE
(default), returns the integrated score (eg across
time points); otherwise, not integrated (eg at a single time point).
times
(numeric()
)
If integrated == TRUE
then a vector of time-points over which to integrate the score.
If integrated == FALSE
then a single time point at which to return the score.
mlr3::Measure
-> mlr3proba::MeasureSurv
-> MeasureSurvAUC
new()
Creates a new instance of this R6 class.
MeasureSurvAUC$new( id, properties = character(), label = NA_character_, man = NA_character_, param_set = ps() )
id
(character(1)
)
Identifier for the new instance.
properties
(character()
)
Properties of the measure.
Must be a subset of mlr_reflections$measure_properties.
Supported by mlr3
:
"requires_task"
(requires the complete Task),
"requires_learner"
(requires the trained Learner),
"requires_train_set"
(requires the training indices from the Resampling), and
"na_score"
(the measure is expected to occasionally return NA
or NaN
).
label
(character(1)
)
Label for the new instance.
man
(character(1)
)
String in the format [pkg]::[topic]
pointing to a manual page for this object.
The referenced help package can be opened via method $help()
.
param_set
(paradox::ParamSet)
Set of hyperparameters.
clone()
The objects of this class are cloneable with this method.
MeasureSurvAUC$clone(deep = FALSE)
deep
Whether to make a deep clone.
Wrapper around PipeOpCrankCompositor to simplify Graph creation.
pipeline_crankcompositor( learner, method = c("mort"), overwrite = FALSE, graph_learner = FALSE )
pipeline_crankcompositor( learner, method = c("mort"), overwrite = FALSE, graph_learner = FALSE )
learner |
|
method |
( |
overwrite |
( |
graph_learner |
( |
mlr3pipelines::Graph or mlr3pipelines::GraphLearner
This Graph can be instantiated via the dictionary mlr_graphs or with the associated sugar function ppl():
mlr_graphs$get("crankcompositor") ppl("crankcompositor")
Other pipelines:
mlr_graphs_distrcompositor
,
mlr_graphs_probregr
,
mlr_graphs_responsecompositor
,
mlr_graphs_survaverager
,
mlr_graphs_survbagging
,
mlr_graphs_survtoclassif_IPCW
,
mlr_graphs_survtoclassif_disctime
## Not run: library(mlr3) library(mlr3pipelines) task = tsk("lung") part = partition(task) # change the crank prediction type of a Cox's model predictions grlrn = ppl( "crankcompositor", learner = lrn("surv.coxph"), method = "mort", overwrite = TRUE, graph_learner = TRUE ) grlrn$train(task, part$train) grlrn$predict(task, part$test) ## End(Not run)
## Not run: library(mlr3) library(mlr3pipelines) task = tsk("lung") part = partition(task) # change the crank prediction type of a Cox's model predictions grlrn = ppl( "crankcompositor", learner = lrn("surv.coxph"), method = "mort", overwrite = TRUE, graph_learner = TRUE ) grlrn$train(task, part$train) grlrn$predict(task, part$test) ## End(Not run)
Wrapper around PipeOpDistrCompositor or PipeOpBreslow to simplify Graph creation.
pipeline_distrcompositor( learner, estimator = "kaplan", form = "aft", overwrite = FALSE, scale_lp = FALSE, graph_learner = FALSE )
pipeline_distrcompositor( learner, estimator = "kaplan", form = "aft", overwrite = FALSE, scale_lp = FALSE, graph_learner = FALSE )
learner |
|
estimator |
( |
form |
( |
overwrite |
( |
scale_lp |
( |
graph_learner |
( |
mlr3pipelines::Graph or mlr3pipelines::GraphLearner
This Graph can be instantiated via the dictionary mlr_graphs or with the associated sugar function ppl():
mlr_graphs$get("distrcompositor") ppl("distrcompositor")
Other pipelines:
mlr_graphs_crankcompositor
,
mlr_graphs_probregr
,
mlr_graphs_responsecompositor
,
mlr_graphs_survaverager
,
mlr_graphs_survbagging
,
mlr_graphs_survtoclassif_IPCW
,
mlr_graphs_survtoclassif_disctime
## Not run: library(mlr3pipelines) # let's change the distribution prediction of Cox (Breslow-based) to an AFT form: task = tsk("rats") grlrn = ppl( "distrcompositor", learner = lrn("surv.coxph"), estimator = "kaplan", form = "aft", overwrite = TRUE, graph_learner = TRUE ) grlrn$train(task) grlrn$predict(task) ## End(Not run)
## Not run: library(mlr3pipelines) # let's change the distribution prediction of Cox (Breslow-based) to an AFT form: task = tsk("rats") grlrn = ppl( "distrcompositor", learner = lrn("surv.coxph"), estimator = "kaplan", form = "aft", overwrite = TRUE, graph_learner = TRUE ) grlrn$train(task) grlrn$predict(task) ## End(Not run)
Wrapper around PipeOpProbregr to simplify Graph creation.
pipeline_probregr( learner, learner_se = NULL, dist = "Uniform", graph_learner = FALSE )
pipeline_probregr( learner, learner_se = NULL, dist = "Uniform", graph_learner = FALSE )
learner |
|
learner_se |
|
dist |
( |
graph_learner |
( |
mlr3pipelines::Graph or mlr3pipelines::GraphLearner
This Graph can be instantiated via the dictionary mlr_graphs or with the associated sugar function ppl():
mlr_graphs$get("probregr") ppl("probregr")
Other pipelines:
mlr_graphs_crankcompositor
,
mlr_graphs_distrcompositor
,
mlr_graphs_responsecompositor
,
mlr_graphs_survaverager
,
mlr_graphs_survbagging
,
mlr_graphs_survtoclassif_IPCW
,
mlr_graphs_survtoclassif_disctime
## Not run: library(mlr3) library(mlr3pipelines) task = tsk("boston_housing") # method 1 - same learner for response and se pipe = ppl( "probregr", learner = lrn("regr.featureless", predict_type = "se"), dist = "Uniform" ) pipe$train(task) pipe$predict(task) # method 2 - different learners for response and se pipe = ppl( "probregr", learner = lrn("regr.rpart"), learner_se = lrn("regr.featureless", predict_type = "se"), dist = "Normal" ) pipe$train(task) pipe$predict(task) ## End(Not run)
## Not run: library(mlr3) library(mlr3pipelines) task = tsk("boston_housing") # method 1 - same learner for response and se pipe = ppl( "probregr", learner = lrn("regr.featureless", predict_type = "se"), dist = "Uniform" ) pipe$train(task) pipe$predict(task) # method 2 - different learners for response and se pipe = ppl( "probregr", learner = lrn("regr.rpart"), learner_se = lrn("regr.featureless", predict_type = "se"), dist = "Normal" ) pipe$train(task) pipe$predict(task) ## End(Not run)
Wrapper around PipeOpResponseCompositor to simplify Graph creation.
pipeline_responsecompositor( learner, method = "rmst", tau = NULL, add_crank = FALSE, overwrite = FALSE, graph_learner = FALSE )
pipeline_responsecompositor( learner, method = "rmst", tau = NULL, add_crank = FALSE, overwrite = FALSE, graph_learner = FALSE )
learner |
|
method |
( |
tau |
( |
add_crank |
( |
overwrite |
( |
graph_learner |
( |
mlr3pipelines::Graph or mlr3pipelines::GraphLearner
This Graph can be instantiated via the dictionary mlr_graphs or with the associated sugar function ppl():
mlr_graphs$get("responsecompositor") ppl("responsecompositor")
Other pipelines:
mlr_graphs_crankcompositor
,
mlr_graphs_distrcompositor
,
mlr_graphs_probregr
,
mlr_graphs_survaverager
,
mlr_graphs_survbagging
,
mlr_graphs_survtoclassif_IPCW
,
mlr_graphs_survtoclassif_disctime
## Not run: library(mlr3) library(mlr3pipelines) task = tsk("lung") part = partition(task) # add survival time prediction type to the predictions of a Cox model grlrn = ppl( "responsecompositor", learner = lrn("surv.coxph"), method = "rmst", overwrite = TRUE, graph_learner = TRUE ) grlrn$train(task, part$train) grlrn$predict(task, part$test) ## End(Not run)
## Not run: library(mlr3) library(mlr3pipelines) task = tsk("lung") part = partition(task) # add survival time prediction type to the predictions of a Cox model grlrn = ppl( "responsecompositor", learner = lrn("surv.coxph"), method = "rmst", overwrite = TRUE, graph_learner = TRUE ) grlrn$train(task, part$train) grlrn$predict(task, part$test) ## End(Not run)
Wrapper around PipeOpSurvAvg to simplify Graph creation.
pipeline_survaverager(learners, param_vals = list(), graph_learner = FALSE)
pipeline_survaverager(learners, param_vals = list(), graph_learner = FALSE)
learners |
|
param_vals |
|
graph_learner |
( |
mlr3pipelines::Graph or mlr3pipelines::GraphLearner
This Graph can be instantiated via the dictionary mlr_graphs or with the associated sugar function ppl():
mlr_graphs$get("survaverager") ppl("survaverager")
Other pipelines:
mlr_graphs_crankcompositor
,
mlr_graphs_distrcompositor
,
mlr_graphs_probregr
,
mlr_graphs_responsecompositor
,
mlr_graphs_survbagging
,
mlr_graphs_survtoclassif_IPCW
,
mlr_graphs_survtoclassif_disctime
## Not run: library(mlr3) library(mlr3pipelines) task = tsk("rats") pipe = ppl( "survaverager", learners = lrns(c("surv.kaplan", "surv.coxph")), param_vals = list(weights = c(0.1, 0.9)), graph_learner = FALSE ) pipe$train(task) pipe$predict(task) ## End(Not run)
## Not run: library(mlr3) library(mlr3pipelines) task = tsk("rats") pipe = ppl( "survaverager", learners = lrns(c("surv.kaplan", "surv.coxph")), param_vals = list(weights = c(0.1, 0.9)), graph_learner = FALSE ) pipe$train(task) pipe$predict(task) ## End(Not run)
Wrapper around PipeOpSubsample and PipeOpSurvAvg to simplify Graph creation.
pipeline_survbagging( learner, iterations = 10, frac = 0.7, avg = TRUE, weights = 1, graph_learner = FALSE )
pipeline_survbagging( learner, iterations = 10, frac = 0.7, avg = TRUE, weights = 1, graph_learner = FALSE )
learner |
|
iterations |
( |
frac |
( |
avg |
( |
weights |
( |
graph_learner |
( |
Bagging (Bootstrap AGGregatING) is the process of bootstrapping data and aggregating
the final predictions. Bootstrapping splits the data into B
smaller datasets of a given size
and is performed with PipeOpSubsample. Aggregation is
the sample mean of deterministic predictions and a
MixtureDistribution of distribution predictions. This can be
further enhanced by using a weighted average by supplying weights
.
mlr3pipelines::Graph or mlr3pipelines::GraphLearner
This Graph can be instantiated via the dictionary mlr_graphs or with the associated sugar function ppl():
mlr_graphs$get("survbagging") ppl("survbagging")
Other pipelines:
mlr_graphs_crankcompositor
,
mlr_graphs_distrcompositor
,
mlr_graphs_probregr
,
mlr_graphs_responsecompositor
,
mlr_graphs_survaverager
,
mlr_graphs_survtoclassif_IPCW
,
mlr_graphs_survtoclassif_disctime
## Not run: library(mlr3) library(mlr3pipelines) task = tsk("rats") pipe = ppl( "survbagging", learner = lrn("surv.coxph"), iterations = 5, graph_learner = FALSE ) pipe$train(task) pipe$predict(task) ## End(Not run)
## Not run: library(mlr3) library(mlr3pipelines) task = tsk("rats") pipe = ppl( "survbagging", learner = lrn("surv.coxph"), iterations = 5, graph_learner = FALSE ) pipe$train(task) pipe$predict(task) ## End(Not run)
Wrapper around PipeOpTaskSurvClassifDiscTime and PipeOpPredClassifSurvDiscTime to simplify Graph creation.
pipeline_survtoclassif_disctime( learner, cut = NULL, max_time = NULL, rhs = NULL, graph_learner = FALSE )
pipeline_survtoclassif_disctime( learner, cut = NULL, max_time = NULL, rhs = NULL, graph_learner = FALSE )
learner |
LearnerClassif |
cut |
( |
max_time |
( |
rhs |
( |
graph_learner |
( |
The pipeline consists of the following steps:
PipeOpTaskSurvClassifDiscTime Converts TaskSurv to a TaskClassif.
A LearnerClassif is fit and predicted on the new TaskClassif
.
PipeOpPredClassifSurvDiscTime transforms the resulting PredictionClassif to PredictionSurv.
Optionally: PipeOpModelMatrix is used to transform the formula of the task before fitting the learner.
mlr3pipelines::Graph or mlr3pipelines::GraphLearner
This Graph can be instantiated via the dictionary mlr_graphs or with the associated sugar function ppl():
mlr_graphs$get("survtoclassif_disctime") ppl("survtoclassif_disctime")
Tutz, Gerhard, Schmid, Matthias (2016). Modeling Discrete Time-to-Event Data, series Springer Series in Statistics. Springer International Publishing. ISBN 978-3-319-28156-8 978-3-319-28158-2, http://link.springer.com/10.1007/978-3-319-28158-2.
Other pipelines:
mlr_graphs_crankcompositor
,
mlr_graphs_distrcompositor
,
mlr_graphs_probregr
,
mlr_graphs_responsecompositor
,
mlr_graphs_survaverager
,
mlr_graphs_survbagging
,
mlr_graphs_survtoclassif_IPCW
## Not run: library(mlr3) library(mlr3learners) library(mlr3pipelines) task = tsk("lung") part = partition(task) grlrn = ppl( "survtoclassif_disctime", learner = lrn("classif.log_reg"), cut = 4, # 4 equidistant time intervals graph_learner = TRUE ) grlrn$train(task, row_ids = part$train) grlrn$predict(task, row_ids = part$test) ## End(Not run)
## Not run: library(mlr3) library(mlr3learners) library(mlr3pipelines) task = tsk("lung") part = partition(task) grlrn = ppl( "survtoclassif_disctime", learner = lrn("classif.log_reg"), cut = 4, # 4 equidistant time intervals graph_learner = TRUE ) grlrn$train(task, row_ids = part$train) grlrn$predict(task, row_ids = part$test) ## End(Not run)
Wrapper around PipeOpTaskSurvClassifIPCW and PipeOpPredClassifSurvIPCW to simplify Graph creation.
pipeline_survtoclassif_IPCW( learner, tau = NULL, eps = 0.001, graph_learner = FALSE )
pipeline_survtoclassif_IPCW( learner, tau = NULL, eps = 0.001, graph_learner = FALSE )
learner |
LearnerClassif |
tau |
( |
eps |
( |
graph_learner |
( |
The pipeline consists of the following steps:
PipeOpTaskSurvClassifIPCW Converts TaskSurv to a TaskClassif.
A LearnerClassif is fit and predicted on the new TaskClassif
.
PipeOpPredClassifSurvIPCW transforms the resulting PredictionClassif to PredictionSurv.
mlr3pipelines::Graph or mlr3pipelines::GraphLearner
This Graph can be instantiated via the dictionary mlr_graphs or with the associated sugar function ppl():
mlr_graphs$get("survtoclassif_IPCW") ppl("survtoclassif_IPCW")
Additional alias id for pipeline construction:
ppl("survtoclassif_vock")
Vock, M D, Wolfson, Julian, Bandyopadhyay, Sunayan, Adomavicius, Gediminas, Johnson, E P, Vazquez-Benitez, Gabriela, O'Connor, J P (2016). “Adapting machine learning techniques to censored time-to-event health record data: A general-purpose approach using inverse probability of censoring weighting.” Journal of Biomedical Informatics, 61, 119–131. doi:10.1016/j.jbi.2016.03.009, https://www.sciencedirect.com/science/article/pii/S1532046416000496.
Other pipelines:
mlr_graphs_crankcompositor
,
mlr_graphs_distrcompositor
,
mlr_graphs_probregr
,
mlr_graphs_responsecompositor
,
mlr_graphs_survaverager
,
mlr_graphs_survbagging
,
mlr_graphs_survtoclassif_disctime
## Not run: library(mlr3) library(mlr3learners) library(mlr3pipelines) task = tsk("lung") part = partition(task) grlrn = ppl( "survtoclassif_IPCW", learner = lrn("classif.rpart"), tau = 500, # Observations after 500 days are censored graph_learner = TRUE ) grlrn$train(task, row_ids = part$train) pred = grlrn$predict(task, row_ids = part$test) pred # crank and distr at the cutoff time point included # score predictions pred$score() # C-index pred$score(msr("surv.brier", times = 500, integrated = FALSE)) # Brier score at tau ## End(Not run)
## Not run: library(mlr3) library(mlr3learners) library(mlr3pipelines) task = tsk("lung") part = partition(task) grlrn = ppl( "survtoclassif_IPCW", learner = lrn("classif.rpart"), tau = 500, # Observations after 500 days are censored graph_learner = TRUE ) grlrn$train(task, row_ids = part$train) pred = grlrn$predict(task, row_ids = part$test) pred # crank and distr at the cutoff time point included # score predictions pred$score() # C-index pred$score(msr("surv.brier", times = 500, integrated = FALSE)) # Brier score at tau ## End(Not run)
Wrapper around multiple PipeOps to help in creation of complex survival reduction methods. Three reductions are currently implemented, see details.
pipeline_survtoregr( method = 1, regr_learner = lrn("regr.featureless"), distrcompose = TRUE, distr_estimator = lrn("surv.kaplan"), regr_se_learner = NULL, surv_learner = lrn("surv.coxph"), survregr_params = list(method = "ipcw", estimator = "kaplan", alpha = 1), distrcompose_params = list(form = "aft"), probregr_params = list(dist = "Uniform"), learnercv_params = list(resampling.method = "insample"), graph_learner = FALSE )
pipeline_survtoregr( method = 1, regr_learner = lrn("regr.featureless"), distrcompose = TRUE, distr_estimator = lrn("surv.kaplan"), regr_se_learner = NULL, surv_learner = lrn("surv.coxph"), survregr_params = list(method = "ipcw", estimator = "kaplan", alpha = 1), distrcompose_params = list(form = "aft"), probregr_params = list(dist = "Uniform"), learnercv_params = list(resampling.method = "insample"), graph_learner = FALSE )
method |
( |
regr_learner |
LearnerRegr |
distrcompose |
( |
distr_estimator |
LearnerSurv |
regr_se_learner |
LearnerRegr |
surv_learner |
LearnerSurv |
survregr_params |
( |
distrcompose_params |
( |
probregr_params |
( |
learnercv_params |
( |
graph_learner |
( |
Three reduction strategies are implemented, these are:
Survival to Deterministic Regression A
PipeOpTaskSurvRegr Converts TaskSurv to TaskRegr.
A LearnerRegr is fit and predicted on the new TaskRegr
.
PipeOpPredRegrSurv transforms the resulting PredictionRegr to PredictionSurv.
Survival to Probabilistic Regression
PipeOpTaskSurvRegr Converts TaskSurv to TaskRegr.
A LearnerRegr is fit on the new TaskRegr
to predict response
, optionally a second
LearnerRegr
can be fit to predict se
.
PipeOpProbregr composes a distr
prediction from the learner(s).
PipeOpPredRegrSurv transforms the resulting PredictionRegr to PredictionSurv.
Survival to Deterministic Regression B
PipeOpLearnerCV cross-validates and makes predictions from
a linear LearnerSurv with lp
predict type on the original TaskSurv.
PipeOpTaskSurvRegr transforms the lp
predictions into the target of a
TaskRegr with the same features as the original TaskSurv.
A LearnerRegr is fit and predicted on the new TaskRegr
.
PipeOpPredRegrSurv transforms the resulting PredictionRegr to PredictionSurv.
Optionally: PipeOpDistrCompositor is used to compose a distr
predict_type from the
predicted lp
predict_type.
Interpretation:
Once a dataset has censoring removed (by a given method) then a regression
learner can predict the survival time as the response
.
This is a very similar reduction to the first method with the main difference being the distribution composition. In the first case this is composed in a survival framework by assuming a linear model form and baseline hazard estimator, in the second case the composition is in a regression framework. The latter case could result in problematic negative predictions and should therefore be interpreted with caution, however a wider choice of distributions makes it a more flexible composition.
This is a rarer use-case that bypasses censoring not be removing it but instead by first predicting the linear predictor from a survival model and fitting a regression model on these predictions. The resulting regression predictions can then be viewed as the linear predictors of the new data, which can ultimately be composed to a distribution.
## Not run: library(mlr3) library(mlr3pipelines) task = tsk("rats") # method 1 with censoring deletion, compose to distribution pipe = ppl( "survtoregr", method = 1, regr_learner = lrn("regr.featureless"), survregr_params = list(method = "delete") ) pipe$train(task) pipe$predict(task) # method 2 with censoring imputation (mrl), one regr learner pipe = ppl( "survtoregr", method = 2, regr_learner = lrn("regr.featureless", predict_type = "se"), survregr_params = list(method = "mrl") ) pipe$train(task) pipe$predict(task) # method 3 with censoring omission and no composition, insample resampling pipe = ppl( "survtoregr", method = 3, regr_learner = lrn("regr.featureless"), distrcompose = FALSE, surv_learner = lrn("surv.coxph"), survregr_params = list(method = "omission") ) pipe$train(task) pipe$predict(task) ## End(Not run)
## Not run: library(mlr3) library(mlr3pipelines) task = tsk("rats") # method 1 with censoring deletion, compose to distribution pipe = ppl( "survtoregr", method = 1, regr_learner = lrn("regr.featureless"), survregr_params = list(method = "delete") ) pipe$train(task) pipe$predict(task) # method 2 with censoring imputation (mrl), one regr learner pipe = ppl( "survtoregr", method = 2, regr_learner = lrn("regr.featureless", predict_type = "se"), survregr_params = list(method = "mrl") ) pipe$train(task) pipe$predict(task) # method 3 with censoring omission and no composition, insample resampling pipe = ppl( "survtoregr", method = 3, regr_learner = lrn("regr.featureless"), distrcompose = FALSE, surv_learner = lrn("surv.coxph"), survregr_params = list(method = "omission") ) pipe$train(task) pipe$predict(task) ## End(Not run)
Calls graphics::hist()
and the result is coerced to a distr6::Distribution.
This Learner can be instantiated via the dictionary mlr_learners or with the associated sugar function lrn():
LearnerDensHistogram$new() mlr_learners$get("dens.hist") lrn("dens.hist")
Type: "dens"
Predict Types: pdf, cdf, distr
Feature Types: integer, numeric
Properties: -
mlr3::Learner
-> mlr3proba::LearnerDens
-> LearnerDensHistogram
new()
Creates a new instance of this R6 class.
LearnerDensHistogram$new()
clone()
The objects of this class are cloneable with this method.
LearnerDensHistogram$clone(deep = FALSE)
deep
Whether to make a deep clone.
Other density estimators:
mlr_learners_dens.kde
Calls kernels implemented in distr6 and the result is coerced to a distr6::Distribution.
The default bandwidth uses Silverman's rule-of-thumb for Gaussian kernels, however for non-Gaussian kernels it is recommended to use mlr3tuning to tune the bandwidth with cross-validation. Other density learners can be used for automated bandwidth selection. The default kernel is Epanechnikov (chosen to reduce dependencies).
This Learner can be instantiated via the dictionary mlr_learners or with the associated sugar function lrn():
LearnerDensKDE$new() mlr_learners$get("dens.kde") lrn("dens.kde")
Type: "dens"
Predict Types: pdf, distr
Feature Types: integer, numeric
Properties: missings
mlr3::Learner
-> mlr3proba::LearnerDens
-> LearnerDensKDE
new()
Creates a new instance of this R6 class.
LearnerDensKDE$new()
clone()
The objects of this class are cloneable with this method.
LearnerDensKDE$clone(deep = FALSE)
deep
Whether to make a deep clone.
Silverman, W. B (1986). Density Estimation for Statistics and Data Analysis. Chapman & Hall, London.
Other density estimators:
mlr_learners_dens.hist
Calls survival::coxph()
.
lp is predicted by survival::predict.coxph()
distr is predicted by survival::survfit.coxph()
crank
is identical to lp
This Learner can be instantiated via the dictionary mlr_learners or with the associated sugar function lrn():
LearnerSurvCoxPH$new() mlr_learners$get("surv.coxph") lrn("surv.coxph")
Task type: “surv”
Predict Types: “crank”, “distr”, “lp”
Feature Types: “logical”, “integer”, “numeric”, “factor”
Id | Type | Default | Levels | Range |
ties | character | efron | efron, breslow, exact | - |
singular.ok | logical | TRUE | TRUE, FALSE | - |
type | character | efron | efron, aalen, kalbfleisch-prentice | - |
stype | integer | 2 | |
|
mlr3::Learner
-> mlr3proba::LearnerSurv
-> LearnerSurvCoxPH
new()
Creates a new instance of this R6 class.
LearnerSurvCoxPH$new()
clone()
The objects of this class are cloneable with this method.
LearnerSurvCoxPH$clone(deep = FALSE)
deep
Whether to make a deep clone.
Cox DR (1972). “Regression Models and Life-Tables.” Journal of the Royal Statistical Society: Series B (Methodological), 34(2), 187–202. doi:10.1111/j.2517-6161.1972.tb00899.x.
Other survival learners:
mlr_learners_surv.kaplan
,
mlr_learners_surv.rpart
Calls survival::survfit()
.
distr is predicted by estimating the survival function with survival::survfit()
crank
is predicted as the sum of the cumulative
hazard function (expected mortality) derived from the survival distribution,
distr
This Learner can be instantiated via the dictionary mlr_learners or with the associated sugar function lrn():
LearnerSurvKaplan$new() mlr_learners$get("surv.kaplan") lrn("surv.kaplan")
Task type: “surv”
Predict Types: “crank”, “distr”
Feature Types: “logical”, “integer”, “numeric”, “character”, “factor”, “ordered”
Empty ParamSet
mlr3::Learner
-> mlr3proba::LearnerSurv
-> LearnerSurvKaplan
new()
Creates a new instance of this R6 class.
LearnerSurvKaplan$new()
clone()
The objects of this class are cloneable with this method.
LearnerSurvKaplan$clone(deep = FALSE)
deep
Whether to make a deep clone.
Kaplan EL, Meier P (1958). “Nonparametric Estimation from Incomplete Observations.” Journal of the American Statistical Association, 53(282), 457–481. doi:10.1080/01621459.1958.10501452.
Other survival learners:
mlr_learners_surv.coxph
,
mlr_learners_surv.rpart
Calls rpart::rpart()
.
crank is predicted using rpart::predict.rpart()
This Learner can be instantiated via the dictionary mlr_learners or with the associated sugar function lrn():
LearnerSurvRpart$new() mlr_learners$get("surv.rpart") lrn("surv.rpart")
Task type: “surv”
Predict Types: “crank”
Feature Types: “logical”, “integer”, “numeric”, “character”, “factor”, “ordered”
Id | Type | Default | Levels | Range |
parms | numeric | 1 | |
|
minbucket | integer | - | |
|
minsplit | integer | 20 | |
|
cp | numeric | 0.01 | |
|
maxcompete | integer | 4 | |
|
maxsurrogate | integer | 5 | |
|
maxdepth | integer | 30 | |
|
usesurrogate | integer | 2 | |
|
surrogatestyle | integer | 0 | |
|
xval | integer | 10 | |
|
cost | untyped | - | - | |
keep_model | logical | FALSE | TRUE, FALSE | - |
xval
is set to 0 in order to save some computation time.
model
has been renamed to keep_model
.
mlr3::Learner
-> mlr3proba::LearnerSurv
-> LearnerSurvRpart
new()
Creates a new instance of this R6 class.
LearnerSurvRpart$new()
importance()
The importance scores are extracted from the model slot variable.importance
.
LearnerSurvRpart$importance()
Named numeric()
.
selected_features()
Selected features are extracted from the model slot frame$var
.
LearnerSurvRpart$selected_features()
character()
.
clone()
The objects of this class are cloneable with this method.
LearnerSurvRpart$clone(deep = FALSE)
deep
Whether to make a deep clone.
Breiman L, Friedman JH, Olshen RA, Stone CJ (1984). Classification And Regression Trees. Routledge. doi:10.1201/9781315139470.
Other survival learners:
mlr_learners_surv.coxph
,
mlr_learners_surv.kaplan
Calculates the cross-entropy, or logarithmic (log), loss.
The Log Loss, in the context of probabilistic predictions, is defined as the negative log
probability density function, , evaluated at the observed value,
,
This Measure can be instantiated via the dictionary mlr_measures or with the associated sugar function msr():
MeasureDensLogloss$new() mlr_measures$get("dens.logloss") msr("dens.logloss")
Id | Type | Default | Range |
eps | numeric | 1e-15 | |
Type: "density"
Range:
Minimize: TRUE
Required prediction: pdf
eps
(numeric(1)
)
Very small number to substitute zero values in order to prevent errors
in e.g. log(0) and/or division-by-zero calculations.
Default value is 1e-15.
mlr3::Measure
-> mlr3proba::MeasureDens
-> MeasureDensLogloss
new()
Creates a new instance of this R6 class.
MeasureDensLogloss$new()
clone()
The objects of this class are cloneable with this method.
MeasureDensLogloss$clone(deep = FALSE)
deep
Whether to make a deep clone.
Calculates the cross-entropy, or logarithmic (log), loss.
The Log Loss, in the context of probabilistic predictions, is defined as the negative log
probability density function, , evaluated at the observed value,
,
Id | Type | Default | Range |
eps | numeric | 1e-15 | |
Type: "regr"
Range:
Minimize: TRUE
Required prediction: distr
eps
(numeric(1)
)
Very small number to substitute zero values in order to prevent errors
in e.g. log(0) and/or division-by-zero calculations.
Default value is 1e-15.
mlr3::Measure
-> mlr3::MeasureRegr
-> MeasureRegrLogloss
new()
Creates a new instance of this R6 class.
MeasureRegrLogloss$new()
clone()
The objects of this class are cloneable with this method.
MeasureRegrLogloss$clone(deep = FALSE)
deep
Whether to make a deep clone.
This calibration method is defined by estimating
where is the observed censoring indicator from the test data,
is the predicted cumulative hazard, and
is the observed
survival time (event or censoring).
The standard error is given by
The model is well calibrated if the estimated coefficient
(returned score) is equal to 1.
This Measure can be instantiated via the dictionary mlr_measures or with the associated sugar function msr():
MeasureSurvCalibrationAlpha$new() mlr_measures$get("surv.calib_alpha") msr("surv.calib_alpha")
Id | Type | Default | Levels | Range |
eps | numeric | 0.001 | |
|
se | logical | FALSE | TRUE, FALSE | - |
method | character | ratio | ratio, diff | - |
truncate | numeric | Inf | |
|
Type: "surv"
Range:
Minimize: FALSE
Required prediction: distr
eps
(numeric(1)
)
Very small number to substitute zero values in order to prevent errors
in e.g. log(0) and/or division-by-zero calculations.
Default value is 0.001.
se
(logical(1)
)
If TRUE
then return standard error of the measure, otherwise the score
itself (default).
method
(character(1)
)
Returns if equal to
ratio
(default) and
if equal to
diff
.
With diff
, the output score can be minimized and for example be used for
tuning purposes. This parameter takes effect only if se
is FALSE
.
truncate
(double(1)
)
This parameter controls the upper bound of the output score.
We use truncate = Inf
by default (so no truncation) and it's up to the user
to set this up reasonably given the chosen method
.
Note that truncation may severely limit automated tuning with this measure
using method = diff
.
mlr3::Measure
-> mlr3proba::MeasureSurv
-> MeasureSurvCalibrationAlpha
new()
Creates a new instance of this R6 class.
MeasureSurvCalibrationAlpha$new(method = "ratio")
method
defines which output score to return, see "Parameter details" section.
clone()
The objects of this class are cloneable with this method.
MeasureSurvCalibrationAlpha$clone(deep = FALSE)
deep
Whether to make a deep clone.
Van Houwelingen, C. H (2000). “Validation, calibration, revision and combination of prognostic survival models.” Statistics in Medicine, 19(24), 3401–3415. doi:10.1002/1097-0258(20001230)19:24<3401::AID-SIM554>3.0.CO;2-2.
Other survival measures:
mlr_measures_surv.calib_beta
,
mlr_measures_surv.chambless_auc
,
mlr_measures_surv.cindex
,
mlr_measures_surv.dcalib
,
mlr_measures_surv.graf
,
mlr_measures_surv.hung_auc
,
mlr_measures_surv.intlogloss
,
mlr_measures_surv.logloss
,
mlr_measures_surv.mae
,
mlr_measures_surv.mse
,
mlr_measures_surv.nagelk_r2
,
mlr_measures_surv.oquigley_r2
,
mlr_measures_surv.rcll
,
mlr_measures_surv.rmse
,
mlr_measures_surv.schmid
,
mlr_measures_surv.song_auc
,
mlr_measures_surv.song_tnr
,
mlr_measures_surv.song_tpr
,
mlr_measures_surv.uno_auc
,
mlr_measures_surv.uno_tnr
,
mlr_measures_surv.uno_tpr
,
mlr_measures_surv.xu_r2
Other calibration survival measures:
mlr_measures_surv.calib_beta
,
mlr_measures_surv.dcalib
Other distr survival measures:
mlr_measures_surv.dcalib
,
mlr_measures_surv.graf
,
mlr_measures_surv.intlogloss
,
mlr_measures_surv.logloss
,
mlr_measures_surv.rcll
,
mlr_measures_surv.schmid
This calibration method fits the predicted linear predictor from a Cox PH model as the only predictor in a new Cox PH model with the test data as the response.
where is the predicted linear predictor on the test data.
The model is well calibrated if the estimated coefficient
(returned score) is equal to 1.
Note: Assumes fitted model is Cox PH (i.e. has an lp
prediction type).
This Measure can be instantiated via the dictionary mlr_measures or with the associated sugar function msr():
MeasureSurvCalibrationBeta$new() mlr_measures$get("surv.calib_beta") msr("surv.calib_beta")
Id | Type | Default | Levels |
se | logical | FALSE | TRUE, FALSE |
method | character | ratio | ratio, diff |
Type: "surv"
Range:
Minimize: FALSE
Required prediction: lp
se
(logical(1)
)
If TRUE
then return standard error of the measure which is the standard
error of the estimated coefficient from the Cox PH model.
If
FALSE
(default) then returns the estimated coefficient .
method
(character(1)
)
Returns if equal to
ratio
(default) and
if
diff
.
With diff
, the output score can be minimized and for example be used for
tuning purposes.
This parameter takes effect only if se
is FALSE
.
mlr3::Measure
-> mlr3proba::MeasureSurv
-> MeasureSurvCalibrationBeta
new()
Creates a new instance of this R6 class.
MeasureSurvCalibrationBeta$new(method = "ratio")
method
defines which output score to return, see "Parameter details" section.
clone()
The objects of this class are cloneable with this method.
MeasureSurvCalibrationBeta$clone(deep = FALSE)
deep
Whether to make a deep clone.
Van Houwelingen, C. H (2000). “Validation, calibration, revision and combination of prognostic survival models.” Statistics in Medicine, 19(24), 3401–3415. doi:10.1002/1097-0258(20001230)19:24<3401::AID-SIM554>3.0.CO;2-2.
Other survival measures:
mlr_measures_surv.calib_alpha
,
mlr_measures_surv.chambless_auc
,
mlr_measures_surv.cindex
,
mlr_measures_surv.dcalib
,
mlr_measures_surv.graf
,
mlr_measures_surv.hung_auc
,
mlr_measures_surv.intlogloss
,
mlr_measures_surv.logloss
,
mlr_measures_surv.mae
,
mlr_measures_surv.mse
,
mlr_measures_surv.nagelk_r2
,
mlr_measures_surv.oquigley_r2
,
mlr_measures_surv.rcll
,
mlr_measures_surv.rmse
,
mlr_measures_surv.schmid
,
mlr_measures_surv.song_auc
,
mlr_measures_surv.song_tnr
,
mlr_measures_surv.song_tpr
,
mlr_measures_surv.uno_auc
,
mlr_measures_surv.uno_tnr
,
mlr_measures_surv.uno_tpr
,
mlr_measures_surv.xu_r2
Other calibration survival measures:
mlr_measures_surv.calib_alpha
,
mlr_measures_surv.dcalib
Other lp survival measures:
mlr_measures_surv.chambless_auc
,
mlr_measures_surv.hung_auc
,
mlr_measures_surv.nagelk_r2
,
mlr_measures_surv.oquigley_r2
,
mlr_measures_surv.song_auc
,
mlr_measures_surv.song_tnr
,
mlr_measures_surv.song_tpr
,
mlr_measures_surv.uno_auc
,
mlr_measures_surv.uno_tnr
,
mlr_measures_surv.uno_tpr
,
mlr_measures_surv.xu_r2
Calls survAUC::AUC.cd()
.
Assumes Cox PH model specification.
All measures implemented from survAUC should be used with
care, we are aware of problems in implementation that sometimes cause fatal
errors in R.
In future updates some of these measures may be re-written and implemented
directly in mlr3proba
.
This Measure can be instantiated via the dictionary mlr_measures or with the associated sugar function msr():
MeasureSurvChamblessAUC$new() mlr_measures$get("surv.chambless_auc") msr("surv.chambless_auc")
Id | Type | Default | Levels |
integrated | logical | TRUE | TRUE, FALSE |
times | untyped | - | |
Type: "surv"
Range:
Minimize: FALSE
Required prediction: lp
integrated
(logical(1)
)
If TRUE
(default), returns the integrated score (eg across
time points); otherwise, not integrated (eg at a single time point).
times
(numeric()
)
If integrated == TRUE
then a vector of time-points over which to integrate the score.
If integrated == FALSE
then a single time point at which to return the score.
mlr3::Measure
-> mlr3proba::MeasureSurv
-> mlr3proba::MeasureSurvAUC
-> MeasureSurvChamblessAUC
new()
Creates a new instance of this R6 class.
MeasureSurvChamblessAUC$new()
clone()
The objects of this class are cloneable with this method.
MeasureSurvChamblessAUC$clone(deep = FALSE)
deep
Whether to make a deep clone.
Chambless LE, Diao G (2006). “Estimation of time-dependent area under the ROC curve for long-term risk prediction.” Statistics in Medicine, 25(20), 3474–3486. doi:10.1002/sim.2299.
Other survival measures:
mlr_measures_surv.calib_alpha
,
mlr_measures_surv.calib_beta
,
mlr_measures_surv.cindex
,
mlr_measures_surv.dcalib
,
mlr_measures_surv.graf
,
mlr_measures_surv.hung_auc
,
mlr_measures_surv.intlogloss
,
mlr_measures_surv.logloss
,
mlr_measures_surv.mae
,
mlr_measures_surv.mse
,
mlr_measures_surv.nagelk_r2
,
mlr_measures_surv.oquigley_r2
,
mlr_measures_surv.rcll
,
mlr_measures_surv.rmse
,
mlr_measures_surv.schmid
,
mlr_measures_surv.song_auc
,
mlr_measures_surv.song_tnr
,
mlr_measures_surv.song_tpr
,
mlr_measures_surv.uno_auc
,
mlr_measures_surv.uno_tnr
,
mlr_measures_surv.uno_tpr
,
mlr_measures_surv.xu_r2
Other AUC survival measures:
mlr_measures_surv.hung_auc
,
mlr_measures_surv.song_auc
,
mlr_measures_surv.song_tnr
,
mlr_measures_surv.song_tpr
,
mlr_measures_surv.uno_auc
,
mlr_measures_surv.uno_tnr
,
mlr_measures_surv.uno_tpr
Other lp survival measures:
mlr_measures_surv.calib_beta
,
mlr_measures_surv.hung_auc
,
mlr_measures_surv.nagelk_r2
,
mlr_measures_surv.oquigley_r2
,
mlr_measures_surv.song_auc
,
mlr_measures_surv.song_tnr
,
mlr_measures_surv.song_tpr
,
mlr_measures_surv.uno_auc
,
mlr_measures_surv.uno_tnr
,
mlr_measures_surv.uno_tpr
,
mlr_measures_surv.xu_r2
Calculates weighted concordance statistics, which, depending on the chosen
weighting method (weight_meth
) and tied times parameter (tiex
), are
equivalent to several proposed methods.
By default, no weighting is applied and this is equivalent to Harrell's C-index.
For the Kaplan-Meier estimate of the training survival distribution (),
and the Kaplan-Meier estimate of the training censoring distribution (
),
we have the following options for time-independent concordance statistics
(C-indexes) given the weighted method:
weight_meth
:
"I"
= No weighting. (Harrell)
"GH"
= Gonen and Heller's Concordance Index
"G"
= Weights concordance by .
"G2"
= Weights concordance by . (Uno et al.)
"SG"
= Weights concordance by (Shemper et al.)
"S"
= Weights concordance by (Peto and Peto)
The last three require training data. "GH"
is only applicable to LearnerSurvCoxPH.
The implementation is slightly different from survival::concordance. Firstly this implementation is faster, and secondly the weights are computed on the training dataset whereas in survival::concordance the weights are computed on the same testing data.
This Measure can be instantiated via the dictionary mlr_measures or with the associated sugar function msr():
MeasureSurvCindex$new() mlr_measures$get("surv.cindex") msr("surv.cindex")
Id | Type | Default | Levels | Range |
t_max | numeric | - | |
|
p_max | numeric | - | |
|
weight_meth | character | I | I, G, G2, SG, S, GH | - |
tiex | numeric | 0.5 | |
|
eps | numeric | 0.001 | |
|
Type: "surv"
Range:
Minimize: FALSE
Required prediction: crank
eps
(numeric(1)
)
Very small number to substitute zero values in order to prevent errors
in e.g. log(0) and/or division-by-zero calculations.
Default value is 0.001.
t_max
(numeric(1)
)
Cutoff time (i.e. time horizon) to evaluate concordance up to.
p_max
(numeric(1)
)
The proportion of censoring to evaluate concordance up to in the given dataset.
When t_max
is specified, this parameter is ignored.
weight_meth
(character(1)
)
Method for weighting concordance. Default "I"
is Harrell's C. See details.
tiex
(numeric(1)
)
Weighting applied to tied rankings, default is to give them half (0.5) weighting.
mlr3::Measure
-> mlr3proba::MeasureSurv
-> MeasureSurvCindex
new()
This is an abstract class that should not be constructed directly.
MeasureSurvCindex$new()
clone()
The objects of this class are cloneable with this method.
MeasureSurvCindex$clone(deep = FALSE)
deep
Whether to make a deep clone.
Peto, Richard, Peto, Julian (1972). “Asymptotically efficient rank invariant test procedures.” Journal of the Royal Statistical Society: Series A (General), 135(2), 185–198.
Harrell, E F, Califf, M R, Pryor, B D, Lee, L K, Rosati, A R (1982). “Evaluating the yield of medical tests.” Jama, 247(18), 2543–2546.
Goenen M, Heller G (2005). “Concordance probability and discriminatory power in proportional hazards regression.” Biometrika, 92(4), 965–970. doi:10.1093/biomet/92.4.965.
Schemper, Michael, Wakounig, Samo, Heinze, Georg (2009). “The estimation of average hazard ratios by weighted Cox regression.” Statistics in Medicine, 28(19), 2473–2489. doi:10.1002/sim.3623.
Uno H, Cai T, Pencina MJ, D'Agostino RB, Wei LJ (2011). “On the C-statistics for evaluating overall adequacy of risk prediction procedures with censored survival data.” Statistics in Medicine, n/a–n/a. doi:10.1002/sim.4154.
Other survival measures:
mlr_measures_surv.calib_alpha
,
mlr_measures_surv.calib_beta
,
mlr_measures_surv.chambless_auc
,
mlr_measures_surv.dcalib
,
mlr_measures_surv.graf
,
mlr_measures_surv.hung_auc
,
mlr_measures_surv.intlogloss
,
mlr_measures_surv.logloss
,
mlr_measures_surv.mae
,
mlr_measures_surv.mse
,
mlr_measures_surv.nagelk_r2
,
mlr_measures_surv.oquigley_r2
,
mlr_measures_surv.rcll
,
mlr_measures_surv.rmse
,
mlr_measures_surv.schmid
,
mlr_measures_surv.song_auc
,
mlr_measures_surv.song_tnr
,
mlr_measures_surv.song_tpr
,
mlr_measures_surv.uno_auc
,
mlr_measures_surv.uno_tnr
,
mlr_measures_surv.uno_tpr
,
mlr_measures_surv.xu_r2
library(mlr3) task = tsk("rats") learner = lrn("surv.coxph") part = partition(task) # train/test split learner$train(task, part$train) p = learner$predict(task, part$test) # Harrell's C-index p$score(msr("surv.cindex")) # same as `p$score()` # Uno's C-index p$score(msr("surv.cindex", weight_meth = "G2"), task = task, train_set = part$train) # Harrell's C-index evaluated up to a specific time horizon p$score(msr("surv.cindex", t_max = 97)) # Harrell's C-index evaluated up to the time corresponding to 30% of censoring p$score(msr("surv.cindex", p_max = 0.3))
library(mlr3) task = tsk("rats") learner = lrn("surv.coxph") part = partition(task) # train/test split learner$train(task, part$train) p = learner$predict(task, part$test) # Harrell's C-index p$score(msr("surv.cindex")) # same as `p$score()` # Uno's C-index p$score(msr("surv.cindex", weight_meth = "G2"), task = task, train_set = part$train) # Harrell's C-index evaluated up to a specific time horizon p$score(msr("surv.cindex", t_max = 97)) # Harrell's C-index evaluated up to the time corresponding to 30% of censoring p$score(msr("surv.cindex", p_max = 0.3))
This calibration method is defined by calculating the following statistic:
where is number of 'buckets' (that equally divide
into intervals),
is the number of predictions, and
is the observed proportion
of observations in the
th interval. An observation is assigned to the
th bucket, if its predicted survival probability at the time of event
falls within the corresponding interval.
This statistic assumes that censoring time is independent of death time.
A model is well-calibrated if , tested with
chisq.test
( if well-calibrated).
Model
is better calibrated than model
if
,
meaning that lower values of this measure are preferred.
This measure can either return the test statistic or the p-value from the chisq.test
.
The former is useful for model comparison whereas the latter is useful for determining if a model
is well-calibrated. If chisq = FALSE
and s
is the predicted value then you can manually
compute the p.value with pchisq(s, B - 1, lower.tail = FALSE)
.
NOTE: This measure is still experimental both theoretically and in implementation. Results should therefore only be taken as an indicator of performance and not for conclusive judgements about model calibration.
This Measure can be instantiated via the dictionary mlr_measures or with the associated sugar function msr():
MeasureSurvDCalibration$new() mlr_measures$get("surv.dcalib") msr("surv.dcalib")
Id | Type | Default | Levels | Range |
B | integer | 10 | |
|
chisq | logical | FALSE | TRUE, FALSE | - |
truncate | numeric | Inf | |
|
Type: "surv"
Range:
Minimize: TRUE
Required prediction: distr
B
(integer(1)
)
Number of buckets to test for uniform predictions over.
Default of 10
is recommended by Haider et al. (2020).
Changing this parameter affects truncate
.
chisq
(logical(1)
)
If TRUE
returns the p-value of the corresponding chisq.test instead of the measure.
Default is FALSE
and returns the statistic s
.
You can manually get the p-value by executing pchisq(s, B - 1, lower.tail = FALSE)
.
The null hypothesis is that the model is D-calibrated.
truncate
(double(1)
)
This parameter controls the upper bound of the output statistic,
when chisq
is FALSE
. We use truncate = Inf
by default but may be sufficient
for most purposes, which corresponds to a p-value of 0.35 for the chisq.test using
buckets. Values
translate to even lower p-values and thus
less calibrated models. If the number of buckets
changes, you probably will want to
change the
truncate
value as well to correspond to the same p-value significance.
Note that truncation may severely limit automated tuning with this measure.
mlr3::Measure
-> mlr3proba::MeasureSurv
-> MeasureSurvDCalibration
new()
Creates a new instance of this R6 class.
MeasureSurvDCalibration$new()
clone()
The objects of this class are cloneable with this method.
MeasureSurvDCalibration$clone(deep = FALSE)
deep
Whether to make a deep clone.
Haider, Humza, Hoehn, Bret, Davis, Sarah, Greiner, Russell (2020). “Effective Ways to Build and Evaluate Individual Survival Distributions.” Journal of Machine Learning Research, 21(85), 1–63. https://jmlr.org/papers/v21/18-772.html.
Other survival measures:
mlr_measures_surv.calib_alpha
,
mlr_measures_surv.calib_beta
,
mlr_measures_surv.chambless_auc
,
mlr_measures_surv.cindex
,
mlr_measures_surv.graf
,
mlr_measures_surv.hung_auc
,
mlr_measures_surv.intlogloss
,
mlr_measures_surv.logloss
,
mlr_measures_surv.mae
,
mlr_measures_surv.mse
,
mlr_measures_surv.nagelk_r2
,
mlr_measures_surv.oquigley_r2
,
mlr_measures_surv.rcll
,
mlr_measures_surv.rmse
,
mlr_measures_surv.schmid
,
mlr_measures_surv.song_auc
,
mlr_measures_surv.song_tnr
,
mlr_measures_surv.song_tpr
,
mlr_measures_surv.uno_auc
,
mlr_measures_surv.uno_tnr
,
mlr_measures_surv.uno_tpr
,
mlr_measures_surv.xu_r2
Other calibration survival measures:
mlr_measures_surv.calib_alpha
,
mlr_measures_surv.calib_beta
Other distr survival measures:
mlr_measures_surv.calib_alpha
,
mlr_measures_surv.graf
,
mlr_measures_surv.intlogloss
,
mlr_measures_surv.logloss
,
mlr_measures_surv.rcll
,
mlr_measures_surv.schmid
Calculates the Integrated Survival Brier Score (ISBS), Integrated Graf Score or squared survival loss.
This measure has two dimensions: (test set) observations and time points.
For a specific individual from the test set, with observed survival
outcome
(time and censoring indicator) and predicted
survival function
, the observation-wise loss integrated across
the time dimension up to the time cutoff
, is:
where is the Kaplan-Meier estimate of the censoring distribution.
The re-weighted ISBS (RISBS) is:
which is always weighted by and is equal to zero for a censored subject.
To get a single score across all observations of the test set, we
return the average of the time-integrated observation-wise scores:
This Measure can be instantiated via the dictionary mlr_measures or with the associated sugar function msr():
MeasureSurvGraf$new() mlr_measures$get("surv.graf") msr("surv.graf")
Id | Type | Default | Levels | Range |
integrated | logical | TRUE | TRUE, FALSE | - |
times | untyped | - | - | |
t_max | numeric | - | |
|
p_max | numeric | - | |
|
method | integer | 2 | |
|
se | logical | FALSE | TRUE, FALSE | - |
proper | logical | FALSE | TRUE, FALSE | - |
eps | numeric | 0.001 | |
|
ERV | logical | FALSE | TRUE, FALSE | - |
Type: "surv"
Range:
Minimize: TRUE
Required prediction: distr
integrated
(logical(1)
)
If TRUE
(default), returns the integrated score (eg across
time points); otherwise, not integrated (eg at a single time point).
times
(numeric()
)
If integrated == TRUE
then a vector of time-points over which to integrate the score.
If integrated == FALSE
then a single time point at which to return the score.
t_max
(numeric(1)
)
Cutoff time (i.e. time horizon) to evaluate the measure up to.
Mutually exclusive with
p_max
or times
.
This will effectively remove test observations for which the observed time
(event or censoring) is strictly more than t_max
.
It's recommended to set t_max
to avoid division by eps
, see Details.
If t_max
is not specified, an Inf
time horizon is assumed.
p_max
(numeric(1)
)
The proportion of censoring to integrate up to in the given dataset.
Mutually exclusive with times
or t_max
.
method
(integer(1)
)
If integrate == TRUE
, this selects the integration weighting method.
method == 1
corresponds to weighting each time-point equally
and taking the mean score over discrete time-points.
method == 2
corresponds to calculating a mean weighted by the
difference between time-points.
method == 2
is the default value, to be in line with other packages.
se
(logical(1)
)
If TRUE
then returns standard error of the measure otherwise
returns the mean across all individual scores, e.g. the mean of
the per observation scores.
Default is FALSE
(returns the mean).
proper
(logical(1)
)
If TRUE
then weights scores by the censoring distribution at
the observed event time, which results in a strictly proper scoring
rule if censoring and survival time distributions are independent
and a sufficiently large dataset is used.
If FALSE
then weights scores by the Graf method which is the
more common usage but the loss is not proper.
eps
(numeric(1)
)
Very small number to substitute zero values in order to prevent errors
in e.g. log(0) and/or division-by-zero calculations.
Default value is 0.001.
ERV
(logical(1)
)
If TRUE
then the Explained Residual Variation method is applied, which
means the score is standardized against a Kaplan-Meier baseline.
Default is FALSE
.
RISBS is strictly proper when the censoring distribution is independent
of the survival distribution and when is fit on a sufficiently large dataset.
ISBS is never proper. Use
proper = FALSE
for ISBS and
proper = TRUE
for RISBS.
Results may be very different if many observations are censored at the last
observed time due to division by in
proper = TRUE
.
If the times
argument is not specified (NULL
), then the unique (and
sorted) time points from the test set are used for evaluation of the
time-integrated score.
This was a design decision due to the fact that different predicted survival
distributions usually have a discretized time domain which may
differ, i.e. in the case the survival predictions come from different survival
learners.
Essentially, using the same set of time points for the calculation of the score
minimizes the bias that would come from using different time points.
We note that
is by default constantly interpolated for time points that fall
outside its discretized time domain.
Naturally, if the times
argument is specified, then exactly these time
points are used for evaluation.
A warning is given to the user in case some of the specified times
fall outside
of the time point range of the test set.
The assumption here is that if the test set is large enough, it should have a
time domain/range similar to the one from the train set, and therefore time
points outside that domain might lead to interpolation or extrapolation of .
If comparing the integrated graf score to other packages, e.g.
pec, then method = 2
should be used. However the results may
still be very slightly different as this package uses survfit
to estimate
the censoring distribution, in line with the Graf 1999 paper; whereas some
other packages use prodlim
with reverse = TRUE
(meaning Kaplan-Meier is
not used).
If task
and train_set
are passed to $score
then is fit on training data,
otherwise testing data. The first is likely to reduce any bias caused by calculating
parts of the measure on the test data it is evaluating. The training data is automatically
used in scoring resamplings.
If t_max
or p_max
is given, then will be fitted using all observations from the
train set (or test set) and only then the cutoff time will be applied.
This is to ensure that more data is used for fitting the censoring distribution via the
Kaplan-Meier.
Setting the
t_max
can help alleviate inflation of the score when proper
is TRUE
,
in cases where an observation is censored at the last observed time point.
This results in and the use of
eps
instead (when t_max
is NULL
).
mlr3::Measure
-> mlr3proba::MeasureSurv
-> MeasureSurvGraf
new()
Creates a new instance of this R6 class.
MeasureSurvGraf$new(ERV = FALSE)
ERV
(logical(1)
)
Standardize measure against a Kaplan-Meier baseline
(Explained Residual Variation)
clone()
The objects of this class are cloneable with this method.
MeasureSurvGraf$clone(deep = FALSE)
deep
Whether to make a deep clone.
Graf E, Schmoor C, Sauerbrei W, Schumacher M (1999). “Assessment and comparison of prognostic classification schemes for survival data.” Statistics in Medicine, 18(17-18), 2529–2545. doi:10.1002/(sici)1097-0258(19990915/30)18:17/18<2529::aid-sim274>3.0.co;2-5.
Other survival measures:
mlr_measures_surv.calib_alpha
,
mlr_measures_surv.calib_beta
,
mlr_measures_surv.chambless_auc
,
mlr_measures_surv.cindex
,
mlr_measures_surv.dcalib
,
mlr_measures_surv.hung_auc
,
mlr_measures_surv.intlogloss
,
mlr_measures_surv.logloss
,
mlr_measures_surv.mae
,
mlr_measures_surv.mse
,
mlr_measures_surv.nagelk_r2
,
mlr_measures_surv.oquigley_r2
,
mlr_measures_surv.rcll
,
mlr_measures_surv.rmse
,
mlr_measures_surv.schmid
,
mlr_measures_surv.song_auc
,
mlr_measures_surv.song_tnr
,
mlr_measures_surv.song_tpr
,
mlr_measures_surv.uno_auc
,
mlr_measures_surv.uno_tnr
,
mlr_measures_surv.uno_tpr
,
mlr_measures_surv.xu_r2
Other Probabilistic survival measures:
mlr_measures_surv.intlogloss
,
mlr_measures_surv.logloss
,
mlr_measures_surv.rcll
,
mlr_measures_surv.schmid
Other distr survival measures:
mlr_measures_surv.calib_alpha
,
mlr_measures_surv.dcalib
,
mlr_measures_surv.intlogloss
,
mlr_measures_surv.logloss
,
mlr_measures_surv.rcll
,
mlr_measures_surv.schmid
Calls survAUC::AUC.hc()
.
Assumes random censoring.
All measures implemented from survAUC should be used with
care, we are aware of problems in implementation that sometimes cause fatal
errors in R.
In future updates some of these measures may be re-written and implemented
directly in mlr3proba
.
This Measure can be instantiated via the dictionary mlr_measures or with the associated sugar function msr():
MeasureSurvHungAUC$new() mlr_measures$get("surv.hung_auc") msr("surv.hung_auc")
Id | Type | Default | Levels |
integrated | logical | TRUE | TRUE, FALSE |
times | untyped | - | |
Type: "surv"
Range:
Minimize: FALSE
Required prediction: lp
integrated
(logical(1)
)
If TRUE
(default), returns the integrated score (eg across
time points); otherwise, not integrated (eg at a single time point).
times
(numeric()
)
If integrated == TRUE
then a vector of time-points over which to integrate the score.
If integrated == FALSE
then a single time point at which to return the score.
mlr3::Measure
-> mlr3proba::MeasureSurv
-> mlr3proba::MeasureSurvAUC
-> MeasureSurvHungAUC
new()
Creates a new instance of this R6 class.
MeasureSurvHungAUC$new()
clone()
The objects of this class are cloneable with this method.
MeasureSurvHungAUC$clone(deep = FALSE)
deep
Whether to make a deep clone.
Hung H, Chiang C (2010). “Estimation methods for time-dependent AUC models with survival data.” The Canadian Journal of Statistics / La Revue Canadienne de Statistique, 38(1), 8–26. https://www.jstor.org/stable/27805213.
Other survival measures:
mlr_measures_surv.calib_alpha
,
mlr_measures_surv.calib_beta
,
mlr_measures_surv.chambless_auc
,
mlr_measures_surv.cindex
,
mlr_measures_surv.dcalib
,
mlr_measures_surv.graf
,
mlr_measures_surv.intlogloss
,
mlr_measures_surv.logloss
,
mlr_measures_surv.mae
,
mlr_measures_surv.mse
,
mlr_measures_surv.nagelk_r2
,
mlr_measures_surv.oquigley_r2
,
mlr_measures_surv.rcll
,
mlr_measures_surv.rmse
,
mlr_measures_surv.schmid
,
mlr_measures_surv.song_auc
,
mlr_measures_surv.song_tnr
,
mlr_measures_surv.song_tpr
,
mlr_measures_surv.uno_auc
,
mlr_measures_surv.uno_tnr
,
mlr_measures_surv.uno_tpr
,
mlr_measures_surv.xu_r2
Other AUC survival measures:
mlr_measures_surv.chambless_auc
,
mlr_measures_surv.song_auc
,
mlr_measures_surv.song_tnr
,
mlr_measures_surv.song_tpr
,
mlr_measures_surv.uno_auc
,
mlr_measures_surv.uno_tnr
,
mlr_measures_surv.uno_tpr
Other lp survival measures:
mlr_measures_surv.calib_beta
,
mlr_measures_surv.chambless_auc
,
mlr_measures_surv.nagelk_r2
,
mlr_measures_surv.oquigley_r2
,
mlr_measures_surv.song_auc
,
mlr_measures_surv.song_tnr
,
mlr_measures_surv.song_tpr
,
mlr_measures_surv.uno_auc
,
mlr_measures_surv.uno_tnr
,
mlr_measures_surv.uno_tpr
,
mlr_measures_surv.xu_r2
Calculates the Integrated Survival Log-Likelihood (ISLL) or Integrated Logarithmic (log) Loss, aka integrated cross entropy.
This measure has two dimensions: (test set) observations and time points.
For a specific individual from the test set, with observed survival
outcome
(time and censoring indicator) and predicted
survival function
, the observation-wise loss integrated across
the time dimension up to the time cutoff
, is:
where is the Kaplan-Meier estimate of the censoring distribution.
The re-weighted ISLL (RISLL) is:
which is always weighted by and is equal to zero for a censored subject.
To get a single score across all observations of the test set, we
return the average of the time-integrated observation-wise scores:
This Measure can be instantiated via the dictionary mlr_measures or with the associated sugar function msr():
MeasureSurvIntLogloss$new() mlr_measures$get("surv.intlogloss") msr("surv.intlogloss")
Id | Type | Default | Levels | Range |
integrated | logical | TRUE | TRUE, FALSE | - |
times | untyped | - | - | |
t_max | numeric | - | |
|
p_max | numeric | - | |
|
method | integer | 2 | |
|
se | logical | FALSE | TRUE, FALSE | - |
proper | logical | FALSE | TRUE, FALSE | - |
eps | numeric | 0.001 | |
|
ERV | logical | FALSE | TRUE, FALSE | - |
Type: "surv"
Range:
Minimize: TRUE
Required prediction: distr
integrated
(logical(1)
)
If TRUE
(default), returns the integrated score (eg across
time points); otherwise, not integrated (eg at a single time point).
times
(numeric()
)
If integrated == TRUE
then a vector of time-points over which to integrate the score.
If integrated == FALSE
then a single time point at which to return the score.
t_max
(numeric(1)
)
Cutoff time (i.e. time horizon) to evaluate the measure up to.
Mutually exclusive with
p_max
or times
.
This will effectively remove test observations for which the observed time
(event or censoring) is strictly more than t_max
.
It's recommended to set t_max
to avoid division by eps
, see Details.
If t_max
is not specified, an Inf
time horizon is assumed.
p_max
(numeric(1)
)
The proportion of censoring to integrate up to in the given dataset.
Mutually exclusive with times
or t_max
.
method
(integer(1)
)
If integrate == TRUE
, this selects the integration weighting method.
method == 1
corresponds to weighting each time-point equally
and taking the mean score over discrete time-points.
method == 2
corresponds to calculating a mean weighted by the
difference between time-points.
method == 2
is the default value, to be in line with other packages.
se
(logical(1)
)
If TRUE
then returns standard error of the measure otherwise
returns the mean across all individual scores, e.g. the mean of
the per observation scores.
Default is FALSE
(returns the mean).
proper
(logical(1)
)
If TRUE
then weights scores by the censoring distribution at
the observed event time, which results in a strictly proper scoring
rule if censoring and survival time distributions are independent
and a sufficiently large dataset is used.
If FALSE
then weights scores by the Graf method which is the
more common usage but the loss is not proper.
eps
(numeric(1)
)
Very small number to substitute zero values in order to prevent errors
in e.g. log(0) and/or division-by-zero calculations.
Default value is 0.001.
ERV
(logical(1)
)
If TRUE
then the Explained Residual Variation method is applied, which
means the score is standardized against a Kaplan-Meier baseline.
Default is FALSE
.
RISLL is strictly proper when the censoring distribution is independent
of the survival distribution and when is fit on a sufficiently large dataset.
ISLL is never proper. Use
proper = FALSE
for ISLL and
proper = TRUE
for RISLL.
Results may be very different if many observations are censored at the last
observed time due to division by in
proper = TRUE
.
If the times
argument is not specified (NULL
), then the unique (and
sorted) time points from the test set are used for evaluation of the
time-integrated score.
This was a design decision due to the fact that different predicted survival
distributions usually have a discretized time domain which may
differ, i.e. in the case the survival predictions come from different survival
learners.
Essentially, using the same set of time points for the calculation of the score
minimizes the bias that would come from using different time points.
We note that
is by default constantly interpolated for time points that fall
outside its discretized time domain.
Naturally, if the times
argument is specified, then exactly these time
points are used for evaluation.
A warning is given to the user in case some of the specified times
fall outside
of the time point range of the test set.
The assumption here is that if the test set is large enough, it should have a
time domain/range similar to the one from the train set, and therefore time
points outside that domain might lead to interpolation or extrapolation of .
If comparing the integrated graf score to other packages, e.g.
pec, then method = 2
should be used. However the results may
still be very slightly different as this package uses survfit
to estimate
the censoring distribution, in line with the Graf 1999 paper; whereas some
other packages use prodlim
with reverse = TRUE
(meaning Kaplan-Meier is
not used).
If task
and train_set
are passed to $score
then is fit on training data,
otherwise testing data. The first is likely to reduce any bias caused by calculating
parts of the measure on the test data it is evaluating. The training data is automatically
used in scoring resamplings.
If t_max
or p_max
is given, then will be fitted using all observations from the
train set (or test set) and only then the cutoff time will be applied.
This is to ensure that more data is used for fitting the censoring distribution via the
Kaplan-Meier.
Setting the
t_max
can help alleviate inflation of the score when proper
is TRUE
,
in cases where an observation is censored at the last observed time point.
This results in and the use of
eps
instead (when t_max
is NULL
).
mlr3::Measure
-> mlr3proba::MeasureSurv
-> MeasureSurvIntLogloss
new()
Creates a new instance of this R6 class.
MeasureSurvIntLogloss$new(ERV = FALSE)
ERV
(logical(1)
)
Standardize measure against a Kaplan-Meier baseline
(Explained Residual Variation)
clone()
The objects of this class are cloneable with this method.
MeasureSurvIntLogloss$clone(deep = FALSE)
deep
Whether to make a deep clone.
Graf E, Schmoor C, Sauerbrei W, Schumacher M (1999). “Assessment and comparison of prognostic classification schemes for survival data.” Statistics in Medicine, 18(17-18), 2529–2545. doi:10.1002/(sici)1097-0258(19990915/30)18:17/18<2529::aid-sim274>3.0.co;2-5.
Other survival measures:
mlr_measures_surv.calib_alpha
,
mlr_measures_surv.calib_beta
,
mlr_measures_surv.chambless_auc
,
mlr_measures_surv.cindex
,
mlr_measures_surv.dcalib
,
mlr_measures_surv.graf
,
mlr_measures_surv.hung_auc
,
mlr_measures_surv.logloss
,
mlr_measures_surv.mae
,
mlr_measures_surv.mse
,
mlr_measures_surv.nagelk_r2
,
mlr_measures_surv.oquigley_r2
,
mlr_measures_surv.rcll
,
mlr_measures_surv.rmse
,
mlr_measures_surv.schmid
,
mlr_measures_surv.song_auc
,
mlr_measures_surv.song_tnr
,
mlr_measures_surv.song_tpr
,
mlr_measures_surv.uno_auc
,
mlr_measures_surv.uno_tnr
,
mlr_measures_surv.uno_tpr
,
mlr_measures_surv.xu_r2
Other Probabilistic survival measures:
mlr_measures_surv.graf
,
mlr_measures_surv.logloss
,
mlr_measures_surv.rcll
,
mlr_measures_surv.schmid
Other distr survival measures:
mlr_measures_surv.calib_alpha
,
mlr_measures_surv.dcalib
,
mlr_measures_surv.graf
,
mlr_measures_surv.logloss
,
mlr_measures_surv.rcll
,
mlr_measures_surv.schmid
Calculates the cross-entropy, or negative log-likelihood (NLL) or logarithmic (log), loss.
The Log Loss, in the context of probabilistic predictions, is defined as the
negative log probability density function, , evaluated at the
observation time (event or censoring),
,
The standard error of the Log Loss, L, is approximated via,
where are the number of observations in the test set, and
is the standard
deviation.
The Re-weighted Negative Log-Likelihood (RNLL) or IPCW (Inverse Probability Censoring Weighted) Log Loss is defined by
where is the censoring indicator and
is the Kaplan-Meier estimator of the
censoring distribution.
So only observations that have experienced the event are taking into account
for RNLL (i.e.
) and both
are calculated only at the event times.
If only censored observations exist in the test set,
NaN
is returned.
This Measure can be instantiated via the dictionary mlr_measures or with the associated sugar function msr():
MeasureSurvLogloss$new() mlr_measures$get("surv.logloss") msr("surv.logloss")
Id | Type | Default | Levels | Range |
eps | numeric | 1e-15 | |
|
se | logical | FALSE | TRUE, FALSE | - |
IPCW | logical | TRUE | TRUE, FALSE | - |
ERV | logical | FALSE | TRUE, FALSE | - |
Type: "surv"
Range:
Minimize: TRUE
Required prediction: distr
eps
(numeric(1)
)
Very small number to substitute zero values in order to prevent errors
in e.g. log(0) and/or division-by-zero calculations.
Default value is 1e-15.
se
(logical(1)
)
If TRUE
then returns standard error of the measure otherwise
returns the mean across all individual scores, e.g. the mean of
the per observation scores.
Default is FALSE
(returns the mean).
ERV
(logical(1)
)
If TRUE
then the Explained Residual Variation method is applied, which
means the score is standardized against a Kaplan-Meier baseline.
Default is FALSE
.
IPCW
(logical(1)
)
If TRUE
(default) then returns the score (which is proper), otherwise the
score (improper).
If task
and train_set
are passed to $score
then is fit on training data,
otherwise testing data. The first is likely to reduce any bias caused by calculating
parts of the measure on the test data it is evaluating. The training data is automatically
used in scoring resamplings.
mlr3::Measure
-> mlr3proba::MeasureSurv
-> MeasureSurvLogloss
new()
Creates a new instance of this R6 class.
MeasureSurvLogloss$new(ERV = FALSE)
ERV
(logical(1)
)
Standardize measure against a Kaplan-Meier baseline
(Explained Residual Variation)
clone()
The objects of this class are cloneable with this method.
MeasureSurvLogloss$clone(deep = FALSE)
deep
Whether to make a deep clone.
Other survival measures:
mlr_measures_surv.calib_alpha
,
mlr_measures_surv.calib_beta
,
mlr_measures_surv.chambless_auc
,
mlr_measures_surv.cindex
,
mlr_measures_surv.dcalib
,
mlr_measures_surv.graf
,
mlr_measures_surv.hung_auc
,
mlr_measures_surv.intlogloss
,
mlr_measures_surv.mae
,
mlr_measures_surv.mse
,
mlr_measures_surv.nagelk_r2
,
mlr_measures_surv.oquigley_r2
,
mlr_measures_surv.rcll
,
mlr_measures_surv.rmse
,
mlr_measures_surv.schmid
,
mlr_measures_surv.song_auc
,
mlr_measures_surv.song_tnr
,
mlr_measures_surv.song_tpr
,
mlr_measures_surv.uno_auc
,
mlr_measures_surv.uno_tnr
,
mlr_measures_surv.uno_tpr
,
mlr_measures_surv.xu_r2
Other Probabilistic survival measures:
mlr_measures_surv.graf
,
mlr_measures_surv.intlogloss
,
mlr_measures_surv.rcll
,
mlr_measures_surv.schmid
Other distr survival measures:
mlr_measures_surv.calib_alpha
,
mlr_measures_surv.dcalib
,
mlr_measures_surv.graf
,
mlr_measures_surv.intlogloss
,
mlr_measures_surv.rcll
,
mlr_measures_surv.schmid
Calculates the mean absolute error (MAE).
The MAE is defined by
where is the true value and
is the prediction.
Censored observations in the test set are ignored.
This Measure can be instantiated via the dictionary mlr_measures or with the associated sugar function msr():
MeasureSurvMAE$new() mlr_measures$get("surv.mae") msr("surv.mae")
Id | Type | Default | Levels |
se | logical | FALSE | TRUE, FALSE |
Type: "surv"
Range:
Minimize: TRUE
Required prediction: response
se
(logical(1)
)
If TRUE
then returns standard error of the measure otherwise
returns the mean across all individual scores, e.g. the mean of
the per observation scores.
Default is FALSE
(returns the mean).
mlr3::Measure
-> mlr3proba::MeasureSurv
-> MeasureSurvMAE
new()
Creates a new instance of this R6 class.
MeasureSurvMAE$new()
clone()
The objects of this class are cloneable with this method.
MeasureSurvMAE$clone(deep = FALSE)
deep
Whether to make a deep clone.
Other survival measures:
mlr_measures_surv.calib_alpha
,
mlr_measures_surv.calib_beta
,
mlr_measures_surv.chambless_auc
,
mlr_measures_surv.cindex
,
mlr_measures_surv.dcalib
,
mlr_measures_surv.graf
,
mlr_measures_surv.hung_auc
,
mlr_measures_surv.intlogloss
,
mlr_measures_surv.logloss
,
mlr_measures_surv.mse
,
mlr_measures_surv.nagelk_r2
,
mlr_measures_surv.oquigley_r2
,
mlr_measures_surv.rcll
,
mlr_measures_surv.rmse
,
mlr_measures_surv.schmid
,
mlr_measures_surv.song_auc
,
mlr_measures_surv.song_tnr
,
mlr_measures_surv.song_tpr
,
mlr_measures_surv.uno_auc
,
mlr_measures_surv.uno_tnr
,
mlr_measures_surv.uno_tpr
,
mlr_measures_surv.xu_r2
Other response survival measures:
mlr_measures_surv.mse
,
mlr_measures_surv.rmse
Calculates the mean squared error (MSE).
The MSE is defined by
where is the true value and
is the prediction.
Censored observations in the test set are ignored.
This Measure can be instantiated via the dictionary mlr_measures or with the associated sugar function msr():
MeasureSurvMSE$new() mlr_measures$get("surv.mse") msr("surv.mse")
Id | Type | Default | Levels |
se | logical | FALSE | TRUE, FALSE |
Type: "surv"
Range:
Minimize: TRUE
Required prediction: response
se
(logical(1)
)
If TRUE
then returns standard error of the measure otherwise
returns the mean across all individual scores, e.g. the mean of
the per observation scores.
Default is FALSE
(returns the mean).
mlr3::Measure
-> mlr3proba::MeasureSurv
-> MeasureSurvMSE
new()
Creates a new instance of this R6 class.
MeasureSurvMSE$new()
clone()
The objects of this class are cloneable with this method.
MeasureSurvMSE$clone(deep = FALSE)
deep
Whether to make a deep clone.
Other survival measures:
mlr_measures_surv.calib_alpha
,
mlr_measures_surv.calib_beta
,
mlr_measures_surv.chambless_auc
,
mlr_measures_surv.cindex
,
mlr_measures_surv.dcalib
,
mlr_measures_surv.graf
,
mlr_measures_surv.hung_auc
,
mlr_measures_surv.intlogloss
,
mlr_measures_surv.logloss
,
mlr_measures_surv.mae
,
mlr_measures_surv.nagelk_r2
,
mlr_measures_surv.oquigley_r2
,
mlr_measures_surv.rcll
,
mlr_measures_surv.rmse
,
mlr_measures_surv.schmid
,
mlr_measures_surv.song_auc
,
mlr_measures_surv.song_tnr
,
mlr_measures_surv.song_tpr
,
mlr_measures_surv.uno_auc
,
mlr_measures_surv.uno_tnr
,
mlr_measures_surv.uno_tpr
,
mlr_measures_surv.xu_r2
Other response survival measures:
mlr_measures_surv.mae
,
mlr_measures_surv.rmse
Calls survAUC::Nagelk()
.
Assumes Cox PH model specification.
All measures implemented from survAUC should be used with
care, we are aware of problems in implementation that sometimes cause fatal
errors in R.
In future updates some of these measures may be re-written and implemented
directly in mlr3proba
.
This Measure can be instantiated via the dictionary mlr_measures or with the associated sugar function msr():
MeasureSurvNagelkR2$new() mlr_measures$get("surv.nagelk_r2") msr("surv.nagelk_r2")
Empty ParamSet
Type: "surv"
Range:
Minimize: FALSE
Required prediction: lp
mlr3::Measure
-> mlr3proba::MeasureSurv
-> MeasureSurvNagelkR2
new()
Creates a new instance of this R6 class.
MeasureSurvNagelkR2$new()
clone()
The objects of this class are cloneable with this method.
MeasureSurvNagelkR2$clone(deep = FALSE)
deep
Whether to make a deep clone.
Nagelkerke, JD N, others (1991). “A note on a general definition of the coefficient of determination.” Biometrika, 78(3), 691–692.
Other survival measures:
mlr_measures_surv.calib_alpha
,
mlr_measures_surv.calib_beta
,
mlr_measures_surv.chambless_auc
,
mlr_measures_surv.cindex
,
mlr_measures_surv.dcalib
,
mlr_measures_surv.graf
,
mlr_measures_surv.hung_auc
,
mlr_measures_surv.intlogloss
,
mlr_measures_surv.logloss
,
mlr_measures_surv.mae
,
mlr_measures_surv.mse
,
mlr_measures_surv.oquigley_r2
,
mlr_measures_surv.rcll
,
mlr_measures_surv.rmse
,
mlr_measures_surv.schmid
,
mlr_measures_surv.song_auc
,
mlr_measures_surv.song_tnr
,
mlr_measures_surv.song_tpr
,
mlr_measures_surv.uno_auc
,
mlr_measures_surv.uno_tnr
,
mlr_measures_surv.uno_tpr
,
mlr_measures_surv.xu_r2
Other R2 survival measures:
mlr_measures_surv.oquigley_r2
,
mlr_measures_surv.xu_r2
Other lp survival measures:
mlr_measures_surv.calib_beta
,
mlr_measures_surv.chambless_auc
,
mlr_measures_surv.hung_auc
,
mlr_measures_surv.oquigley_r2
,
mlr_measures_surv.song_auc
,
mlr_measures_surv.song_tnr
,
mlr_measures_surv.song_tpr
,
mlr_measures_surv.uno_auc
,
mlr_measures_surv.uno_tnr
,
mlr_measures_surv.uno_tpr
,
mlr_measures_surv.xu_r2
Calls survAUC::OXS()
.
Assumes Cox PH model specification.
All measures implemented from survAUC should be used with
care, we are aware of problems in implementation that sometimes cause fatal
errors in R.
In future updates some of these measures may be re-written and implemented
directly in mlr3proba
.
This Measure can be instantiated via the dictionary mlr_measures or with the associated sugar function msr():
MeasureSurvOQuigleyR2$new() mlr_measures$get("surv.oquigley_r2") msr("surv.oquigley_r2")
Empty ParamSet
Type: "surv"
Range:
Minimize: FALSE
Required prediction: lp
mlr3::Measure
-> mlr3proba::MeasureSurv
-> MeasureSurvOQuigleyR2
new()
Creates a new instance of this R6 class.
MeasureSurvOQuigleyR2$new()
clone()
The objects of this class are cloneable with this method.
MeasureSurvOQuigleyR2$clone(deep = FALSE)
deep
Whether to make a deep clone.
O'Quigley J, Xu R, Stare J (2005). “Explained randomness in proportional hazards models.” Statistics in Medicine, 24(3), 479–489. doi:10.1002/sim.1946.
Other survival measures:
mlr_measures_surv.calib_alpha
,
mlr_measures_surv.calib_beta
,
mlr_measures_surv.chambless_auc
,
mlr_measures_surv.cindex
,
mlr_measures_surv.dcalib
,
mlr_measures_surv.graf
,
mlr_measures_surv.hung_auc
,
mlr_measures_surv.intlogloss
,
mlr_measures_surv.logloss
,
mlr_measures_surv.mae
,
mlr_measures_surv.mse
,
mlr_measures_surv.nagelk_r2
,
mlr_measures_surv.rcll
,
mlr_measures_surv.rmse
,
mlr_measures_surv.schmid
,
mlr_measures_surv.song_auc
,
mlr_measures_surv.song_tnr
,
mlr_measures_surv.song_tpr
,
mlr_measures_surv.uno_auc
,
mlr_measures_surv.uno_tnr
,
mlr_measures_surv.uno_tpr
,
mlr_measures_surv.xu_r2
Other R2 survival measures:
mlr_measures_surv.nagelk_r2
,
mlr_measures_surv.xu_r2
Other lp survival measures:
mlr_measures_surv.calib_beta
,
mlr_measures_surv.chambless_auc
,
mlr_measures_surv.hung_auc
,
mlr_measures_surv.nagelk_r2
,
mlr_measures_surv.song_auc
,
mlr_measures_surv.song_tnr
,
mlr_measures_surv.song_tpr
,
mlr_measures_surv.uno_auc
,
mlr_measures_surv.uno_tnr
,
mlr_measures_surv.uno_tpr
,
mlr_measures_surv.xu_r2
Calculates the right-censored logarithmic (log), loss.
The RCLL, in the context of probabilistic predictions, is defined by
where is the censoring indicator,
the probability
density function and
the survival function.
RCLL is proper given that censoring and survival distribution are independent, see Rindt et al. (2022).
Note: Even though RCLL is a proper scoring rule, the calculation of (which in our case is discrete, i.e. it is a probability mass function) for time points in the test set that don't exist in the predicted survival matrix (
distr
), results in 0 values, which are substituted by "eps"
in our implementation, therefore skewing the result towards .
This problem is also discussed in Rindt et al. (2022), where the authors perform interpolation to get non-zero values for the
.
Until this is handled in
mlr3proba
some way, we advise against using this measure for model evaluation.
This Measure can be instantiated via the dictionary mlr_measures or with the associated sugar function msr():
MeasureSurvRCLL$new() mlr_measures$get("surv.rcll") msr("surv.rcll")
Id | Type | Default | Levels | Range |
eps | numeric | 1e-15 | |
|
se | logical | FALSE | TRUE, FALSE | - |
ERV | logical | FALSE | TRUE, FALSE | - |
na.rm | logical | TRUE | TRUE, FALSE | - |
Type: "surv"
Range:
Minimize: TRUE
Required prediction: distr
eps
(numeric(1)
)
Very small number to substitute zero values in order to prevent errors
in e.g. log(0) and/or division-by-zero calculations.
Default value is 1e-15.
se
(logical(1)
)
If TRUE
then returns standard error of the measure otherwise
returns the mean across all individual scores, e.g. the mean of
the per observation scores.
Default is FALSE
(returns the mean).
ERV
(logical(1)
)
If TRUE
then the Explained Residual Variation method is applied, which
means the score is standardized against a Kaplan-Meier baseline.
Default is FALSE
.
na.rm
(logical(1)
)
If TRUE
(default) then removes any NAs in individual score calculations.
mlr3::Measure
-> mlr3proba::MeasureSurv
-> MeasureSurvRCLL
new()
Creates a new instance of this R6 class.
MeasureSurvRCLL$new(ERV = FALSE)
ERV
(logical(1)
)
Standardize measure against a Kaplan-Meier baseline
(Explained Residual Variation)
clone()
The objects of this class are cloneable with this method.
MeasureSurvRCLL$clone(deep = FALSE)
deep
Whether to make a deep clone.
Avati, Anand, Duan, Tony, Zhou, Sharon, Jung, Kenneth, Shah, H N, Ng, Y A (2020). “Countdown Regression: Sharp and Calibrated Survival Predictions.” Proceedings of The 35th Uncertainty in Artificial Intelligence Conference, 115(4), 145–155. https://proceedings.mlr.press/v115/avati20a.html.
Rindt, David, Hu, Robert, Steinsaltz, David, Sejdinovic, Dino (2022). “Survival regression with proper scoring rules and monotonic neural networks.” Proceedings of The 25th International Conference on Artificial Intelligence and Statistics, 151(4), 1190–1205. https://proceedings.mlr.press/v151/rindt22a.html.
Other survival measures:
mlr_measures_surv.calib_alpha
,
mlr_measures_surv.calib_beta
,
mlr_measures_surv.chambless_auc
,
mlr_measures_surv.cindex
,
mlr_measures_surv.dcalib
,
mlr_measures_surv.graf
,
mlr_measures_surv.hung_auc
,
mlr_measures_surv.intlogloss
,
mlr_measures_surv.logloss
,
mlr_measures_surv.mae
,
mlr_measures_surv.mse
,
mlr_measures_surv.nagelk_r2
,
mlr_measures_surv.oquigley_r2
,
mlr_measures_surv.rmse
,
mlr_measures_surv.schmid
,
mlr_measures_surv.song_auc
,
mlr_measures_surv.song_tnr
,
mlr_measures_surv.song_tpr
,
mlr_measures_surv.uno_auc
,
mlr_measures_surv.uno_tnr
,
mlr_measures_surv.uno_tpr
,
mlr_measures_surv.xu_r2
Other Probabilistic survival measures:
mlr_measures_surv.graf
,
mlr_measures_surv.intlogloss
,
mlr_measures_surv.logloss
,
mlr_measures_surv.schmid
Other distr survival measures:
mlr_measures_surv.calib_alpha
,
mlr_measures_surv.dcalib
,
mlr_measures_surv.graf
,
mlr_measures_surv.intlogloss
,
mlr_measures_surv.logloss
,
mlr_measures_surv.schmid
Calculates the root mean squared error (RMSE).
The RMSE is defined by
where is the true value and
is the prediction.
Censored observations in the test set are ignored.
This Measure can be instantiated via the dictionary mlr_measures or with the associated sugar function msr():
MeasureSurvRMSE$new() mlr_measures$get("surv.rmse") msr("surv.rmse")
Id | Type | Default | Levels |
se | logical | FALSE | TRUE, FALSE |
Type: "surv"
Range:
Minimize: TRUE
Required prediction: response
se
(logical(1)
)
If TRUE
then returns standard error of the measure otherwise
returns the mean across all individual scores, e.g. the mean of
the per observation scores.
Default is FALSE
(returns the mean).
mlr3::Measure
-> mlr3proba::MeasureSurv
-> MeasureSurvRMSE
new()
Creates a new instance of this R6 class.
MeasureSurvRMSE$new()
clone()
The objects of this class are cloneable with this method.
MeasureSurvRMSE$clone(deep = FALSE)
deep
Whether to make a deep clone.
Other survival measures:
mlr_measures_surv.calib_alpha
,
mlr_measures_surv.calib_beta
,
mlr_measures_surv.chambless_auc
,
mlr_measures_surv.cindex
,
mlr_measures_surv.dcalib
,
mlr_measures_surv.graf
,
mlr_measures_surv.hung_auc
,
mlr_measures_surv.intlogloss
,
mlr_measures_surv.logloss
,
mlr_measures_surv.mae
,
mlr_measures_surv.mse
,
mlr_measures_surv.nagelk_r2
,
mlr_measures_surv.oquigley_r2
,
mlr_measures_surv.rcll
,
mlr_measures_surv.schmid
,
mlr_measures_surv.song_auc
,
mlr_measures_surv.song_tnr
,
mlr_measures_surv.song_tpr
,
mlr_measures_surv.uno_auc
,
mlr_measures_surv.uno_tnr
,
mlr_measures_surv.uno_tpr
,
mlr_measures_surv.xu_r2
Other response survival measures:
mlr_measures_surv.mae
,
mlr_measures_surv.mse
Calculates the Integrated Schmid Score (ISS), aka integrated absolute loss.
This measure has two dimensions: (test set) observations and time points.
For a specific individual from the test set, with observed survival
outcome
(time and censoring indicator) and predicted
survival function
, the observation-wise loss integrated across
the time dimension up to the time cutoff
, is:
where is the Kaplan-Meier estimate of the censoring distribution.
The re-weighted ISS (RISS) is:
which is always weighted by and is equal to zero for a censored subject.
To get a single score across all observations of the test set, we
return the average of the time-integrated observation-wise scores:
where is the Kaplan-Meier estimate of the censoring distribution.
The re-weighted ISS, RISS is given by
This Measure can be instantiated via the dictionary mlr_measures or with the associated sugar function msr():
MeasureSurvSchmid$new() mlr_measures$get("surv.schmid") msr("surv.schmid")
Id | Type | Default | Levels | Range |
integrated | logical | TRUE | TRUE, FALSE | - |
times | untyped | - | - | |
t_max | numeric | - | |
|
p_max | numeric | - | |
|
method | integer | 2 | |
|
se | logical | FALSE | TRUE, FALSE | - |
proper | logical | FALSE | TRUE, FALSE | - |
eps | numeric | 0.001 | |
|
ERV | logical | FALSE | TRUE, FALSE | - |
Type: "surv"
Range:
Minimize: TRUE
Required prediction: distr
integrated
(logical(1)
)
If TRUE
(default), returns the integrated score (eg across
time points); otherwise, not integrated (eg at a single time point).
times
(numeric()
)
If integrated == TRUE
then a vector of time-points over which to integrate the score.
If integrated == FALSE
then a single time point at which to return the score.
t_max
(numeric(1)
)
Cutoff time (i.e. time horizon) to evaluate the measure up to.
Mutually exclusive with
p_max
or times
.
This will effectively remove test observations for which the observed time
(event or censoring) is strictly more than t_max
.
It's recommended to set t_max
to avoid division by eps
, see Details.
If t_max
is not specified, an Inf
time horizon is assumed.
p_max
(numeric(1)
)
The proportion of censoring to integrate up to in the given dataset.
Mutually exclusive with times
or t_max
.
method
(integer(1)
)
If integrate == TRUE
, this selects the integration weighting method.
method == 1
corresponds to weighting each time-point equally
and taking the mean score over discrete time-points.
method == 2
corresponds to calculating a mean weighted by the
difference between time-points.
method == 2
is the default value, to be in line with other packages.
se
(logical(1)
)
If TRUE
then returns standard error of the measure otherwise
returns the mean across all individual scores, e.g. the mean of
the per observation scores.
Default is FALSE
(returns the mean).
proper
(logical(1)
)
If TRUE
then weights scores by the censoring distribution at
the observed event time, which results in a strictly proper scoring
rule if censoring and survival time distributions are independent
and a sufficiently large dataset is used.
If FALSE
then weights scores by the Graf method which is the
more common usage but the loss is not proper.
eps
(numeric(1)
)
Very small number to substitute zero values in order to prevent errors
in e.g. log(0) and/or division-by-zero calculations.
Default value is 0.001.
ERV
(logical(1)
)
If TRUE
then the Explained Residual Variation method is applied, which
means the score is standardized against a Kaplan-Meier baseline.
Default is FALSE
.
RISS is strictly proper when the censoring distribution is independent
of the survival distribution and when is fit on a sufficiently large dataset.
ISS is never proper. Use
proper = FALSE
for ISS and
proper = TRUE
for RISS.
Results may be very different if many observations are censored at the last
observed time due to division by in
proper = TRUE
.
If the times
argument is not specified (NULL
), then the unique (and
sorted) time points from the test set are used for evaluation of the
time-integrated score.
This was a design decision due to the fact that different predicted survival
distributions usually have a discretized time domain which may
differ, i.e. in the case the survival predictions come from different survival
learners.
Essentially, using the same set of time points for the calculation of the score
minimizes the bias that would come from using different time points.
We note that
is by default constantly interpolated for time points that fall
outside its discretized time domain.
Naturally, if the times
argument is specified, then exactly these time
points are used for evaluation.
A warning is given to the user in case some of the specified times
fall outside
of the time point range of the test set.
The assumption here is that if the test set is large enough, it should have a
time domain/range similar to the one from the train set, and therefore time
points outside that domain might lead to interpolation or extrapolation of .
If comparing the integrated graf score to other packages, e.g.
pec, then method = 2
should be used. However the results may
still be very slightly different as this package uses survfit
to estimate
the censoring distribution, in line with the Graf 1999 paper; whereas some
other packages use prodlim
with reverse = TRUE
(meaning Kaplan-Meier is
not used).
If task
and train_set
are passed to $score
then is fit on training data,
otherwise testing data. The first is likely to reduce any bias caused by calculating
parts of the measure on the test data it is evaluating. The training data is automatically
used in scoring resamplings.
If t_max
or p_max
is given, then will be fitted using all observations from the
train set (or test set) and only then the cutoff time will be applied.
This is to ensure that more data is used for fitting the censoring distribution via the
Kaplan-Meier.
Setting the
t_max
can help alleviate inflation of the score when proper
is TRUE
,
in cases where an observation is censored at the last observed time point.
This results in and the use of
eps
instead (when t_max
is NULL
).
mlr3::Measure
-> mlr3proba::MeasureSurv
-> MeasureSurvSchmid
new()
Creates a new instance of this R6 class.
MeasureSurvSchmid$new(ERV = FALSE)
ERV
(logical(1)
)
Standardize measure against a Kaplan-Meier baseline
(Explained Residual Variation)
clone()
The objects of this class are cloneable with this method.
MeasureSurvSchmid$clone(deep = FALSE)
deep
Whether to make a deep clone.
Schemper, Michael, Henderson, Robin (2000). “Predictive Accuracy and Explained Variation in Cox Regression.” Biometrics, 56, 249–255. doi:10.1002/sim.1486.
Schmid, Matthias, Hielscher, Thomas, Augustin, Thomas, Gefeller, Olaf (2011). “A Robust Alternative to the Schemper-Henderson Estimator of Prediction Error.” Biometrics, 67(2), 524–535. doi:10.1111/j.1541-0420.2010.01459.x.
Other survival measures:
mlr_measures_surv.calib_alpha
,
mlr_measures_surv.calib_beta
,
mlr_measures_surv.chambless_auc
,
mlr_measures_surv.cindex
,
mlr_measures_surv.dcalib
,
mlr_measures_surv.graf
,
mlr_measures_surv.hung_auc
,
mlr_measures_surv.intlogloss
,
mlr_measures_surv.logloss
,
mlr_measures_surv.mae
,
mlr_measures_surv.mse
,
mlr_measures_surv.nagelk_r2
,
mlr_measures_surv.oquigley_r2
,
mlr_measures_surv.rcll
,
mlr_measures_surv.rmse
,
mlr_measures_surv.song_auc
,
mlr_measures_surv.song_tnr
,
mlr_measures_surv.song_tpr
,
mlr_measures_surv.uno_auc
,
mlr_measures_surv.uno_tnr
,
mlr_measures_surv.uno_tpr
,
mlr_measures_surv.xu_r2
Other Probabilistic survival measures:
mlr_measures_surv.graf
,
mlr_measures_surv.intlogloss
,
mlr_measures_surv.logloss
,
mlr_measures_surv.rcll
Other distr survival measures:
mlr_measures_surv.calib_alpha
,
mlr_measures_surv.dcalib
,
mlr_measures_surv.graf
,
mlr_measures_surv.intlogloss
,
mlr_measures_surv.logloss
,
mlr_measures_surv.rcll
Calls survAUC::AUC.sh()
.
Assumes Cox PH model specification.
All measures implemented from survAUC should be used with
care, we are aware of problems in implementation that sometimes cause fatal
errors in R.
In future updates some of these measures may be re-written and implemented
directly in mlr3proba
.
This Measure can be instantiated via the dictionary mlr_measures or with the associated sugar function msr():
MeasureSurvSongAUC$new() mlr_measures$get("surv.song_auc") msr("surv.song_auc")
Id | Type | Default | Levels |
times | untyped | - | |
integrated | logical | TRUE | TRUE, FALSE |
type | character | incident | incident, cumulative |
Type: "surv"
Range:
Minimize: FALSE
Required prediction: lp
times
(numeric()
)
If integrated == TRUE
then a vector of time-points over which to integrate the score.
If integrated == FALSE
then a single time point at which to return the score.
integrated
(logical(1)
)
If TRUE
(default), returns the integrated score (eg across
time points); otherwise, not integrated (eg at a single time point).
type
(character(1)
)
A string defining the type of true positive rate (TPR): incident
refers to
incident TPR, cumulative
refers to cumulative TPR.
mlr3::Measure
-> mlr3proba::MeasureSurv
-> mlr3proba::MeasureSurvAUC
-> MeasureSurvSongAUC
new()
Creates a new instance of this R6 class.
MeasureSurvSongAUC$new()
clone()
The objects of this class are cloneable with this method.
MeasureSurvSongAUC$clone(deep = FALSE)
deep
Whether to make a deep clone.
Song, Xiao, Zhou, Xiao-Hua (2008). “A semiparametric approach for the covariate specific ROC curve with survival outcome.” Statistica Sinica, 18(3), 947–65. https://www.jstor.org/stable/24308524.
Other survival measures:
mlr_measures_surv.calib_alpha
,
mlr_measures_surv.calib_beta
,
mlr_measures_surv.chambless_auc
,
mlr_measures_surv.cindex
,
mlr_measures_surv.dcalib
,
mlr_measures_surv.graf
,
mlr_measures_surv.hung_auc
,
mlr_measures_surv.intlogloss
,
mlr_measures_surv.logloss
,
mlr_measures_surv.mae
,
mlr_measures_surv.mse
,
mlr_measures_surv.nagelk_r2
,
mlr_measures_surv.oquigley_r2
,
mlr_measures_surv.rcll
,
mlr_measures_surv.rmse
,
mlr_measures_surv.schmid
,
mlr_measures_surv.song_tnr
,
mlr_measures_surv.song_tpr
,
mlr_measures_surv.uno_auc
,
mlr_measures_surv.uno_tnr
,
mlr_measures_surv.uno_tpr
,
mlr_measures_surv.xu_r2
Other AUC survival measures:
mlr_measures_surv.chambless_auc
,
mlr_measures_surv.hung_auc
,
mlr_measures_surv.song_tnr
,
mlr_measures_surv.song_tpr
,
mlr_measures_surv.uno_auc
,
mlr_measures_surv.uno_tnr
,
mlr_measures_surv.uno_tpr
Other lp survival measures:
mlr_measures_surv.calib_beta
,
mlr_measures_surv.chambless_auc
,
mlr_measures_surv.hung_auc
,
mlr_measures_surv.nagelk_r2
,
mlr_measures_surv.oquigley_r2
,
mlr_measures_surv.song_tnr
,
mlr_measures_surv.song_tpr
,
mlr_measures_surv.uno_auc
,
mlr_measures_surv.uno_tnr
,
mlr_measures_surv.uno_tpr
,
mlr_measures_surv.xu_r2
Calls survAUC::spec.sh()
.
Assumes Cox PH model specification.
times
and lp_thresh
are arbitrarily set to 0
to prevent crashing, these
should be further specified.
All measures implemented from survAUC should be used with
care, we are aware of problems in implementation that sometimes cause fatal
errors in R.
In future updates some of these measures may be re-written and implemented
directly in mlr3proba
.
This Measure can be instantiated via the dictionary mlr_measures or with the associated sugar function msr():
MeasureSurvSongTNR$new() mlr_measures$get("surv.song_tnr") msr("surv.song_tnr")
Id | Type | Default | Range |
times | numeric | - | |
lp_thresh | numeric | 0 | |
Type: "surv"
Range:
Minimize: FALSE
Required prediction: lp
times
(numeric()
)
If integrated == TRUE
then a vector of time-points over which to integrate the score.
If integrated == FALSE
then a single time point at which to return the score.
lp_thresh
(numeric(1)
)
Determines the cutoff threshold of the linear predictor in the
calculation of the TPR/TNR scores.
mlr3::Measure
-> mlr3proba::MeasureSurv
-> mlr3proba::MeasureSurvAUC
-> MeasureSurvSongTNR
new()
Creates a new instance of this R6 class.
MeasureSurvSongTNR$new()
clone()
The objects of this class are cloneable with this method.
MeasureSurvSongTNR$clone(deep = FALSE)
deep
Whether to make a deep clone.
Song, Xiao, Zhou, Xiao-Hua (2008). “A semiparametric approach for the covariate specific ROC curve with survival outcome.” Statistica Sinica, 18(3), 947–65. https://www.jstor.org/stable/24308524.
Other survival measures:
mlr_measures_surv.calib_alpha
,
mlr_measures_surv.calib_beta
,
mlr_measures_surv.chambless_auc
,
mlr_measures_surv.cindex
,
mlr_measures_surv.dcalib
,
mlr_measures_surv.graf
,
mlr_measures_surv.hung_auc
,
mlr_measures_surv.intlogloss
,
mlr_measures_surv.logloss
,
mlr_measures_surv.mae
,
mlr_measures_surv.mse
,
mlr_measures_surv.nagelk_r2
,
mlr_measures_surv.oquigley_r2
,
mlr_measures_surv.rcll
,
mlr_measures_surv.rmse
,
mlr_measures_surv.schmid
,
mlr_measures_surv.song_auc
,
mlr_measures_surv.song_tpr
,
mlr_measures_surv.uno_auc
,
mlr_measures_surv.uno_tnr
,
mlr_measures_surv.uno_tpr
,
mlr_measures_surv.xu_r2
Other AUC survival measures:
mlr_measures_surv.chambless_auc
,
mlr_measures_surv.hung_auc
,
mlr_measures_surv.song_auc
,
mlr_measures_surv.song_tpr
,
mlr_measures_surv.uno_auc
,
mlr_measures_surv.uno_tnr
,
mlr_measures_surv.uno_tpr
Other lp survival measures:
mlr_measures_surv.calib_beta
,
mlr_measures_surv.chambless_auc
,
mlr_measures_surv.hung_auc
,
mlr_measures_surv.nagelk_r2
,
mlr_measures_surv.oquigley_r2
,
mlr_measures_surv.song_auc
,
mlr_measures_surv.song_tpr
,
mlr_measures_surv.uno_auc
,
mlr_measures_surv.uno_tnr
,
mlr_measures_surv.uno_tpr
,
mlr_measures_surv.xu_r2
Calls survAUC::sens.sh()
.
Assumes Cox PH model specification.
times
and lp_thresh
are arbitrarily set to 0
to prevent crashing, these
should be further specified.
All measures implemented from survAUC should be used with
care, we are aware of problems in implementation that sometimes cause fatal
errors in R.
In future updates some of these measures may be re-written and implemented
directly in mlr3proba
.
This Measure can be instantiated via the dictionary mlr_measures or with the associated sugar function msr():
MeasureSurvSongTPR$new() mlr_measures$get("surv.song_tpr") msr("surv.song_tpr")
Id | Type | Default | Levels | Range |
times | numeric | - | |
|
lp_thresh | numeric | 0 | |
|
type | character | incident | incident, cumulative | - |
Type: "surv"
Range:
Minimize: FALSE
Required prediction: lp
times
(numeric()
)
If integrated == TRUE
then a vector of time-points over which to integrate the score.
If integrated == FALSE
then a single time point at which to return the score.
lp_thresh
(numeric(1)
)
Determines the cutoff threshold of the linear predictor in the
calculation of the TPR/TNR scores.
mlr3::Measure
-> mlr3proba::MeasureSurv
-> mlr3proba::MeasureSurvAUC
-> MeasureSurvSongTPR
new()
Creates a new instance of this R6 class.
MeasureSurvSongTPR$new()
clone()
The objects of this class are cloneable with this method.
MeasureSurvSongTPR$clone(deep = FALSE)
deep
Whether to make a deep clone.
Song, Xiao, Zhou, Xiao-Hua (2008). “A semiparametric approach for the covariate specific ROC curve with survival outcome.” Statistica Sinica, 18(3), 947–65. https://www.jstor.org/stable/24308524.
Other survival measures:
mlr_measures_surv.calib_alpha
,
mlr_measures_surv.calib_beta
,
mlr_measures_surv.chambless_auc
,
mlr_measures_surv.cindex
,
mlr_measures_surv.dcalib
,
mlr_measures_surv.graf
,
mlr_measures_surv.hung_auc
,
mlr_measures_surv.intlogloss
,
mlr_measures_surv.logloss
,
mlr_measures_surv.mae
,
mlr_measures_surv.mse
,
mlr_measures_surv.nagelk_r2
,
mlr_measures_surv.oquigley_r2
,
mlr_measures_surv.rcll
,
mlr_measures_surv.rmse
,
mlr_measures_surv.schmid
,
mlr_measures_surv.song_auc
,
mlr_measures_surv.song_tnr
,
mlr_measures_surv.uno_auc
,
mlr_measures_surv.uno_tnr
,
mlr_measures_surv.uno_tpr
,
mlr_measures_surv.xu_r2
Other AUC survival measures:
mlr_measures_surv.chambless_auc
,
mlr_measures_surv.hung_auc
,
mlr_measures_surv.song_auc
,
mlr_measures_surv.song_tnr
,
mlr_measures_surv.uno_auc
,
mlr_measures_surv.uno_tnr
,
mlr_measures_surv.uno_tpr
Other lp survival measures:
mlr_measures_surv.calib_beta
,
mlr_measures_surv.chambless_auc
,
mlr_measures_surv.hung_auc
,
mlr_measures_surv.nagelk_r2
,
mlr_measures_surv.oquigley_r2
,
mlr_measures_surv.song_auc
,
mlr_measures_surv.song_tnr
,
mlr_measures_surv.uno_auc
,
mlr_measures_surv.uno_tnr
,
mlr_measures_surv.uno_tpr
,
mlr_measures_surv.xu_r2
Calls survAUC::AUC.uno()
.
Assumes random censoring.
All measures implemented from survAUC should be used with
care, we are aware of problems in implementation that sometimes cause fatal
errors in R.
In future updates some of these measures may be re-written and implemented
directly in mlr3proba
.
This Measure can be instantiated via the dictionary mlr_measures or with the associated sugar function msr():
MeasureSurvUnoAUC$new() mlr_measures$get("surv.uno_auc") msr("surv.uno_auc")
Id | Type | Default | Levels |
integrated | logical | TRUE | TRUE, FALSE |
times | untyped | - | |
Type: "surv"
Range:
Minimize: FALSE
Required prediction: lp
integrated
(logical(1)
)
If TRUE
(default), returns the integrated score (eg across
time points); otherwise, not integrated (eg at a single time point).
times
(numeric()
)
If integrated == TRUE
then a vector of time-points over which to integrate the score.
If integrated == FALSE
then a single time point at which to return the score.
mlr3::Measure
-> mlr3proba::MeasureSurv
-> mlr3proba::MeasureSurvAUC
-> MeasureSurvUnoAUC
new()
Creates a new instance of this R6 class.
MeasureSurvUnoAUC$new()
clone()
The objects of this class are cloneable with this method.
MeasureSurvUnoAUC$clone(deep = FALSE)
deep
Whether to make a deep clone.
Uno H, Cai T, Tian L, Wei LJ (2007). “Evaluating Prediction Rules fort-Year Survivors With Censored Regression Models.” Journal of the American Statistical Association, 102(478), 527–537. doi:10.1198/016214507000000149.
Other survival measures:
mlr_measures_surv.calib_alpha
,
mlr_measures_surv.calib_beta
,
mlr_measures_surv.chambless_auc
,
mlr_measures_surv.cindex
,
mlr_measures_surv.dcalib
,
mlr_measures_surv.graf
,
mlr_measures_surv.hung_auc
,
mlr_measures_surv.intlogloss
,
mlr_measures_surv.logloss
,
mlr_measures_surv.mae
,
mlr_measures_surv.mse
,
mlr_measures_surv.nagelk_r2
,
mlr_measures_surv.oquigley_r2
,
mlr_measures_surv.rcll
,
mlr_measures_surv.rmse
,
mlr_measures_surv.schmid
,
mlr_measures_surv.song_auc
,
mlr_measures_surv.song_tnr
,
mlr_measures_surv.song_tpr
,
mlr_measures_surv.uno_tnr
,
mlr_measures_surv.uno_tpr
,
mlr_measures_surv.xu_r2
Other AUC survival measures:
mlr_measures_surv.chambless_auc
,
mlr_measures_surv.hung_auc
,
mlr_measures_surv.song_auc
,
mlr_measures_surv.song_tnr
,
mlr_measures_surv.song_tpr
,
mlr_measures_surv.uno_tnr
,
mlr_measures_surv.uno_tpr
Other lp survival measures:
mlr_measures_surv.calib_beta
,
mlr_measures_surv.chambless_auc
,
mlr_measures_surv.hung_auc
,
mlr_measures_surv.nagelk_r2
,
mlr_measures_surv.oquigley_r2
,
mlr_measures_surv.song_auc
,
mlr_measures_surv.song_tnr
,
mlr_measures_surv.song_tpr
,
mlr_measures_surv.uno_tnr
,
mlr_measures_surv.uno_tpr
,
mlr_measures_surv.xu_r2
Calls survAUC::spec.uno()
.
Assumes random censoring.
times
and lp_thresh
are arbitrarily set to 0
to prevent crashing, these
should be further specified.
All measures implemented from survAUC should be used with
care, we are aware of problems in implementation that sometimes cause fatal
errors in R.
In future updates some of these measures may be re-written and implemented
directly in mlr3proba
.
This Measure can be instantiated via the dictionary mlr_measures or with the associated sugar function msr():
MeasureSurvUnoTNR$new() mlr_measures$get("surv.uno_tnr") msr("surv.uno_tnr")
Id | Type | Default | Range |
times | numeric | - | |
lp_thresh | numeric | 0 | |
Type: "surv"
Range:
Minimize: FALSE
Required prediction: lp
times
(numeric()
)
A vector of time-points at which we calculate the TPR/TNR scores.
lp_thresh
(numeric(1)
)
Determines the cutoff threshold of the linear predictor in the
calculation of the TPR/TNR scores.
mlr3::Measure
-> mlr3proba::MeasureSurv
-> mlr3proba::MeasureSurvAUC
-> MeasureSurvUnoTNR
new()
Creates a new instance of this R6 class.
MeasureSurvUnoTNR$new()
clone()
The objects of this class are cloneable with this method.
MeasureSurvUnoTNR$clone(deep = FALSE)
deep
Whether to make a deep clone.
Uno H, Cai T, Tian L, Wei LJ (2007). “Evaluating Prediction Rules fort-Year Survivors With Censored Regression Models.” Journal of the American Statistical Association, 102(478), 527–537. doi:10.1198/016214507000000149.
Other survival measures:
mlr_measures_surv.calib_alpha
,
mlr_measures_surv.calib_beta
,
mlr_measures_surv.chambless_auc
,
mlr_measures_surv.cindex
,
mlr_measures_surv.dcalib
,
mlr_measures_surv.graf
,
mlr_measures_surv.hung_auc
,
mlr_measures_surv.intlogloss
,
mlr_measures_surv.logloss
,
mlr_measures_surv.mae
,
mlr_measures_surv.mse
,
mlr_measures_surv.nagelk_r2
,
mlr_measures_surv.oquigley_r2
,
mlr_measures_surv.rcll
,
mlr_measures_surv.rmse
,
mlr_measures_surv.schmid
,
mlr_measures_surv.song_auc
,
mlr_measures_surv.song_tnr
,
mlr_measures_surv.song_tpr
,
mlr_measures_surv.uno_auc
,
mlr_measures_surv.uno_tpr
,
mlr_measures_surv.xu_r2
Other AUC survival measures:
mlr_measures_surv.chambless_auc
,
mlr_measures_surv.hung_auc
,
mlr_measures_surv.song_auc
,
mlr_measures_surv.song_tnr
,
mlr_measures_surv.song_tpr
,
mlr_measures_surv.uno_auc
,
mlr_measures_surv.uno_tpr
Other lp survival measures:
mlr_measures_surv.calib_beta
,
mlr_measures_surv.chambless_auc
,
mlr_measures_surv.hung_auc
,
mlr_measures_surv.nagelk_r2
,
mlr_measures_surv.oquigley_r2
,
mlr_measures_surv.song_auc
,
mlr_measures_surv.song_tnr
,
mlr_measures_surv.song_tpr
,
mlr_measures_surv.uno_auc
,
mlr_measures_surv.uno_tpr
,
mlr_measures_surv.xu_r2
Calls survAUC::sens.uno()
.
Assumes random censoring.
times
and lp_thresh
are arbitrarily set to 0
to prevent crashing, these
should be further specified.
All measures implemented from survAUC should be used with
care, we are aware of problems in implementation that sometimes cause fatal
errors in R.
In future updates some of these measures may be re-written and implemented
directly in mlr3proba
.
This Measure can be instantiated via the dictionary mlr_measures or with the associated sugar function msr():
MeasureSurvUnoTPR$new() mlr_measures$get("surv.uno_tpr") msr("surv.uno_tpr")
Id | Type | Default | Range |
times | numeric | - | |
lp_thresh | numeric | 0 | |
Type: "surv"
Range:
Minimize: FALSE
Required prediction: lp
times
(numeric()
)
A vector of time-points at which we calculate the TPR/TNR scores.
lp_thresh
(numeric(1)
)
Determines the cutoff threshold of the linear predictor in the
calculation of the TPR/TNR scores.
mlr3::Measure
-> mlr3proba::MeasureSurv
-> mlr3proba::MeasureSurvAUC
-> MeasureSurvUnoTPR
new()
Creates a new instance of this R6 class.
MeasureSurvUnoTPR$new()
clone()
The objects of this class are cloneable with this method.
MeasureSurvUnoTPR$clone(deep = FALSE)
deep
Whether to make a deep clone.
Uno H, Cai T, Tian L, Wei LJ (2007). “Evaluating Prediction Rules fort-Year Survivors With Censored Regression Models.” Journal of the American Statistical Association, 102(478), 527–537. doi:10.1198/016214507000000149.
Other survival measures:
mlr_measures_surv.calib_alpha
,
mlr_measures_surv.calib_beta
,
mlr_measures_surv.chambless_auc
,
mlr_measures_surv.cindex
,
mlr_measures_surv.dcalib
,
mlr_measures_surv.graf
,
mlr_measures_surv.hung_auc
,
mlr_measures_surv.intlogloss
,
mlr_measures_surv.logloss
,
mlr_measures_surv.mae
,
mlr_measures_surv.mse
,
mlr_measures_surv.nagelk_r2
,
mlr_measures_surv.oquigley_r2
,
mlr_measures_surv.rcll
,
mlr_measures_surv.rmse
,
mlr_measures_surv.schmid
,
mlr_measures_surv.song_auc
,
mlr_measures_surv.song_tnr
,
mlr_measures_surv.song_tpr
,
mlr_measures_surv.uno_auc
,
mlr_measures_surv.uno_tnr
,
mlr_measures_surv.xu_r2
Other AUC survival measures:
mlr_measures_surv.chambless_auc
,
mlr_measures_surv.hung_auc
,
mlr_measures_surv.song_auc
,
mlr_measures_surv.song_tnr
,
mlr_measures_surv.song_tpr
,
mlr_measures_surv.uno_auc
,
mlr_measures_surv.uno_tnr
Other lp survival measures:
mlr_measures_surv.calib_beta
,
mlr_measures_surv.chambless_auc
,
mlr_measures_surv.hung_auc
,
mlr_measures_surv.nagelk_r2
,
mlr_measures_surv.oquigley_r2
,
mlr_measures_surv.song_auc
,
mlr_measures_surv.song_tnr
,
mlr_measures_surv.song_tpr
,
mlr_measures_surv.uno_auc
,
mlr_measures_surv.uno_tnr
,
mlr_measures_surv.xu_r2
Calls survAUC::XO()
.
Assumes Cox PH model specification.
All measures implemented from survAUC should be used with
care, we are aware of problems in implementation that sometimes cause fatal
errors in R.
In future updates some of these measures may be re-written and implemented
directly in mlr3proba
.
This Measure can be instantiated via the dictionary mlr_measures or with the associated sugar function msr():
MeasureSurvXuR2$new() mlr_measures$get("surv.xu_r2") msr("surv.xu_r2")
Empty ParamSet
Type: "surv"
Range:
Minimize: FALSE
Required prediction: lp
mlr3::Measure
-> mlr3proba::MeasureSurv
-> MeasureSurvXuR2
new()
Creates a new instance of this R6 class.
MeasureSurvXuR2$new()
clone()
The objects of this class are cloneable with this method.
MeasureSurvXuR2$clone(deep = FALSE)
deep
Whether to make a deep clone.
Xu R, O'Quigley J (1999). “A R2 type measure of dependence for proportional hazards models.” Journal of Nonparametric Statistics, 12(1), 83–107. doi:10.1080/10485259908832799.
Other survival measures:
mlr_measures_surv.calib_alpha
,
mlr_measures_surv.calib_beta
,
mlr_measures_surv.chambless_auc
,
mlr_measures_surv.cindex
,
mlr_measures_surv.dcalib
,
mlr_measures_surv.graf
,
mlr_measures_surv.hung_auc
,
mlr_measures_surv.intlogloss
,
mlr_measures_surv.logloss
,
mlr_measures_surv.mae
,
mlr_measures_surv.mse
,
mlr_measures_surv.nagelk_r2
,
mlr_measures_surv.oquigley_r2
,
mlr_measures_surv.rcll
,
mlr_measures_surv.rmse
,
mlr_measures_surv.schmid
,
mlr_measures_surv.song_auc
,
mlr_measures_surv.song_tnr
,
mlr_measures_surv.song_tpr
,
mlr_measures_surv.uno_auc
,
mlr_measures_surv.uno_tnr
,
mlr_measures_surv.uno_tpr
Other R2 survival measures:
mlr_measures_surv.nagelk_r2
,
mlr_measures_surv.oquigley_r2
Other lp survival measures:
mlr_measures_surv.calib_beta
,
mlr_measures_surv.chambless_auc
,
mlr_measures_surv.hung_auc
,
mlr_measures_surv.nagelk_r2
,
mlr_measures_surv.oquigley_r2
,
mlr_measures_surv.song_auc
,
mlr_measures_surv.song_tnr
,
mlr_measures_surv.song_tpr
,
mlr_measures_surv.uno_auc
,
mlr_measures_surv.uno_tnr
,
mlr_measures_surv.uno_tpr
Composes a survival distribution (distr
) using the linear predictor
predictions (lp
) from a given LearnerSurv during training and prediction,
utilizing the breslow estimator. The specified learner
must be
capable of generating lp
-type predictions (e.g., a Cox-type model).
This PipeOp can be instantiated via the Dictionary mlr_pipeops or with the associated sugar function po():
PipeOpBreslow$new(learner) mlr_pipeops$get("breslowcompose", learner) po("breslowcompose", learner, breslow.overwrite = TRUE)
PipeOpBreslow is like a LearnerSurv.
It has one input channel, named input
that takes a TaskSurv during training
and another TaskSurv during prediction.
PipeOpBreslow has one output channel named output
, producing NULL
during
training and a PredictionSurv during prediction.
The $state
slot stores the times
and status
survival target variables of
the train TaskSurv as well as the lp
predictions on the train set.
The parameters are:
breslow.overwrite
:: logical(1)
If FALSE
(default) then the compositor does nothing and returns the
input learner
's PredictionSurv.
If TRUE
or in the case that the input learner
doesn't have distr
predictions, then the distr
is overwritten with the distr
composed
from lp
and the train set information using breslow.
This is useful for changing the prediction distr
from one model form to
another.
mlr3pipelines::PipeOp
-> PipeOpBreslow
learner
(mlr3::Learner)
The input survival learner.
new()
Creates a new instance of this R6 class.
PipeOpBreslow$new(learner, id = NULL, param_vals = list())
learner
(LearnerSurv)
Survival learner which must provide lp
-type predictions
id
(character(1))
Identifier of the resulting object. If NULL
(default), it will be set
as the id
of the input learner
.
param_vals
(list()
)
List of hyperparameter settings, overwriting the hyperparameter settings that would
otherwise be set during construction.
clone()
The objects of this class are cloneable with this method.
PipeOpBreslow$clone(deep = FALSE)
deep
Whether to make a deep clone.
Cox DR (1972). “Regression Models and Life-Tables.” Journal of the Royal Statistical Society: Series B (Methodological), 34(2), 187–202. doi:10.1111/j.2517-6161.1972.tb00899.x.
Lin, Y. D (2007). “On the Breslow estimator.” Lifetime Data Analysis, 13(4), 471-480. doi:10.1007/s10985-007-9048-y.
Other survival compositors:
mlr_pipeops_crankcompose
,
mlr_pipeops_distrcompose
,
mlr_pipeops_responsecompose
## Not run: library(mlr3) library(mlr3pipelines) task = tsk("rats") part = partition(task, ratio = 0.8) train_task = task$clone()$filter(part$train) test_task = task$clone()$filter(part$test) learner = lrn("surv.coxph") # learner with lp predictions b = po("breslowcompose", learner = learner, breslow.overwrite = TRUE) b$train(list(train_task)) p = b$predict(list(test_task))[[1L]] ## End(Not run)
## Not run: library(mlr3) library(mlr3pipelines) task = tsk("rats") part = partition(task, ratio = 0.8) train_task = task$clone()$filter(part$train) test_task = task$clone()$filter(part$test) learner = lrn("surv.coxph") # learner with lp predictions b = po("breslowcompose", learner = learner, breslow.overwrite = TRUE) b$train(list(train_task)) p = b$predict(list(test_task))[[1L]] ## End(Not run)
Combines a predicted response
and se
from PredictionRegr with a specified probability
distribution to estimate (or 'compose') a distr
prediction.
This PipeOp can be instantiated via the
dictionary mlr3pipelines::mlr_pipeops or with the associated sugar
function mlr3pipelines::po()
:
PipeOpProbregr$new() mlr_pipeops$get("compose_probregr") po("compose_probregr")
PipeOpProbregr has two input channels named "input_response"
and "input_se"
,
which take NULL
during training and two PredictionRegrs during prediction, these should
respectively contain the response
and se
return type, the same object can be passed twice.
The output during prediction is a PredictionRegr with the "response" from input_response
,
the "se" from input_se
and a "distr" created from combining the two.
The $state
is left empty (list()
).
dist
:: character(1)
Location-scale distribution to use for composition. Current choices are
"Uniform"
(default), "Normal"
, "Cauchy"
, "Gumbel"
, "Laplace"
,
"Logistic"
. All implemented via distr6.
The composition is created by substituting the response
and se
predictions into the
distribution location and scale parameters respectively.
mlr3pipelines::PipeOp
-> PipeOpProbregr
new()
Creates a new instance of this R6 class.
PipeOpProbregr$new(id = "compose_probregr", param_vals = list())
id
(character(1)
)
Identifier of the resulting object.
param_vals
(list()
)
List of hyperparameter settings, overwriting the hyperparameter settings that would
otherwise be set during construction.
clone()
The objects of this class are cloneable with this method.
PipeOpProbregr$clone(deep = FALSE)
deep
Whether to make a deep clone.
## Not run: library(mlr3) library(mlr3pipelines) set.seed(1) task = tsk("boston_housing") # Option 1: Use a learner that can predict se learn = lrn("regr.featureless", predict_type = "se") pred = learn$train(task)$predict(task) poc = po("compose_probregr") poc$predict(list(pred, pred))[[1]] # Option 2: Use two learners, one for response and the other for se learn_response = lrn("regr.rpart") learn_se = lrn("regr.featureless", predict_type = "se") pred_response = learn_response$train(task)$predict(task) pred_se = learn_se$train(task)$predict(task) poc = po("compose_probregr") poc$predict(list(pred_response, pred_se))[[1]] ## End(Not run)
## Not run: library(mlr3) library(mlr3pipelines) set.seed(1) task = tsk("boston_housing") # Option 1: Use a learner that can predict se learn = lrn("regr.featureless", predict_type = "se") pred = learn$train(task)$predict(task) poc = po("compose_probregr") poc$predict(list(pred, pred))[[1]] # Option 2: Use two learners, one for response and the other for se learn_response = lrn("regr.rpart") learn_se = lrn("regr.featureless", predict_type = "se") pred_response = learn_response$train(task)$predict(task) pred_se = learn_se$train(task)$predict(task) poc = po("compose_probregr") poc$predict(list(pred_response, pred_se))[[1]] ## End(Not run)
Uses a predicted distr
in a PredictionSurv to estimate (or 'compose') a crank
prediction.
This PipeOp can be instantiated via the
dictionary mlr3pipelines::mlr_pipeops or with the associated sugar
function mlr3pipelines::po()
:
PipeOpCrankCompositor$new() mlr_pipeops$get("crankcompose") po("crankcompose")
PipeOpCrankCompositor has one input channel named "input"
, which takes NULL
during training and PredictionSurv during prediction.
PipeOpCrankCompositor has one output channel named "output"
, producing NULL
during training and a PredictionSurv during prediction.
The output during prediction is the PredictionSurv from the input but with the crank
predict type overwritten by the given estimation method.
The $state
is left empty (list()
).
method
:: character(1)
Determines what method should be used to produce a continuous ranking from the distribution.
Currently only mort
is supported, which is the sum of the cumulative hazard, also called expected/ensemble mortality, see Ishwaran et al. (2008).
For more details, see get_mortality()
.
overwrite
:: logical(1)
If FALSE
(default) and the prediction already has a crank
prediction, then the compositor returns the input prediction unchanged.
If TRUE
, then the crank
will be overwritten.
mlr3pipelines::PipeOp
-> PipeOpCrankCompositor
new()
Creates a new instance of this R6 class.
PipeOpCrankCompositor$new(id = "crankcompose", param_vals = list())
id
(character(1)
)
Identifier of the resulting object.
param_vals
(list()
)
List of hyperparameter settings, overwriting the hyperparameter settings that would
otherwise be set during construction.
clone()
The objects of this class are cloneable with this method.
PipeOpCrankCompositor$clone(deep = FALSE)
deep
Whether to make a deep clone.
Sonabend, Raphael, Bender, Andreas, Vollmer, Sebastian (2022). “Avoiding C-hacking when evaluating survival distribution predictions with discrimination measures.” Bioinformatics. ISSN 1367-4803, doi:10.1093/BIOINFORMATICS/BTAC451, https://academic.oup.com/bioinformatics/advance-article/doi/10.1093/bioinformatics/btac451/6640155.
Ishwaran, Hemant, Kogalur, B U, Blackstone, H E, Lauer, S M, others (2008). “Random survival forests.” The Annals of applied statistics, 2(3), 841–860.
Other survival compositors:
mlr_pipeops_compose_breslow_distr
,
mlr_pipeops_distrcompose
,
mlr_pipeops_responsecompose
## Not run: library(mlr3pipelines) task = tsk("rats") # change the crank prediction type of a Cox's model predictions pred = lrn("surv.coxph")$train(task)$predict(task) poc = po("crankcompose", param_vals = list(overwrite = TRUE)) poc$predict(list(pred))[[1L]] ## End(Not run)
## Not run: library(mlr3pipelines) task = tsk("rats") # change the crank prediction type of a Cox's model predictions pred = lrn("surv.coxph")$train(task)$predict(task) poc = po("crankcompose", param_vals = list(overwrite = TRUE)) poc$predict(list(pred))[[1L]] ## End(Not run)
Estimates (or 'composes') a survival distribution from a predicted baseline
survival distribution (distr
) and a linear predictor (lp
) from two PredictionSurvs.
Compositor Assumptions:
The baseline distr
is a discrete estimator, e.g. surv.kaplan.
The composed distr
is of a linear form
This PipeOp can be instantiated via the
dictionary mlr3pipelines::mlr_pipeops or with the associated sugar
function mlr3pipelines::po()
:
PipeOpDistrCompositor$new() mlr_pipeops$get("distrcompose") po("distrcompose")
PipeOpDistrCompositor has two input channels, "base"
and "pred"
.
Both input channels take NULL
during training and PredictionSurv during prediction.
PipeOpDistrCompositor has one output channel named "output"
, producing
NULL
during training and a PredictionSurv during prediction.
The output during prediction is the PredictionSurv from the "pred"
input
but with an extra (or overwritten) column for the distr
predict type; which
is composed from the distr
of "base"
and the lp
of "pred"
.
If no lp
predictions have been made or exist, then the "pred"
is returned unchanged.
The $state
is left empty (list()
).
The parameters are:
form
:: character(1)
Determines the form that the predicted linear survival model should take. This is either,
accelerated-failure time, aft
, proportional hazards, ph
, or proportional odds, po
.
Default aft
.
overwrite
:: logical(1)
If FALSE
(default) then if the "pred" input already has a distr
, the compositor does
nothing and returns the given PredictionSurv. If TRUE
, then the distr
is overwritten
with the distr
composed from lp
- this is useful for changing the prediction
distr
from one model form to another.
scale_lp
:: logical(1)
This option is only applicable to form
equal to "aft"
. If TRUE
, it
min-max scales the linear prediction scores to be in the interval ,
avoiding extrapolation of the baseline
on the transformed time
points
, as these will be
,
and so always smaller than the maximum time point for which we have estimated
.
Note that this is just a heuristic to get reasonable results in the
case you observe survival predictions to be e.g. constant after the AFT
composition and it definitely provides no guarantee for creating calibrated
distribution predictions (as none of these methods do). Therefore, it is
set to
FALSE
by default.
The respective form
s above have respective survival distributions:
where is the estimated baseline survival distribution, and
is the
predicted linear predictor.
For an example use of the "aft"
composition using Kaplan-Meier as a baseline
distribution, see Norman et al. (2024).
mlr3pipelines::PipeOp
-> PipeOpDistrCompositor
new()
Creates a new instance of this R6 class.
PipeOpDistrCompositor$new(id = "distrcompose", param_vals = list())
id
(character(1)
)
Identifier of the resulting object.
param_vals
(list()
)
List of hyperparameter settings, overwriting the hyperparameter settings that would
otherwise be set during construction.
clone()
The objects of this class are cloneable with this method.
PipeOpDistrCompositor$clone(deep = FALSE)
deep
Whether to make a deep clone.
Norman, A P, Li, Wanlu, Jiang, Wenyu, Chen, E B (2024). “deepAFT: A nonlinear accelerated failure time model with artificial neural network.” Statistics in Medicine. doi:10.1002/sim.10152.
Other survival compositors:
mlr_pipeops_compose_breslow_distr
,
mlr_pipeops_crankcompose
,
mlr_pipeops_responsecompose
## Not run: library(mlr3) library(mlr3pipelines) task = tsk("rats") base = lrn("surv.kaplan")$train(task)$predict(task) pred = lrn("surv.coxph")$train(task)$predict(task) # let's change the distribution prediction of Cox (Breslow-based) to an AFT form: pod = po("distrcompose", param_vals = list(form = "aft", overwrite = TRUE)) pod$predict(list(base = base, pred = pred))[[1]] ## End(Not run)
## Not run: library(mlr3) library(mlr3pipelines) task = tsk("rats") base = lrn("surv.kaplan")$train(task)$predict(task) pred = lrn("surv.coxph")$train(task)$predict(task) # let's change the distribution prediction of Cox (Breslow-based) to an AFT form: pod = po("distrcompose", param_vals = list(form = "aft", overwrite = TRUE)) pod$predict(list(base = base, pred = pred))[[1]] ## End(Not run)
Uses a predicted survival distribution (distr
) in a PredictionSurv to estimate (or 'compose') an expected survival time (response
) prediction.
Practically, this PipeOp
summarizes an observation's survival curve/distribution to a single number which can be either the restricted mean survival time or the median survival time.
This PipeOp can be instantiated via the
dictionary mlr3pipelines::mlr_pipeops or with the associated sugar
function mlr3pipelines::po()
:
PipeOpResponseCompositor$new() mlr_pipeops$get("responsecompose") po("responsecompose")
PipeOpResponseCompositor has one input channel named "input"
, which takes
NULL
during training and PredictionSurv during prediction.
PipeOpResponseCompositor has one output channel named "output"
, producing NULL
during training
and a PredictionSurv during prediction.
The output during prediction is the PredictionSurv from the input but with the response
predict type overwritten by the given method.
The $state
is left empty (list()
).
method
:: character(1)
Determines what method should be used to produce a survival time (response) from the survival distribution.
Available methods are "rmst"
and "median"
, corresponding to the restricted mean survival time and the median survival time respectively.
tau
:: numeric(1)
Determines the time point up to which we calculate the restricted mean survival time (works only for the "rmst"
method).
If NULL
(default), all the available time points in the predicted survival distribution will be used.
add_crank
:: logical(1)
If TRUE
then crank
predict type will be set as -response
(as higher survival times correspond to lower risk).
Works only if overwrite
is TRUE
.
overwrite
:: logical(1)
If FALSE
(default) and the prediction already has a response
prediction, then the compositor returns the input prediction unchanged.
If TRUE
, then the response
(and the crank
, if add_crank
is TRUE
) will be overwritten.
The restricted mean survival time is the default/preferred method and is calculated as follows:
where is the expected survival time,
is the time cutoff/horizon and
are the predicted survival probabilities of observation
for all the
time points.
The survival time is just the first time point for which the survival probability is less than
.
If no such time point exists (e.g. when the survival distribution is not proper due to high censoring) we return the last time point.
This is not a good estimate to use in general, only a reasonable substitute in such cases.
mlr3pipelines::PipeOp
-> PipeOpResponseCompositor
new()
Creates a new instance of this R6 class.
PipeOpResponseCompositor$new(id = "responsecompose", param_vals = list())
id
(character(1)
)
Identifier of the resulting object.
param_vals
(list()
)
List of hyperparameter settings, overwriting the hyperparameter settings that would
otherwise be set during construction.
clone()
The objects of this class are cloneable with this method.
PipeOpResponseCompositor$clone(deep = FALSE)
deep
Whether to make a deep clone.
Zhao, Lihui, Claggett, Brian, Tian, Lu, Uno, Hajime, Pfeffer, A. M, Solomon, D. S, Trippa, Lorenzo, Wei, J. L (2016). “On the restricted mean survival time curve in survival analysis.” Biometrics, 72(1), 215–221. ISSN 1541-0420, doi:10.1111/BIOM.12384, https://onlinelibrary.wiley.com/doi/full/10.1111/biom.12384.
Other survival compositors:
mlr_pipeops_compose_breslow_distr
,
mlr_pipeops_crankcompose
,
mlr_pipeops_distrcompose
## Not run: library(mlr3pipelines) task = tsk("rats") # add survival time prediction type to the predictions of a Cox model # Median survival time as response pred = lrn("surv.coxph")$train(task)$predict(task) por = po("responsecompose", param_vals = list(method = "median", overwrite = TRUE)) por$predict(list(pred))[[1L]] # mostly improper survival distributions, "median" sets the survival time # to the last time point # RMST (default) as response, while also changing the `crank` to `-response` por = po("responsecompose", param_vals = list(overwrite = TRUE, add_crank = TRUE)) por$predict(list(pred))[[1L]] ## End(Not run)
## Not run: library(mlr3pipelines) task = tsk("rats") # add survival time prediction type to the predictions of a Cox model # Median survival time as response pred = lrn("surv.coxph")$train(task)$predict(task) por = po("responsecompose", param_vals = list(method = "median", overwrite = TRUE)) por$predict(list(pred))[[1L]] # mostly improper survival distributions, "median" sets the survival time # to the last time point # RMST (default) as response, while also changing the `crank` to `-response` por = po("responsecompose", param_vals = list(overwrite = TRUE, add_crank = TRUE)) por$predict(list(pred))[[1L]] ## End(Not run)
Perform (weighted) prediction averaging from survival PredictionSurvs by connecting
PipeOpSurvAvg
to multiple PipeOpLearner outputs.
The resulting prediction will aggregate any predict types that are contained within all inputs.
Any predict types missing from at least one input will be set to NULL
. These are aggregated
as follows:
"response"
, "crank"
, and "lp"
are all a weighted average from the incoming predictions.
"distr"
is a distr6::VectorDistribution containing distr6::MixtureDistributions.
Weights can be set as a parameter; if none are provided, defaults to equal weights for each prediction.
Input and output channels are inherited from PipeOpEnsemble with a PredictionSurv for inputs and outputs.
The $state
is left empty (list()
).
The parameters are the parameters inherited from the PipeOpEnsemble.
Inherits from PipeOpEnsemble by implementing the
private$weighted_avg_predictions()
method.
mlr3pipelines::PipeOp
-> mlr3pipelines::PipeOpEnsemble
-> PipeOpSurvAvg
new()
Creates a new instance of this R6 class.
PipeOpSurvAvg$new(innum = 0, id = "survavg", param_vals = list(), ...)
innum
(numeric(1)
)
Determines the number of input channels.
If innum
is 0 (default), a vararg input channel is created that can take an arbitrary
number of inputs.
id
(character(1)
)
Identifier of the resulting object.
param_vals
(list()
)
List of hyperparameter settings, overwriting the hyperparameter settings that would
otherwise be set during construction.
...
(ANY
)
Additional arguments passed to mlr3pipelines::PipeOpEnsemble.
clone()
The objects of this class are cloneable with this method.
PipeOpSurvAvg$clone(deep = FALSE)
deep
Whether to make a deep clone.
Other PipeOps:
PipeOpPredTransformer
,
PipeOpTaskTransformer
,
PipeOpTransformer
,
mlr_pipeops_trafopred_classifsurv_IPCW
,
mlr_pipeops_trafopred_classifsurv_disctime
,
mlr_pipeops_trafopred_regrsurv
,
mlr_pipeops_trafopred_survregr
,
mlr_pipeops_trafotask_regrsurv
,
mlr_pipeops_trafotask_survclassif_IPCW
,
mlr_pipeops_trafotask_survclassif_disctime
,
mlr_pipeops_trafotask_survregr
## Not run: library(mlr3) library(mlr3pipelines) task = tsk("rats") p1 = lrn("surv.coxph")$train(task)$predict(task) p2 = lrn("surv.kaplan")$train(task)$predict(task) poc = po("survavg", param_vals = list(weights = c(0.2, 0.8))) poc$predict(list(p1, p2)) ## End(Not run)
## Not run: library(mlr3) library(mlr3pipelines) task = tsk("rats") p1 = lrn("surv.coxph")$train(task)$predict(task) p2 = lrn("surv.kaplan")$train(task)$predict(task) poc = po("survavg", param_vals = list(weights = c(0.2, 0.8))) poc$predict(list(p1, p2)) ## End(Not run)
Transform PredictionClassif to PredictionSurv by converting event probabilities of a pseudo status variable (discrete time hazards) to survival probabilities using the product rule (Tutz et al. 2016):
Where:
We assume that continuous time is divided into time intervals
is the survival probability at time
is the discrete-time hazard (classifier prediction), i.e. the
conditional probability for an event in the
-interval.
This PipeOp can be instantiated via the
dictionary mlr3pipelines::mlr_pipeops
or with the associated sugar function mlr3pipelines::po()
:
PipeOpPredClassifSurvDiscTime$new() mlr_pipeops$get("trafopred_classifsurv_disctime") po("trafopred_classifsurv_disctime")
The input is a PredictionClassif and a data.table with the transformed data both generated by PipeOpTaskSurvClassifDiscTime. The output is the input PredictionClassif transformed to a PredictionSurv. Only works during prediction phase.
mlr3pipelines::PipeOp
-> PipeOpPredClassifSurvDiscTime
new()
Creates a new instance of this R6 class.
PipeOpPredClassifSurvDiscTime$new(id = "trafopred_classifsurv_disctime")
id
(character(1))
Identifier of the resulting object.
clone()
The objects of this class are cloneable with this method.
PipeOpPredClassifSurvDiscTime$clone(deep = FALSE)
deep
Whether to make a deep clone.
Tutz, Gerhard, Schmid, Matthias (2016). Modeling Discrete Time-to-Event Data, series Springer Series in Statistics. Springer International Publishing. ISBN 978-3-319-28156-8 978-3-319-28158-2, http://link.springer.com/10.1007/978-3-319-28158-2.
Other PipeOps:
PipeOpPredTransformer
,
PipeOpTaskTransformer
,
PipeOpTransformer
,
mlr_pipeops_survavg
,
mlr_pipeops_trafopred_classifsurv_IPCW
,
mlr_pipeops_trafopred_regrsurv
,
mlr_pipeops_trafopred_survregr
,
mlr_pipeops_trafotask_regrsurv
,
mlr_pipeops_trafotask_survclassif_IPCW
,
mlr_pipeops_trafotask_survclassif_disctime
,
mlr_pipeops_trafotask_survregr
Other Transformation PipeOps:
mlr_pipeops_trafopred_classifsurv_IPCW
,
mlr_pipeops_trafopred_regrsurv
,
mlr_pipeops_trafopred_survregr
,
mlr_pipeops_trafotask_regrsurv
,
mlr_pipeops_trafotask_survclassif_IPCW
,
mlr_pipeops_trafotask_survclassif_disctime
,
mlr_pipeops_trafotask_survregr
Transform PredictionClassif to PredictionSurv using the Inverse Probability of Censoring Weights (IPCW) method by Vock et al. (2016).
This PipeOp can be instantiated via the
dictionary mlr3pipelines::mlr_pipeops
or with the associated sugar function mlr3pipelines::po()
:
PipeOpPredClassifSurvIPCW$new() mlr_pipeops$get("trafopred_classifsurv_IPCW") po("trafopred_classifsurv_IPCW")
The input is a PredictionClassif and a data.table containing observed times, censoring indicators and row ids, all generated by PipeOpTaskSurvClassifIPCW during the prediction phase.
The output is the input PredictionClassif transformed to a PredictionSurv.
Each input classification probability prediction corresponds to the
probability of having the event up to the specified cutoff time
,
see Vock et al. (2016) and PipeOpTaskSurvClassifIPCW.
Therefore, these predictions serve as continuous risk scores that can be
directly interpreted as
crank
predictions in the right-censored survival
setting. We also map them to the survival distribution prediction distr
,
at the specified cutoff time point , i.e. as
.
Survival measures that use the survival distribution (eg ISBS)
should be evaluated exactly at the cutoff time point
, see example.
mlr3pipelines::PipeOp
-> PipeOpPredClassifSurvIPCW
new()
Creates a new instance of this R6 class.
PipeOpPredClassifSurvIPCW$new(id = "trafopred_classifsurv_IPCW")
id
(character(1))
Identifier of the resulting object.
clone()
The objects of this class are cloneable with this method.
PipeOpPredClassifSurvIPCW$clone(deep = FALSE)
deep
Whether to make a deep clone.
Vock, M D, Wolfson, Julian, Bandyopadhyay, Sunayan, Adomavicius, Gediminas, Johnson, E P, Vazquez-Benitez, Gabriela, O'Connor, J P (2016). “Adapting machine learning techniques to censored time-to-event health record data: A general-purpose approach using inverse probability of censoring weighting.” Journal of Biomedical Informatics, 61, 119–131. doi:10.1016/j.jbi.2016.03.009, https://www.sciencedirect.com/science/article/pii/S1532046416000496.
Other PipeOps:
PipeOpPredTransformer
,
PipeOpTaskTransformer
,
PipeOpTransformer
,
mlr_pipeops_survavg
,
mlr_pipeops_trafopred_classifsurv_disctime
,
mlr_pipeops_trafopred_regrsurv
,
mlr_pipeops_trafopred_survregr
,
mlr_pipeops_trafotask_regrsurv
,
mlr_pipeops_trafotask_survclassif_IPCW
,
mlr_pipeops_trafotask_survclassif_disctime
,
mlr_pipeops_trafotask_survregr
Other Transformation PipeOps:
mlr_pipeops_trafopred_classifsurv_disctime
,
mlr_pipeops_trafopred_regrsurv
,
mlr_pipeops_trafopred_survregr
,
mlr_pipeops_trafotask_regrsurv
,
mlr_pipeops_trafotask_survclassif_IPCW
,
mlr_pipeops_trafotask_survclassif_disctime
,
mlr_pipeops_trafotask_survregr
Transform PredictionRegr to PredictionSurv.
Input and output channels are inherited from PipeOpPredTransformer.
The output is the input PredictionRegr transformed to a PredictionSurv. Censoring can be
added with the status
hyper-parameter. se
is ignored.
The $state
is a named list
with the $state
elements inherited from PipeOpPredTransformer
.
The parameters are
status :: (numeric(1))
If NULL
then assumed no censoring in the dataset. Otherwise should be a vector of 0/1
s
of same length as the prediction object, where 1
is dead and 0
censored.
mlr3pipelines::PipeOp
-> mlr3proba::PipeOpTransformer
-> mlr3proba::PipeOpPredTransformer
-> PipeOpPredRegrSurv
new()
Creates a new instance of this R6 class.
PipeOpPredRegrSurv$new(id = "trafopred_regrsurv", param_vals = list())
id
(character(1)
)
Identifier of the resulting object.
param_vals
(list()
)
List of hyperparameter settings, overwriting the hyperparameter settings that would
otherwise be set during construction.
clone()
The objects of this class are cloneable with this method.
PipeOpPredRegrSurv$clone(deep = FALSE)
deep
Whether to make a deep clone.
Other PipeOps:
PipeOpPredTransformer
,
PipeOpTaskTransformer
,
PipeOpTransformer
,
mlr_pipeops_survavg
,
mlr_pipeops_trafopred_classifsurv_IPCW
,
mlr_pipeops_trafopred_classifsurv_disctime
,
mlr_pipeops_trafopred_survregr
,
mlr_pipeops_trafotask_regrsurv
,
mlr_pipeops_trafotask_survclassif_IPCW
,
mlr_pipeops_trafotask_survclassif_disctime
,
mlr_pipeops_trafotask_survregr
Other Transformation PipeOps:
mlr_pipeops_trafopred_classifsurv_IPCW
,
mlr_pipeops_trafopred_classifsurv_disctime
,
mlr_pipeops_trafopred_survregr
,
mlr_pipeops_trafotask_regrsurv
,
mlr_pipeops_trafotask_survclassif_IPCW
,
mlr_pipeops_trafotask_survclassif_disctime
,
mlr_pipeops_trafotask_survregr
## Not run: library(mlr3) library(mlr3pipelines) # simple example pred = PredictionRegr$new(row_ids = 1:10, truth = 1:10, response = 1:10) po = po("trafopred_regrsurv") # assume no censoring new_pred = po$predict(list(pred = pred, task = NULL))[[1]] po$train(list(NULL, NULL)) print(new_pred) # add censoring task_surv = tsk("rats") task_regr = po("trafotask_survregr", method = "omit")$train(list(task_surv, NULL))[[1]] learn = lrn("regr.featureless") pred = learn$train(task_regr)$predict(task_regr) po = po("trafopred_regrsurv") new_pred = po$predict(list(pred = pred, task = task_surv))[[1]] all.equal(new_pred$truth, task_surv$truth()) ## End(Not run)
## Not run: library(mlr3) library(mlr3pipelines) # simple example pred = PredictionRegr$new(row_ids = 1:10, truth = 1:10, response = 1:10) po = po("trafopred_regrsurv") # assume no censoring new_pred = po$predict(list(pred = pred, task = NULL))[[1]] po$train(list(NULL, NULL)) print(new_pred) # add censoring task_surv = tsk("rats") task_regr = po("trafotask_survregr", method = "omit")$train(list(task_surv, NULL))[[1]] learn = lrn("regr.featureless") pred = learn$train(task_regr)$predict(task_regr) po = po("trafopred_regrsurv") new_pred = po$predict(list(pred = pred, task = task_surv))[[1]] all.equal(new_pred$truth, task_surv$truth()) ## End(Not run)
Transform PredictionSurv to PredictionRegr.
Input and output channels are inherited from PipeOpPredTransformer.
The output is the input PredictionSurv transformed to a PredictionRegr. Censoring is ignored.
crank
and lp
predictions are also ignored.
The $state
is a named list
with the $state
elements inherited from PipeOpPredTransformer.
mlr3pipelines::PipeOp
-> mlr3proba::PipeOpTransformer
-> mlr3proba::PipeOpPredTransformer
-> PipeOpPredSurvRegr
new()
Creates a new instance of this R6 class.
PipeOpPredSurvRegr$new(id = "trafopred_survregr")
id
(character(1)
)
Identifier of the resulting object.
clone()
The objects of this class are cloneable with this method.
PipeOpPredSurvRegr$clone(deep = FALSE)
deep
Whether to make a deep clone.
Other PipeOps:
PipeOpPredTransformer
,
PipeOpTaskTransformer
,
PipeOpTransformer
,
mlr_pipeops_survavg
,
mlr_pipeops_trafopred_classifsurv_IPCW
,
mlr_pipeops_trafopred_classifsurv_disctime
,
mlr_pipeops_trafopred_regrsurv
,
mlr_pipeops_trafotask_regrsurv
,
mlr_pipeops_trafotask_survclassif_IPCW
,
mlr_pipeops_trafotask_survclassif_disctime
,
mlr_pipeops_trafotask_survregr
Other Transformation PipeOps:
mlr_pipeops_trafopred_classifsurv_IPCW
,
mlr_pipeops_trafopred_classifsurv_disctime
,
mlr_pipeops_trafopred_regrsurv
,
mlr_pipeops_trafotask_regrsurv
,
mlr_pipeops_trafotask_survclassif_IPCW
,
mlr_pipeops_trafotask_survclassif_disctime
,
mlr_pipeops_trafotask_survregr
## Not run: library(mlr3) library(mlr3pipelines) library(survival) # simple example pred = PredictionSurv$new(row_ids = 1:10, truth = Surv(1:10, rbinom(10, 1, 0.5)), response = 1:10) po = po("trafopred_survregr") new_pred = po$predict(list(pred = pred))[[1]] print(new_pred) ## End(Not run)
## Not run: library(mlr3) library(mlr3pipelines) library(survival) # simple example pred = PredictionSurv$new(row_ids = 1:10, truth = Surv(1:10, rbinom(10, 1, 0.5)), response = 1:10) po = po("trafopred_survregr") new_pred = po$predict(list(pred = pred))[[1]] print(new_pred) ## End(Not run)
Transform TaskRegr to TaskSurv.
Input and output channels are inherited from PipeOpTaskTransformer.
The output is the input TaskRegr transformed to a TaskSurv.
The $state
is a named list
with the $state
elements inherited from PipeOpTaskTransformer.
The parameters are
status :: (numeric(1))
If NULL
then assumed no censoring in the dataset. Otherwise should be a vector of 0/1
s
of same length as the prediction object, where 1
is dead and 0
censored.
mlr3pipelines::PipeOp
-> mlr3proba::PipeOpTransformer
-> mlr3proba::PipeOpTaskTransformer
-> PipeOpTaskRegrSurv
new()
Creates a new instance of this R6 class.
PipeOpTaskRegrSurv$new(id = "trafotask_regrsurv")
id
(character(1)
)
Identifier of the resulting object.
clone()
The objects of this class are cloneable with this method.
PipeOpTaskRegrSurv$clone(deep = FALSE)
deep
Whether to make a deep clone.
Other PipeOps:
PipeOpPredTransformer
,
PipeOpTaskTransformer
,
PipeOpTransformer
,
mlr_pipeops_survavg
,
mlr_pipeops_trafopred_classifsurv_IPCW
,
mlr_pipeops_trafopred_classifsurv_disctime
,
mlr_pipeops_trafopred_regrsurv
,
mlr_pipeops_trafopred_survregr
,
mlr_pipeops_trafotask_survclassif_IPCW
,
mlr_pipeops_trafotask_survclassif_disctime
,
mlr_pipeops_trafotask_survregr
Other Transformation PipeOps:
mlr_pipeops_trafopred_classifsurv_IPCW
,
mlr_pipeops_trafopred_classifsurv_disctime
,
mlr_pipeops_trafopred_regrsurv
,
mlr_pipeops_trafopred_survregr
,
mlr_pipeops_trafotask_survclassif_IPCW
,
mlr_pipeops_trafotask_survclassif_disctime
,
mlr_pipeops_trafotask_survregr
## Not run: library(mlr3) library(mlr3pipelines) task = tsk("boston_housing") po = po("trafotask_regrsurv") # assume no censoring new_task = po$train(list(task_regr = task, task_surv = NULL))[[1]] print(new_task) # add censoring task_surv = tsk("rats") task_regr = po("trafotask_survregr", method = "omit")$train(list(task_surv, NULL))[[1]] print(task_regr) new_task = po$train(list(task_regr = task_regr, task_surv = task_surv))[[1]] new_task$truth() task_surv$truth() ## End(Not run)
## Not run: library(mlr3) library(mlr3pipelines) task = tsk("boston_housing") po = po("trafotask_regrsurv") # assume no censoring new_task = po$train(list(task_regr = task, task_surv = NULL))[[1]] print(new_task) # add censoring task_surv = tsk("rats") task_regr = po("trafotask_survregr", method = "omit")$train(list(task_surv, NULL))[[1]] print(task_regr) new_task = po$train(list(task_regr = task_regr, task_surv = task_surv))[[1]] new_task$truth() task_surv$truth() ## End(Not run)
Transform TaskSurv to TaskClassif by dividing continuous
time into multiple time intervals for each observation.
This transformation creates a new target variable disc_status
that indicates
whether an event occurred within each time interval.
This approach facilitates survival analysis within a classification framework
using discrete time intervals (Tutz et al. 2016).
This PipeOp can be instantiated via the
dictionary mlr3pipelines::mlr_pipeops
or with the associated sugar function mlr3pipelines::po()
:
PipeOpTaskSurvClassifDiscTime$new() mlr_pipeops$get("trafotask_survclassif_disctime") po("trafotask_survclassif_disctime")
PipeOpTaskSurvClassifDiscTime has one input channel named "input", and two output channels, one named "output" and the other "transformed_data".
During training, the "output" is the "input" TaskSurv transformed to a
TaskClassif.
The target column is named "disc_status"
and indicates whether an event occurred
in each time interval.
An additional feature named "tend"
contains the end time point of each interval.
Lastly, the "output" task has a column with the original observation ids,
under the role "original_ids"
.
The "transformed_data" is an empty data.table.
During prediction, the "input" TaskSurv is transformed to the "output"
TaskClassif with "disc_status"
as target and the "tend"
feature included.
The "transformed_data" is a data.table with columns the "disc_status"
target of the "output" task, the "id"
(original observation ids),
"obs_times"
(observed times per "id"
) and "tend"
(end time of each interval).
This "transformed_data" is only meant to be used with the PipeOpPredClassifSurvDiscTime.
The $state
contains information about the cut
parameter used.
The parameters are
cut :: numeric()
Split points, used to partition the data into intervals based on the time
column.
If unspecified, all unique event times will be used.
If cut
is a single integer, it will be interpreted as the number of equidistant
intervals from 0 until the maximum event time.
max_time :: numeric(1)
If cut
is unspecified, this will be the last possible event time.
All event times after max_time
will be administratively censored at max_time.
Needs to be greater than the minimum event time in the given task.
mlr3pipelines::PipeOp
-> PipeOpTaskSurvClassifDiscTime
new()
Creates a new instance of this R6 class.
PipeOpTaskSurvClassifDiscTime$new(id = "trafotask_survclassif_disctime")
id
(character(1)
)
Identifier of the resulting object.
clone()
The objects of this class are cloneable with this method.
PipeOpTaskSurvClassifDiscTime$clone(deep = FALSE)
deep
Whether to make a deep clone.
Tutz, Gerhard, Schmid, Matthias (2016). Modeling Discrete Time-to-Event Data, series Springer Series in Statistics. Springer International Publishing. ISBN 978-3-319-28156-8 978-3-319-28158-2, http://link.springer.com/10.1007/978-3-319-28158-2.
Other PipeOps:
PipeOpPredTransformer
,
PipeOpTaskTransformer
,
PipeOpTransformer
,
mlr_pipeops_survavg
,
mlr_pipeops_trafopred_classifsurv_IPCW
,
mlr_pipeops_trafopred_classifsurv_disctime
,
mlr_pipeops_trafopred_regrsurv
,
mlr_pipeops_trafopred_survregr
,
mlr_pipeops_trafotask_regrsurv
,
mlr_pipeops_trafotask_survclassif_IPCW
,
mlr_pipeops_trafotask_survregr
Other Transformation PipeOps:
mlr_pipeops_trafopred_classifsurv_IPCW
,
mlr_pipeops_trafopred_classifsurv_disctime
,
mlr_pipeops_trafopred_regrsurv
,
mlr_pipeops_trafopred_survregr
,
mlr_pipeops_trafotask_regrsurv
,
mlr_pipeops_trafotask_survclassif_IPCW
,
mlr_pipeops_trafotask_survregr
## Not run: library(mlr3) library(mlr3learners) library(mlr3pipelines) task = tsk("lung") # transform the survival task to a classification task # all unique event times are used as cutpoints po_disc = po("trafotask_survclassif_disctime") task_classif = po_disc$train(list(task))[[1L]] # the end time points of the discrete time intervals unique(task_classif$data(cols = "tend"))[[1L]] # train a classification learner learner = lrn("classif.log_reg", predict_type = "prob") learner$train(task_classif) ## End(Not run)
## Not run: library(mlr3) library(mlr3learners) library(mlr3pipelines) task = tsk("lung") # transform the survival task to a classification task # all unique event times are used as cutpoints po_disc = po("trafotask_survclassif_disctime") task_classif = po_disc$train(list(task))[[1L]] # the end time points of the discrete time intervals unique(task_classif$data(cols = "tend"))[[1L]] # train a classification learner learner = lrn("classif.log_reg", predict_type = "prob") learner$train(task_classif) ## End(Not run)
Transform TaskSurv to TaskClassif using the Inverse Probability of Censoring Weights (IPCW) method by Vock et al. (2016).
Let be the observed times (event or censoring) and
the censoring indicators for each observation
in the training set.
The IPCW technique consists of two steps: first we estimate the censoring
distribution
using the Kaplan-Meier estimator from the
training data. Then we calculate the observation weights given a cutoff time
as:
Observations that are censored prior to are assigned zero weights, i.e.
.
This PipeOp can be instantiated via the
dictionary mlr3pipelines::mlr_pipeops
or with the associated sugar function mlr3pipelines::po()
:
PipeOpTaskSurvClassifIPCW$new() mlr_pipeops$get("trafotask_survclassif_IPCW") po("trafotask_survclassif_IPCW")
PipeOpTaskSurvClassifIPCW has one input channel named "input", and two output channels, one named "output" and the other "data".
Training transforms the "input" TaskSurv to a TaskClassif,
which is the "output".
The target column is named "status"
and indicates whether an event occurred
before the cutoff time (
1
= yes, 0
= no).
The observed times column is removed from the "output" task.
The transformed task has the property "weights"
(the ).
The "data" is
NULL
.
During prediction, the "input" TaskSurv is transformed to the "output"
TaskClassif with "status"
as target (again indicating
if the event occurred before the cutoff time).
The "data" is a data.table containing the observed times
and
censoring indicators/
status
of each subject as well as the corresponding
row_ids
.
This "data" is only meant to be used with the PipeOpPredClassifSurvIPCW.
The parameters are
tau
:: numeric()
Predefined time point for IPCW. Observations with time larger than are censored.
Must be less or equal to the maximum event time.
eps
:: numeric()
Small value to replace censoring probabilities to prevent
infinite weights (a warning is triggered if this happens).
mlr3pipelines::PipeOp
-> PipeOpTaskSurvClassifIPCW
new()
Creates a new instance of this R6 class.
PipeOpTaskSurvClassifIPCW$new(id = "trafotask_survclassif_IPCW")
id
(character(1)
)
Identifier of the resulting object.
clone()
The objects of this class are cloneable with this method.
PipeOpTaskSurvClassifIPCW$clone(deep = FALSE)
deep
Whether to make a deep clone.
Vock, M D, Wolfson, Julian, Bandyopadhyay, Sunayan, Adomavicius, Gediminas, Johnson, E P, Vazquez-Benitez, Gabriela, O'Connor, J P (2016). “Adapting machine learning techniques to censored time-to-event health record data: A general-purpose approach using inverse probability of censoring weighting.” Journal of Biomedical Informatics, 61, 119–131. doi:10.1016/j.jbi.2016.03.009, https://www.sciencedirect.com/science/article/pii/S1532046416000496.
Other PipeOps:
PipeOpPredTransformer
,
PipeOpTaskTransformer
,
PipeOpTransformer
,
mlr_pipeops_survavg
,
mlr_pipeops_trafopred_classifsurv_IPCW
,
mlr_pipeops_trafopred_classifsurv_disctime
,
mlr_pipeops_trafopred_regrsurv
,
mlr_pipeops_trafopred_survregr
,
mlr_pipeops_trafotask_regrsurv
,
mlr_pipeops_trafotask_survclassif_disctime
,
mlr_pipeops_trafotask_survregr
Other Transformation PipeOps:
mlr_pipeops_trafopred_classifsurv_IPCW
,
mlr_pipeops_trafopred_classifsurv_disctime
,
mlr_pipeops_trafopred_regrsurv
,
mlr_pipeops_trafopred_survregr
,
mlr_pipeops_trafotask_regrsurv
,
mlr_pipeops_trafotask_survclassif_disctime
,
mlr_pipeops_trafotask_survregr
## Not run: library(mlr3) library(mlr3learners) library(mlr3pipelines) task = tsk("lung") # split task to train and test subtasks part = partition(task) task_train = task$clone()$filter(part$train) task_test = task$clone()$filter(part$test) # define IPCW pipeop po_ipcw = po("trafotask_survclassif_IPCW", tau = 365) # during training, output is a classification task with weights task_classif_train = po_ipcw$train(list(task_train))[[1]] task_classif_train # during prediction, output is a classification task (no weights) task_classif_test = po_ipcw$predict(list(task_test))[[1]] task_classif_test # train classif learner on the train task with weights learner = lrn("classif.rpart", predict_type = "prob") learner$train(task_classif_train) # predict using the test output task p = learner$predict(task_classif_test) # use classif measures for evaluation p$confusion p$score() p$score(msr("classif.auc")) ## End(Not run)
## Not run: library(mlr3) library(mlr3learners) library(mlr3pipelines) task = tsk("lung") # split task to train and test subtasks part = partition(task) task_train = task$clone()$filter(part$train) task_test = task$clone()$filter(part$test) # define IPCW pipeop po_ipcw = po("trafotask_survclassif_IPCW", tau = 365) # during training, output is a classification task with weights task_classif_train = po_ipcw$train(list(task_train))[[1]] task_classif_train # during prediction, output is a classification task (no weights) task_classif_test = po_ipcw$predict(list(task_test))[[1]] task_classif_test # train classif learner on the train task with weights learner = lrn("classif.rpart", predict_type = "prob") learner$train(task_classif_train) # predict using the test output task p = learner$predict(task_classif_test) # use classif measures for evaluation p$confusion p$score() p$score(msr("classif.auc")) ## End(Not run)
Transform TaskSurv to TaskRegr.
Input and output channels are inherited from PipeOpTaskTransformer.
The output is the input TaskSurv transformed to a TaskRegr.
The $state
is a named list
with the $state
elements
instatus
: Censoring status from input training task.
outstatus
: Censoring status from input prediction task.
The parameters are
method
:: character(1)
Method to use for dealing with censoring. Options are "ipcw"
(Vock et al., 2016): censoring
column is removed and a weights
column is added, weights are inverse estimated survival
probability of the censoring distribution evaluated at survival time;
"mrl"
(Klein and Moeschberger, 2003): survival time of censored
observations is transformed to the observed time plus the mean residual life-time at the moment
of censoring; "bj"
(Buckley and James, 1979): Buckley-James imputation assuming an AFT
model form, calls bujar::bujar; "delete"
: censored observations are deleted from the
data-set - should be used with caution if censoring is informative; "omit"
: the censoring
status column is deleted - again should be used with caution; "reorder"
: selects features and
targets and sets the target in the new task object. Note that "mrl"
and "ipcw"
will perform
worse with Type I censoring.
estimator
:: character(1)
Method for calculating censoring weights or mean residual lifetime in "mrl"
,
current options are: "kaplan"
: unconditional Kaplan-Meier estimator;
"akritas"
: conditional non-parameteric nearest-neighbours estimator;
"cox"
.
alpha
:: numeric(1)
When ipcw
is used, optional hyper-parameter that adds an extra penalty to the weighting for
censored observations. If set to 0
then censored observations are given zero weight and
deleted, weighting only the non-censored observations. A weight for an observation is then
where
is the censoring indicator.
eps
:: numeric(1)
Small value to replace 0
survival probabilities with in IPCW to prevent infinite weights.
lambda
:: numeric(1)
Nearest neighbours parameter for the "akritas"
estimator in the mlr3extralearners package, default 0.5
.
features, target
:: character()
For "reorder"
method, specify which columns become features and targets.
learner cneter, mimpu, iter.bj, max.cycle, mstop, nu
Passed to bujar::bujar.
mlr3pipelines::PipeOp
-> mlr3proba::PipeOpTransformer
-> mlr3proba::PipeOpTaskTransformer
-> PipeOpTaskSurvRegr
new()
Creates a new instance of this R6 class.
PipeOpTaskSurvRegr$new(id = "trafotask_survregr", param_vals = list())
id
(character(1)
)
Identifier of the resulting object.
param_vals
(list()
)
List of hyperparameter settings, overwriting the hyperparameter settings that would
otherwise be set during construction.
clone()
The objects of this class are cloneable with this method.
PipeOpTaskSurvRegr$clone(deep = FALSE)
deep
Whether to make a deep clone.
Buckley, Jonathan, James, Ian (1979). “Linear Regression with Censored Data.” Biometrika, 66(3), 429–436. doi:10.2307/2335161, https://www.jstor.org/stable/2335161.
Klein, P J, Moeschberger, L M (2003). Survival analysis: techniques for censored and truncated data, 2 edition. Springer Science & Business Media. ISBN 0387216456.
Vock, M D, Wolfson, Julian, Bandyopadhyay, Sunayan, Adomavicius, Gediminas, Johnson, E P, Vazquez-Benitez, Gabriela, O'Connor, J P (2016). “Adapting machine learning techniques to censored time-to-event health record data: A general-purpose approach using inverse probability of censoring weighting.” Journal of Biomedical Informatics, 61, 119–131. doi:10.1016/j.jbi.2016.03.009, https://www.sciencedirect.com/science/article/pii/S1532046416000496.
Other PipeOps:
PipeOpPredTransformer
,
PipeOpTaskTransformer
,
PipeOpTransformer
,
mlr_pipeops_survavg
,
mlr_pipeops_trafopred_classifsurv_IPCW
,
mlr_pipeops_trafopred_classifsurv_disctime
,
mlr_pipeops_trafopred_regrsurv
,
mlr_pipeops_trafopred_survregr
,
mlr_pipeops_trafotask_regrsurv
,
mlr_pipeops_trafotask_survclassif_IPCW
,
mlr_pipeops_trafotask_survclassif_disctime
Other Transformation PipeOps:
mlr_pipeops_trafopred_classifsurv_IPCW
,
mlr_pipeops_trafopred_classifsurv_disctime
,
mlr_pipeops_trafopred_regrsurv
,
mlr_pipeops_trafopred_survregr
,
mlr_pipeops_trafotask_regrsurv
,
mlr_pipeops_trafotask_survclassif_IPCW
,
mlr_pipeops_trafotask_survclassif_disctime
## Not run: library(mlr3) library(mlr3pipelines) # these methods are generally only successful if censoring is not too high # create survival task by undersampling task = tsk("rats")$filter( c(which(tsk("rats")$truth()[, 2] == 1), sample(which(tsk("rats")$truth()[, 2] == 0), 42)) ) # deletion po = po("trafotask_survregr", method = "delete") po$train(list(task, NULL))[[1]] # 42 deleted # omission po = po("trafotask_survregr", method = "omit") po$train(list(task, NULL))[[1]] if (requireNamespace("mlr3extralearners", quietly = TRUE)) { # ipcw with Akritas po = po("trafotask_survregr", method = "ipcw", estimator = "akritas", lambda = 0.4, alpha = 0) new_task = po$train(list(task, NULL))[[1]] print(new_task) new_task$weights } # mrl with Kaplan-Meier po = po("trafotask_survregr", method = "mrl") new_task = po$train(list(task, NULL))[[1]] data.frame(new = new_task$truth(), old = task$truth()) # Buckley-James imputation if (requireNamespace("bujar", quietly = TRUE)) { po = po("trafotask_survregr", method = "bj") new_task = po$train(list(task, NULL))[[1]] data.frame(new = new_task$truth(), old = task$truth()) } # reorder - in practice this will be only be used in a few graphs po = po("trafotask_survregr", method = "reorder", features = c("sex", "rx", "time", "status"), target = "litter") new_task = po$train(list(task, NULL))[[1]] print(new_task) # reorder using another task for feature names po = po("trafotask_survregr", method = "reorder", target = "litter") new_task = po$train(list(task, task))[[1]] print(new_task) ## End(Not run)
## Not run: library(mlr3) library(mlr3pipelines) # these methods are generally only successful if censoring is not too high # create survival task by undersampling task = tsk("rats")$filter( c(which(tsk("rats")$truth()[, 2] == 1), sample(which(tsk("rats")$truth()[, 2] == 0), 42)) ) # deletion po = po("trafotask_survregr", method = "delete") po$train(list(task, NULL))[[1]] # 42 deleted # omission po = po("trafotask_survregr", method = "omit") po$train(list(task, NULL))[[1]] if (requireNamespace("mlr3extralearners", quietly = TRUE)) { # ipcw with Akritas po = po("trafotask_survregr", method = "ipcw", estimator = "akritas", lambda = 0.4, alpha = 0) new_task = po$train(list(task, NULL))[[1]] print(new_task) new_task$weights } # mrl with Kaplan-Meier po = po("trafotask_survregr", method = "mrl") new_task = po$train(list(task, NULL))[[1]] data.frame(new = new_task$truth(), old = task$truth()) # Buckley-James imputation if (requireNamespace("bujar", quietly = TRUE)) { po = po("trafotask_survregr", method = "bj") new_task = po$train(list(task, NULL))[[1]] data.frame(new = new_task$truth(), old = task$truth()) } # reorder - in practice this will be only be used in a few graphs po = po("trafotask_survregr", method = "reorder", features = c("sex", "rx", "time", "status"), target = "litter") new_task = po$train(list(task, NULL))[[1]] print(new_task) # reorder using another task for feature names po = po("trafotask_survregr", method = "reorder", target = "litter") new_task = po$train(list(task, task))[[1]] print(new_task) ## End(Not run)
A mlr3::TaskGenerator calling coxed::sim.survdata()
.
This generator creates a survival dataset using coxed, and exposes
some parameters from the sim.survdata()
function.
We don't include the parameters X
(user-specified variables), covariate
,
low
, high
, compare
, beta
and hazard.fun
for this generator.
The latter means that no user-specified hazard function can be used and the
generated datasets always use the flexible-hazard method from the package.
This TaskGenerator can be instantiated via the dictionary mlr_task_generators or with the associated sugar function tgen()
:
mlr_task_generators$get("coxed") tgen("coxed")
Id | Type | Default | Levels | Range |
T | numeric | 100 | |
|
type | character | none | none, tvc, tvbeta | - |
knots | integer | 8 | |
|
spline | logical | TRUE | TRUE, FALSE | - |
xvars | integer | 3 | |
|
mu | untyped | 0 | - | |
sd | untyped | 0.5 | - | |
censor | numeric | 0.1 | |
|
censor.cond | logical | FALSE | TRUE, FALSE | - |
mlr3::TaskGenerator
-> TaskGeneratorCoxed
new()
Creates a new instance of this R6 class.
TaskGeneratorCoxed$new()
help()
Opens the corresponding help page referenced by field $man
.
TaskGeneratorCoxed$help()
clone()
The objects of this class are cloneable with this method.
TaskGeneratorCoxed$clone(deep = FALSE)
deep
Whether to make a deep clone.
Harden, J. J, Kropko, Jonathan (2019). “Simulating Duration Data for the Cox Model.” Political Science Research and Methods, 7(4), 921–928. doi:10.1017/PSRM.2018.19.
as.data.table(mlr_task_generators)
for a table of available TaskGenerators in the running session
Other TaskGenerator:
mlr_task_generators_simdens
,
mlr_task_generators_simsurv
library(mlr3) # time horizon = 365 days, censoring proportion = 60%, 6 covariates normally # distributed with mean = 1 and sd = 2, independent censoring, no time-varying # effects gen = tgen("coxed", T = 365, type = "none", censor = 0.6, xvars = 6, mu = 1, sd = 2, censor.cond = FALSE) gen$generate(50) # same as above, but with time-varying coefficients (counting process format) gen$param_set$set_values(type = "tvc") gen$generate(50)
library(mlr3) # time horizon = 365 days, censoring proportion = 60%, 6 covariates normally # distributed with mean = 1 and sd = 2, independent censoring, no time-varying # effects gen = tgen("coxed", T = 365, type = "none", censor = 0.6, xvars = 6, mu = 1, sd = 2, censor.cond = FALSE) gen$generate(50) # same as above, but with time-varying coefficients (counting process format) gen$param_set$set_values(type = "tvc") gen$generate(50)
A mlr3::TaskGenerator calling distr6::distrSimulate()
.
See distr6::distrSimulate()
for an explanation of the hyperparameters.
See distr6::listDistributions()
for the names of the available distributions.
This TaskGenerator can be instantiated via the dictionary mlr_task_generators or with the associated sugar function tgen()
:
mlr_task_generators$get("simdens") tgen("simdens")
Id | Type | Default | Levels |
distribution | character | Normal | Arcsine, Arrdist, Bernoulli, Beta, BetaNoncentral, Binomial, Categorical, Cauchy, ChiSquared, ChiSquaredNoncentral, ... |
pars | untyped | - | |
mlr3::TaskGenerator
-> TaskGeneratorSimdens
new()
Creates a new instance of this R6 class.
TaskGeneratorSimdens$new()
help()
Opens the corresponding help page referenced by field $man
.
TaskGeneratorSimdens$help()
clone()
The objects of this class are cloneable with this method.
TaskGeneratorSimdens$clone(deep = FALSE)
deep
Whether to make a deep clone.
as.data.table(mlr_task_generators)
for a table of available TaskGenerators in the running session
Other TaskGenerator:
mlr_task_generators_coxed
,
mlr_task_generators_simsurv
# generate 20 samples from a standard Normal distribution dens_gen = tgen("simdens") dens_gen$param_set task = dens_gen$generate(20) head(task) # generate 50 samples from a Binomial distribution with specific parameters dens_gen = tgen("simdens", distribution = "Bernoulli", pars = list(prob = 0.8)) task = dens_gen$generate(50) task$data()[["x"]]
# generate 20 samples from a standard Normal distribution dens_gen = tgen("simdens") dens_gen$param_set task = dens_gen$generate(20) head(task) # generate 50 samples from a Binomial distribution with specific parameters dens_gen = tgen("simdens", distribution = "Bernoulli", pars = list(prob = 0.8)) task = dens_gen$generate(50) task$data()[["x"]]
A mlr3::TaskGenerator calling simsurv::simsurv()
from package simsurv.
This generator currently only exposes a small subset of the flexibility of simsurv, and just creates a small dataset with the following numerical covariates:
treatment
: Bernoulli distributed with hazard ratio 0.5
.
height
: Normally distributed with hazard ratio 1
.
weight
: normally distributed with hazard ratio 1
.
See simsurv::simsurv()
for an explanation of the hyperparameters.
Initial values for hyperparameters are lambdas
= 0.1, gammas
= 1.5 and maxt
= 5.
The last one, by default generates samples which are administratively censored at , so increase this value if you want to change this.
This TaskGenerator can be instantiated via the dictionary mlr_task_generators or with the associated sugar function tgen()
:
mlr_task_generators$get("simsurv") tgen("simsurv")
Id | Type | Default | Levels | Range |
dist | character | weibull | weibull, exponential, gompertz | - |
lambdas | numeric | - | |
|
gammas | numeric | - | |
|
maxt | numeric | - | |
|
mlr3::TaskGenerator
-> TaskGeneratorSimsurv
new()
Creates a new instance of this R6 class.
TaskGeneratorSimsurv$new()
help()
Opens the corresponding help page referenced by field $man
.
TaskGeneratorSimsurv$help()
clone()
The objects of this class are cloneable with this method.
TaskGeneratorSimsurv$clone(deep = FALSE)
deep
Whether to make a deep clone.
Brilleman, L. S, Wolfe, Rory, Moreno-Betancur, Margarita, Crowther, J. M (2021). “Simulating Survival Data Using the simsurv R Package.” Journal of Statistical Software, 97(3), 1–27. doi:10.18637/JSS.V097.I03.
as.data.table(mlr_task_generators)
for a table of available TaskGenerators in the running session
Other TaskGenerator:
mlr_task_generators_coxed
,
mlr_task_generators_simdens
# generate 20 samples with Weibull survival distribution gen = tgen("simsurv") task = gen$generate(20) head(task) # generate 100 samples with exponential survival distribution and tau = 40 gen = tgen("simsurv", dist = "exponential", gammas = NULL, maxt = 40) task = gen$generate(100) head(task)
# generate 20 samples with Weibull survival distribution gen = tgen("simsurv") task = gen$generate(20) head(task) # generate 100 samples with exponential survival distribution and tau = 40 gen = tgen("simsurv", dist = "exponential", gammas = NULL, maxt = 40) task = gen$generate(100) head(task)
A survival task for the actg data set.
R6::R6Class inheriting from TaskSurv.
This Task can be instantiated via the dictionary mlr_tasks or with the associated sugar function tsk()
:
mlr_tasks$get("actg") tsk("actg")
Task type: “surv”
Dimensions: 1151x13
Properties: -
Has Missings: FALSE
Target: “time”, “status”
Features: “age”, “cd4”, “hemophil”, “ivdrug”, “karnof”, “priorzdv”, “raceth”, “sexF”, “strat2”, “tx”, “txgrp”
Column sex
has been renamed to sexF
and censor
has been renamed to status
.
Columns id
, time_d
, and censor_d
have been removed so target is time
to AIDS diagnosis (in days).
Chapter in the mlr3book: https://mlr3book.mlr-org.com/chapters/chapter2/data_and_basic_modeling.html
as.data.table(mlr_tasks)
for a table of available Tasks in the running session
Other Task:
TaskDens
,
TaskSurv
,
mlr_tasks_faithful
,
mlr_tasks_gbcs
,
mlr_tasks_gbsg
,
mlr_tasks_grace
,
mlr_tasks_lung
,
mlr_tasks_mgus
,
mlr_tasks_pbc
,
mlr_tasks_precip
,
mlr_tasks_rats
,
mlr_tasks_unemployment
,
mlr_tasks_veteran
,
mlr_tasks_whas
A density task for the faithful data set.
R6::R6Class inheriting from TaskDens.
This Task can be instantiated via the dictionary mlr_tasks or with the associated sugar function tsk()
:
mlr_tasks$get("faithful") tsk("faithful")
Task type: “dens”
Dimensions: 272x1
Properties: -
Has Missings: FALSE
Target: -
Features: “eruptions”
Only the eruptions
column is kept in this task.
Chapter in the mlr3book: https://mlr3book.mlr-org.com/chapters/chapter2/data_and_basic_modeling.html
as.data.table(mlr_tasks)
for a table of available Tasks in the running session
Other Task:
TaskDens
,
TaskSurv
,
mlr_tasks_actg
,
mlr_tasks_gbcs
,
mlr_tasks_gbsg
,
mlr_tasks_grace
,
mlr_tasks_lung
,
mlr_tasks_mgus
,
mlr_tasks_pbc
,
mlr_tasks_precip
,
mlr_tasks_rats
,
mlr_tasks_unemployment
,
mlr_tasks_veteran
,
mlr_tasks_whas
A survival task for the gbcs data set.
R6::R6Class inheriting from TaskSurv.
This Task can be instantiated via the dictionary mlr_tasks or with the associated sugar function tsk()
:
mlr_tasks$get("gbcs") tsk("gbcs")
Task type: “surv”
Dimensions: 686x10
Properties: -
Has Missings: FALSE
Target: “time”, “status”
Features: “age”, “estrg_recp”, “grade”, “hormone”, “menopause”, “nodes”, “prog_recp”, “size”
Column id
and all date columns have been removed, as well as rectime
and censrec
.
Target columns (survtime
, censdead
) have been renamed to (time
, status
).
Chapter in the mlr3book: https://mlr3book.mlr-org.com/chapters/chapter2/data_and_basic_modeling.html
as.data.table(mlr_tasks)
for a table of available Tasks in the running session
Other Task:
TaskDens
,
TaskSurv
,
mlr_tasks_actg
,
mlr_tasks_faithful
,
mlr_tasks_gbsg
,
mlr_tasks_grace
,
mlr_tasks_lung
,
mlr_tasks_mgus
,
mlr_tasks_pbc
,
mlr_tasks_precip
,
mlr_tasks_rats
,
mlr_tasks_unemployment
,
mlr_tasks_veteran
,
mlr_tasks_whas
A survival task for the gbsg data set.
R6::R6Class inheriting from TaskSurv.
This Task can be instantiated via the dictionary mlr_tasks or with the associated sugar function tsk()
:
mlr_tasks$get("gbsg") tsk("gbsg")
Task type: “surv”
Dimensions: 686x10
Properties: -
Has Missings: FALSE
Target: “time”, “status”
Features: “age”, “er”, “grade”, “hormon”, “meno”, “nodes”, “pgr”, “size”
Removed column pid
.
Column meno
has been converted to factor
and 0/1 values have been
replaced with premenopausal
and postmenopausal
respectively.
Column hormon
has been converted to factor
and 0/1 values have been
replaced with no
and yes
respectively.
Column grade
has been converted to factor
.
Renamed target column rfstime
to time
.
Chapter in the mlr3book: https://mlr3book.mlr-org.com/chapters/chapter2/data_and_basic_modeling.html
as.data.table(mlr_tasks)
for a table of available Tasks in the running session
Other Task:
TaskDens
,
TaskSurv
,
mlr_tasks_actg
,
mlr_tasks_faithful
,
mlr_tasks_gbcs
,
mlr_tasks_grace
,
mlr_tasks_lung
,
mlr_tasks_mgus
,
mlr_tasks_pbc
,
mlr_tasks_precip
,
mlr_tasks_rats
,
mlr_tasks_unemployment
,
mlr_tasks_veteran
,
mlr_tasks_whas
A survival task for the grace data set.
R6::R6Class inheriting from TaskSurv.
This Task can be instantiated via the dictionary mlr_tasks or with the associated sugar function tsk()
:
mlr_tasks$get("grace") tsk("grace")
Task type: “surv”
Dimensions: 1000x8
Properties: -
Has Missings: FALSE
Target: “time”, “status”
Features: “age”, “los”, “revasc”, “revascdays”, “stchange”, “sysbp”
Column id
is removed.
Target columns (days
, death
) have been renamed to (time
, status
).
Chapter in the mlr3book: https://mlr3book.mlr-org.com/chapters/chapter2/data_and_basic_modeling.html
as.data.table(mlr_tasks)
for a table of available Tasks in the running session
Other Task:
TaskDens
,
TaskSurv
,
mlr_tasks_actg
,
mlr_tasks_faithful
,
mlr_tasks_gbcs
,
mlr_tasks_gbsg
,
mlr_tasks_lung
,
mlr_tasks_mgus
,
mlr_tasks_pbc
,
mlr_tasks_precip
,
mlr_tasks_rats
,
mlr_tasks_unemployment
,
mlr_tasks_veteran
,
mlr_tasks_whas
A survival task for the lung data set.
R6::R6Class inheriting from TaskSurv.
This Task can be instantiated via the dictionary mlr_tasks or with the associated sugar function tsk()
:
mlr_tasks$get("lung") tsk("lung")
Task type: “surv”
Dimensions: 168x9
Properties: -
Has Missings: FALSE
Target: “time”, “status”
Features: “age”, “meal.cal”, “pat.karno”, “ph.ecog”, “ph.karno”, “sex”, “wt.loss”
Column inst
has been removed.
Column sex
has been converted to a factor
, all others have been
converted to integer
.
Kept only complete cases (no missing values).
Chapter in the mlr3book: https://mlr3book.mlr-org.com/chapters/chapter2/data_and_basic_modeling.html
as.data.table(mlr_tasks)
for a table of available Tasks in the running session
Other Task:
TaskDens
,
TaskSurv
,
mlr_tasks_actg
,
mlr_tasks_faithful
,
mlr_tasks_gbcs
,
mlr_tasks_gbsg
,
mlr_tasks_grace
,
mlr_tasks_mgus
,
mlr_tasks_pbc
,
mlr_tasks_precip
,
mlr_tasks_rats
,
mlr_tasks_unemployment
,
mlr_tasks_veteran
,
mlr_tasks_whas
A survival task for the mgus data set.
R6::R6Class inheriting from TaskSurv.
This Task can be instantiated via the dictionary mlr_tasks or with the associated sugar function tsk()
:
mlr_tasks$get("mgus") tsk("mgus")
Task type: “surv”
Dimensions: 176x9
Properties: -
Has Missings: FALSE
Target: “time”, “status”
Features: “age”, “alb”, “creat”, “dxyr”, “hgb”, “mspike”, “sex”
Removed columns id
, pcdx
and pctime
.
Renamed target columns from (fultime
, death
) to (time
, status
).
Kept only complete cases (no missing values).
Chapter in the mlr3book: https://mlr3book.mlr-org.com/chapters/chapter2/data_and_basic_modeling.html
as.data.table(mlr_tasks)
for a table of available Tasks in the running session
Other Task:
TaskDens
,
TaskSurv
,
mlr_tasks_actg
,
mlr_tasks_faithful
,
mlr_tasks_gbcs
,
mlr_tasks_gbsg
,
mlr_tasks_grace
,
mlr_tasks_lung
,
mlr_tasks_pbc
,
mlr_tasks_precip
,
mlr_tasks_rats
,
mlr_tasks_unemployment
,
mlr_tasks_veteran
,
mlr_tasks_whas
A survival task for the pbc data set.
R6::R6Class inheriting from TaskSurv.
This Task can be instantiated via the dictionary mlr_tasks or with the associated sugar function tsk()
:
mlr_tasks$get("pbc") tsk("pbc")
Task type: “surv”
Dimensions: 276x19
Properties: -
Has Missings: FALSE
Target: “time”, “status”
Features: “age”, “albumin”, “alk.phos”, “ascites”, “ast”, “bili”, “chol”, “copper”, “edema”, “hepato”, “platelet”, “protime”, “sex”, “spiders”, “stage”, “trig”, “trt”
Removed column id
.
Kept only complete cases (no missing values).
Column age
has been converted to integer
.
Columns trt
, stage
, hepato
, edema
and ascites
have been converted
to factor
s.
Column trt
has levels Dpenicillmain
and placebo
instead of 1 and 2.
Column status
has 1 for death and 0 for censored or transplant.
Chapter in the mlr3book: https://mlr3book.mlr-org.com/chapters/chapter2/data_and_basic_modeling.html
as.data.table(mlr_tasks)
for a table of available Tasks in the running session
Other Task:
TaskDens
,
TaskSurv
,
mlr_tasks_actg
,
mlr_tasks_faithful
,
mlr_tasks_gbcs
,
mlr_tasks_gbsg
,
mlr_tasks_grace
,
mlr_tasks_lung
,
mlr_tasks_mgus
,
mlr_tasks_precip
,
mlr_tasks_rats
,
mlr_tasks_unemployment
,
mlr_tasks_veteran
,
mlr_tasks_whas
A density task for the precip data set.
R6::R6Class inheriting from TaskDens.
This Task can be instantiated via the dictionary mlr_tasks or with the associated sugar function tsk()
:
mlr_tasks$get("precip") tsk("precip")
Task type: “dens”
Dimensions: 70x1
Properties: -
Has Missings: FALSE
Target: -
Features: “precip”
Only the precip
column is kept in this task.
Chapter in the mlr3book: https://mlr3book.mlr-org.com/chapters/chapter2/data_and_basic_modeling.html
as.data.table(mlr_tasks)
for a table of available Tasks in the running session
Other Task:
TaskDens
,
TaskSurv
,
mlr_tasks_actg
,
mlr_tasks_faithful
,
mlr_tasks_gbcs
,
mlr_tasks_gbsg
,
mlr_tasks_grace
,
mlr_tasks_lung
,
mlr_tasks_mgus
,
mlr_tasks_pbc
,
mlr_tasks_rats
,
mlr_tasks_unemployment
,
mlr_tasks_veteran
,
mlr_tasks_whas
A survival task for the rats data set.
R6::R6Class inheriting from TaskSurv.
This Task can be instantiated via the dictionary mlr_tasks or with the associated sugar function tsk()
:
mlr_tasks$get("rats") tsk("rats")
Task type: “surv”
Dimensions: 300x5
Properties: -
Has Missings: FALSE
Target: “time”, “status”
Features: “litter”, “rx”, “sex”
Column sex
has been converted to a factor
, all others have been
converted to integer
.
Chapter in the mlr3book: https://mlr3book.mlr-org.com/chapters/chapter2/data_and_basic_modeling.html
as.data.table(mlr_tasks)
for a table of available Tasks in the running session
Other Task:
TaskDens
,
TaskSurv
,
mlr_tasks_actg
,
mlr_tasks_faithful
,
mlr_tasks_gbcs
,
mlr_tasks_gbsg
,
mlr_tasks_grace
,
mlr_tasks_lung
,
mlr_tasks_mgus
,
mlr_tasks_pbc
,
mlr_tasks_precip
,
mlr_tasks_unemployment
,
mlr_tasks_veteran
,
mlr_tasks_whas
A survival task for the Ecdat::UnempDur data set.
R6::R6Class inheriting from TaskSurv.
This Task can be instantiated via the dictionary mlr_tasks or with the associated sugar function tsk()
:
mlr_tasks$get("unemployment") tsk("unemployment")
Task type: “surv”
Dimensions: 3343x6
Properties: -
Has Missings: FALSE
Target: “time”, “status”
Features: “age”, “logwage”, “tenure”, “ui”
Only the columns spell
, censor1
, age
, logwage
, tenure
, ui
are
kept in this task.
Renamed target columns from (spell
, censor1
) to (time
, status
), so
outcome is the duration until re-employment in a full-time job.
Chapter in the mlr3book: https://mlr3book.mlr-org.com/chapters/chapter2/data_and_basic_modeling.html
as.data.table(mlr_tasks)
for a table of available Tasks in the running session
Other Task:
TaskDens
,
TaskSurv
,
mlr_tasks_actg
,
mlr_tasks_faithful
,
mlr_tasks_gbcs
,
mlr_tasks_gbsg
,
mlr_tasks_grace
,
mlr_tasks_lung
,
mlr_tasks_mgus
,
mlr_tasks_pbc
,
mlr_tasks_precip
,
mlr_tasks_rats
,
mlr_tasks_veteran
,
mlr_tasks_whas
A survival task for the veteran data set.
R6::R6Class inheriting from TaskSurv.
This Task can be instantiated via the dictionary mlr_tasks or with the associated sugar function tsk()
:
mlr_tasks$get("veteran") tsk("veteran")
Task type: “surv”
Dimensions: 137x8
Properties: -
Has Missings: FALSE
Target: “time”, “status”
Features: “age”, “celltype”, “diagtime”, “karno”, “prior”, “trt”
Columns age
, time
, status
, diagtime
and karno
have been converted
to integer
.
Columns trt
, prior
have been converted to factor
s. Prior therapy
values are no
/yes
instead of 0/10.
Chapter in the mlr3book: https://mlr3book.mlr-org.com/chapters/chapter2/data_and_basic_modeling.html
as.data.table(mlr_tasks)
for a table of available Tasks in the running session
Other Task:
TaskDens
,
TaskSurv
,
mlr_tasks_actg
,
mlr_tasks_faithful
,
mlr_tasks_gbcs
,
mlr_tasks_gbsg
,
mlr_tasks_grace
,
mlr_tasks_lung
,
mlr_tasks_mgus
,
mlr_tasks_pbc
,
mlr_tasks_precip
,
mlr_tasks_rats
,
mlr_tasks_unemployment
,
mlr_tasks_whas
A survival task for the whas data set.
R6::R6Class inheriting from TaskSurv.
This Task can be instantiated via the dictionary mlr_tasks or with the associated sugar function tsk()
:
mlr_tasks$get("whas") tsk("whas")
Task type: “surv”
Dimensions: 481x11
Properties: -
Has Missings: FALSE
Target: “time”, “status”
Features: “age”, “chf”, “cpk”, “lenstay”, “miord”, “mitype”, “sexF”, “sho”, “year”
Columns id
, yrgrp
, and dstat
are removed.
Column sex
is renamed to sexF
, lenfol
to time
, and fstat
to status
.
Target is total follow-up time from hospital admission.
Chapter in the mlr3book: https://mlr3book.mlr-org.com/chapters/chapter2/data_and_basic_modeling.html
as.data.table(mlr_tasks)
for a table of available Tasks in the running session
Other Task:
TaskDens
,
TaskSurv
,
mlr_tasks_actg
,
mlr_tasks_faithful
,
mlr_tasks_gbcs
,
mlr_tasks_gbsg
,
mlr_tasks_grace
,
mlr_tasks_lung
,
mlr_tasks_mgus
,
mlr_tasks_pbc
,
mlr_tasks_precip
,
mlr_tasks_rats
,
mlr_tasks_unemployment
,
mlr_tasks_veteran
Methods to plot prediction error curves (pecs) for either a PredictionSurv object or a list of trained LearnerSurvs.
pecs(x, measure = c("graf", "logloss"), times, n, eps = NULL, ...) ## S3 method for class 'list' pecs( x, measure = c("graf", "logloss"), times, n, eps = NULL, task = NULL, row_ids = NULL, newdata = NULL, train_task = NULL, train_set = NULL, proper = TRUE, ... ) ## S3 method for class 'PredictionSurv' pecs( x, measure = c("graf", "logloss"), times, n, eps = 1e-15, train_task = NULL, train_set = NULL, proper = TRUE, ... )
pecs(x, measure = c("graf", "logloss"), times, n, eps = NULL, ...) ## S3 method for class 'list' pecs( x, measure = c("graf", "logloss"), times, n, eps = NULL, task = NULL, row_ids = NULL, newdata = NULL, train_task = NULL, train_set = NULL, proper = TRUE, ... ) ## S3 method for class 'PredictionSurv' pecs( x, measure = c("graf", "logloss"), times, n, eps = 1e-15, train_task = NULL, train_set = NULL, proper = TRUE, ... )
x |
(PredictionSurv or |
measure |
( |
times |
( |
n |
( |
eps |
( |
... |
Additional arguments. |
task |
(TaskSurv) |
row_ids |
( |
newdata |
( |
train_task |
(TaskSurv) |
train_set |
( |
proper |
( |
If times
and n
are missing then measure
is evaluated over all observed time-points
from the PredictionSurv or TaskSurv object. If a range is provided for times
without n
,
then all time-points between the range are returned.
## Not run: #' library(mlr3) task = tsk("rats") # Prediction Error Curves for prediction object learn = lrn("surv.coxph") p = learn$train(task)$predict(task) pecs(p) pecs(p, measure = "logloss", times = c(20, 40, 60, 80)) + ggplot2::geom_point() + ggplot2::ggtitle("Logloss Prediction Error Curve for Cox PH") # Access underlying data x = pecs(p) x$data # Prediction Error Curves for fitted learners learns = lrns(c("surv.kaplan", "surv.coxph")) lapply(learns, function(x) x$train(task)) pecs(learns, task = task, measure = "logloss", times = c(20, 90), n = 10) ## End(Not run)
## Not run: #' library(mlr3) task = tsk("rats") # Prediction Error Curves for prediction object learn = lrn("surv.coxph") p = learn$train(task)$predict(task) pecs(p) pecs(p, measure = "logloss", times = c(20, 40, 60, 80)) + ggplot2::geom_point() + ggplot2::ggtitle("Logloss Prediction Error Curve for Cox PH") # Access underlying data x = pecs(p) x$data # Prediction Error Curves for fitted learners learns = lrns(c("surv.kaplan", "surv.coxph")) lapply(learns, function(x) x$train(task)) pecs(learns, task = task, measure = "logloss", times = c(20, 90), n = 10) ## End(Not run)
Parent class for PipeOps that transform Prediction objects to different types.
PipeOpPredTransformer
has one input and output channel named "input"
and "output"
.
In training and testing these expect and produce mlr3::Prediction objects with the type
depending on the transformers.
The $state
is a named list
with the $state
elements
inpredtypes
: Predict types in the input prediction object during training.
outpredtypes
: Predict types in the input prediction object during prediction, checked
against inpredtypes
.
Classes inheriting from PipeOpPredTransformer
transform Prediction
objects from one class (e.g. regr, classif) to another.
mlr3pipelines::PipeOp
-> mlr3proba::PipeOpTransformer
-> PipeOpPredTransformer
new()
Creates a new instance of this R6 class.
PipeOpPredTransformer$new( id, param_set = ps(), param_vals = list(), packages = character(0), input = data.table(), output = data.table() )
id
(character(1)
)
Identifier of the resulting object.
param_set
(paradox::ParamSet)
Set of hyperparameters.
param_vals
(list()
)
List of hyperparameter settings, overwriting the hyperparameter settings that would
otherwise be set during construction.
packages
(character()
)
Set of required packages.
A warning is signaled by the constructor if at least one of the packages is not installed,
but loaded (not attached) later on-demand via requireNamespace()
.
input
data.table::data.tabledata.table
with columns name
(character
), train
(character
), predict
(character
).
Sets the $input
slot, see PipeOp.
output
data.table::data.tabledata.table
with columns name
(character
), train
(character
), predict
(character
).
Sets the $output
slot, see PipeOp.
clone()
The objects of this class are cloneable with this method.
PipeOpPredTransformer$clone(deep = FALSE)
deep
Whether to make a deep clone.
Other PipeOps:
PipeOpTaskTransformer
,
PipeOpTransformer
,
mlr_pipeops_survavg
,
mlr_pipeops_trafopred_classifsurv_IPCW
,
mlr_pipeops_trafopred_classifsurv_disctime
,
mlr_pipeops_trafopred_regrsurv
,
mlr_pipeops_trafopred_survregr
,
mlr_pipeops_trafotask_regrsurv
,
mlr_pipeops_trafotask_survclassif_IPCW
,
mlr_pipeops_trafotask_survclassif_disctime
,
mlr_pipeops_trafotask_survregr
Other Transformers:
PipeOpTaskTransformer
,
PipeOpTransformer
Parent class for PipeOps that transform task objects to different types.
PipeOpTaskTransformer
has one input and output channel named "input"
and "output"
.
In training and testing these expect and produce mlr3::Task objects with the type depending on
the transformers.
The $state
is left empty (list()
).
The commonality of methods using PipeOpTaskTransformer
is that they take a mlr3::Task of
one class and transform it to another class. This usually involves transformation of the data,
which can be controlled via parameters.
mlr3pipelines::PipeOp
-> mlr3proba::PipeOpTransformer
-> PipeOpTaskTransformer
new()
Creates a new instance of this R6 class.
PipeOpTaskTransformer$new( id, param_set = ps(), param_vals = list(), packages = character(0), input, output )
id
(character(1)
)
Identifier of the resulting object.
param_set
(paradox::ParamSet)
Set of hyperparameters.
param_vals
(list()
)
List of hyperparameter settings, overwriting the hyperparameter settings that would
otherwise be set during construction.
packages
(character()
)
Set of required packages.
A warning is signaled by the constructor if at least one of the packages is not installed,
but loaded (not attached) later on-demand via requireNamespace()
.
input
data.table::data.tabledata.table
with columns name
(character
), train
(character
), predict
(character
).
Sets the $input
slot, see PipeOp.
output
data.table::data.tabledata.table
with columns name
(character
), train
(character
), predict
(character
).
Sets the $output
slot, see PipeOp.
clone()
The objects of this class are cloneable with this method.
PipeOpTaskTransformer$clone(deep = FALSE)
deep
Whether to make a deep clone.
Other PipeOps:
PipeOpPredTransformer
,
PipeOpTransformer
,
mlr_pipeops_survavg
,
mlr_pipeops_trafopred_classifsurv_IPCW
,
mlr_pipeops_trafopred_classifsurv_disctime
,
mlr_pipeops_trafopred_regrsurv
,
mlr_pipeops_trafopred_survregr
,
mlr_pipeops_trafotask_regrsurv
,
mlr_pipeops_trafotask_survclassif_IPCW
,
mlr_pipeops_trafotask_survclassif_disctime
,
mlr_pipeops_trafotask_survregr
Other Transformers:
PipeOpPredTransformer
,
PipeOpTransformer
Parent class for PipeOps that transform Task and Prediction objects to different types.
Determined by child classes.
The $state
is left empty (list()
).
The commonality of methods using PipeOpTransformer is that they take a Task or Prediction of one type (e.g. regr or classif) and transform it to another type.
mlr3pipelines::PipeOp
-> PipeOpTransformer
new()
Creates a new instance of this R6 class.
PipeOpTransformer$new( id, param_set = ps(), param_vals = list(), packages = character(), input = data.table(), output = data.table() )
id
(character(1)
)
Identifier of the resulting object.
param_set
(paradox::ParamSet)
Set of hyperparameters.
param_vals
(list()
)
List of hyperparameter settings, overwriting the hyperparameter settings that would
otherwise be set during construction.
packages
(character()
)
Set of required packages.
A warning is signaled by the constructor if at least one of the packages is not installed,
but loaded (not attached) later on-demand via requireNamespace()
.
input
data.table::data.tabledata.table
with columns name
(character
), train
(character
), predict
(character
).
Sets the $input
slot, see PipeOp.
output
data.table::data.tabledata.table
with columns name
(character
), train
(character
), predict
(character
).
Sets the $output
slot, see PipeOp.
clone()
The objects of this class are cloneable with this method.
PipeOpTransformer$clone(deep = FALSE)
deep
Whether to make a deep clone.
Other PipeOps:
PipeOpPredTransformer
,
PipeOpTaskTransformer
,
mlr_pipeops_survavg
,
mlr_pipeops_trafopred_classifsurv_IPCW
,
mlr_pipeops_trafopred_classifsurv_disctime
,
mlr_pipeops_trafopred_regrsurv
,
mlr_pipeops_trafopred_survregr
,
mlr_pipeops_trafotask_regrsurv
,
mlr_pipeops_trafotask_survclassif_IPCW
,
mlr_pipeops_trafotask_survclassif_disctime
,
mlr_pipeops_trafotask_survregr
Other Transformers:
PipeOpPredTransformer
,
PipeOpTaskTransformer
Plots probability density functions from n
predicted probability
distributions.
plot_probregr( p, n, type = c("point", "line", "both", "none"), which_plot = c("random", "top"), rm_zero = TRUE, ... )
plot_probregr( p, n, type = c("point", "line", "both", "none"), which_plot = c("random", "top"), rm_zero = TRUE, ... )
p |
(PredictionRegr) |
n |
( |
type |
( |
which_plot |
( |
rm_zero |
( |
... |
Unused |
type
:
"point"
(default) - Truth plotted as point (truth, predicted_pdf(truth))
"line"
- Truth plotted as vertical line intercepting x-axis at the truth.
"both"
- Plots both the above options.
"none"
- Truth not plotted (default if p$truth
is missing).
which_plot
:
"random"(default) - Random selection of
n' distributions are plotted.
"top"- Top
n' distributions are plotted.
It is unlikely the plot will be interpretable when n >> 5
.
## Not run: library(mlr3verse) task = tsk("boston_housing") pipe = as_learner(ppl("probregr", lrn("regr.ranger"), dist = "Normal")) p = pipe$train(task)$predict(task) plot_probregr(p, 10, "point", "top") ## End(Not run)
## Not run: library(mlr3verse) task = tsk("boston_housing") pipe = as_learner(ppl("probregr", lrn("regr.ranger"), dist = "Normal")) p = pipe$train(task)$predict(task) plot_probregr(p, 10, "point", "top") ## End(Not run)
LearnerSurv
objectsWrapper around predict.LearnerSurv
and plot.Matdist
.
## S3 method for class 'LearnerSurv' plot( x, task, fun = c("survival", "pdf", "cdf", "quantile", "hazard", "cumhazard"), row_ids = NULL, newdata, ... )
## S3 method for class 'LearnerSurv' plot( x, task, fun = c("survival", "pdf", "cdf", "quantile", "hazard", "cumhazard"), row_ids = NULL, newdata, ... )
x |
|
task |
(TaskSurv) |
fun |
( |
row_ids |
( |
newdata |
( |
... |
Additional arguments passed to |
## Not run: library(mlr3) task = tsk("rats") # Prediction Error Curves for prediction object learn = lrn("surv.coxph") learn$train(task) plot(learn, task, "survival", ind = 10) plot(learn, task, "survival", row_ids = 1:5) plot(learn, task, "survival", newdata = task$data()[1:5, ]) plot(learn, task, "survival", newdata = task$data()[1:5, ], ylim = c(0, 1)) ## End(Not run)
## Not run: library(mlr3) task = tsk("rats") # Prediction Error Curves for prediction object learn = lrn("surv.coxph") learn$train(task) plot(learn, task, "survival", ind = 10) plot(learn, task, "survival", row_ids = 1:5) plot(learn, task, "survival", newdata = task$data()[1:5, ]) plot(learn, task, "survival", newdata = task$data()[1:5, ], ylim = c(0, 1)) ## End(Not run)
This object stores the predictions returned by a learner of class LearnerDens.
The task_type
is set to "dens"
.
mlr3::Prediction
-> PredictionDens
pdf
(numeric()
)
Access the stored predicted probability density function.
cdf
(numeric()
)
Access the stored predicted cumulative distribution function.
distr
(Distribution)
Access the stored estimated distribution.
new()
Creates a new instance of this R6 class.
PredictionDens$new( task = NULL, row_ids = task$row_ids, pdf = NULL, cdf = NULL, distr = NULL, check = TRUE )
task
(TaskSurv)
Task, used to extract defaults for row_ids
.
row_ids
(integer()
)
Row ids of the predicted observations, i.e. the row ids of the test set.
pdf
(numeric()
)
Numeric vector of estimated probability density function, evaluated at values in test set.
One element for each observation in the test set.
cdf
(numeric()
)
Numeric vector of estimated cumulative distribution function, evaluated at values in test
set. One element for each observation in the test set.
distr
(Distribution)
Distribution from distr6.
The distribution from which pdf
and cdf
are derived.
check
(logical(1)
)
If TRUE
, performs argument checks and predict type conversions.
clone()
The objects of this class are cloneable with this method.
PredictionDens$clone(deep = FALSE)
deep
Whether to make a deep clone.
Other Prediction:
PredictionSurv
library(mlr3) task = mlr_tasks$get("precip") learner = mlr_learners$get("dens.hist") p = learner$train(task)$predict(task) head(as.data.table(p))
library(mlr3) task = mlr_tasks$get("precip") learner = mlr_learners$get("dens.hist") p = learner$train(task)$predict(task) head(as.data.table(p))
This object stores the predictions returned by a learner of class LearnerSurv.
The task_type
is set to "surv"
.
For accessing survival and hazard functions, as well as other complex methods
from a PredictionSurv object, see public methods on distr6::ExoticStatistics()
and example below.
mlr3::Prediction
-> PredictionSurv
truth
(Surv
)
True (observed) outcome.
crank
(numeric()
)
Access the stored predicted continuous ranking.
distr
(distr6::Matdist|distr6::Arrdist|distr6::VectorDistribution)
Convert the stored survival array or matrix to a survival distribution.
lp
(numeric()
)
Access the stored predicted linear predictor.
response
(numeric()
)
Access the stored predicted survival time.
new()
Creates a new instance of this R6 class.
PredictionSurv$new( task = NULL, row_ids = task$row_ids, truth = task$truth(), crank = NULL, distr = NULL, lp = NULL, response = NULL, check = TRUE )
task
(TaskSurv)
Task, used to extract defaults for row_ids
and truth
.
row_ids
(integer()
)
Row ids of the predicted observations, i.e. the row ids of the test set.
truth
(survival::Surv()
)
True (observed) response.
crank
(numeric()
)
Numeric vector of predicted continuous rankings (or relative risks). One element for each
observation in the test set. For a pair of continuous ranks, a higher rank indicates that
the observation is more likely to experience the event.
distr
(matrix()|[distr6::Arrdist]|[distr6::Matdist]|[distr6::VectorDistribution]
)
Either a matrix of predicted survival probabilities, a distr6::VectorDistribution,
a distr6::Matdist or an distr6::Arrdist.
If a matrix/array then column names must be given and correspond to survival times.
Rows of matrix correspond to individual predictions. It is advised that the
first column should be time 0
with all entries 1
and the last
with all entries 0
. If a VectorDistribution
then each distribution in the vector
should correspond to a predicted survival distribution.
lp
(numeric()
)
Numeric vector of linear predictor scores. One element for each observation in the test
set. where
is a matrix of covariates and
is a vector
of estimated coefficients.
response
(numeric()
)
Numeric vector of predicted survival times.
One element for each observation in the test set.
check
(logical(1)
)
If TRUE
, performs argument checks and predict type conversions.
Upon initialization, if the distr
input is a Distribution,
we try to coerce it either to a survival matrix or a survival array and store it
in the $data$distr
slot for internal use.
If the stored $data$distr
is a Distribution object,
the active field $distr
(external user API) returns it without modification.
Otherwise, if $data$distr
is a survival matrix or array, $distr
constructs a distribution out of the $data$distr
object, which will be a
Matdist or Arrdist respectively.
Note that if a survival 3d array is stored in $data$distr
, the $distr
field returns an Arrdist initialized with which.curve = 0.5
by default (i.e. the median curve). This means that measures that require
a distr
prediction like MeasureSurvGraf, MeasureSurvRCLL, etc.
will use the median survival probabilities.
Note that it is possible to manually change which.curve
after construction
of the predicted distribution but we advise against this as it may lead to
inconsistent results.
clone()
The objects of this class are cloneable with this method.
PredictionSurv$clone(deep = FALSE)
deep
Whether to make a deep clone.
Other Prediction:
PredictionDens
library(mlr3) task = tsk("rats") learner = lrn("surv.kaplan") p = learner$train(task, row_ids = 1:26)$predict(task, row_ids = 27:30) head(as.data.table(p)) p$distr # distr6::Matdist class (test obs x time points) # survival probabilities of the 4 test rats at two time points p$distr$survival(c(20, 100))
library(mlr3) task = tsk("rats") learner = lrn("surv.kaplan") p = learner$train(task, row_ids = 1:26)$predict(task, row_ids = 27:30) head(as.data.table(p)) p$distr # distr6::Matdist class (test obs x time points) # survival probabilities of the 4 test rats at two time points p$distr$survival(c(20, 100))
This task specializes TaskUnsupervised for density estimation problems.
The data in backend
should be a numeric vector or a one column matrix-like object.
The task_type
is set to "density"
.
Predefined tasks are stored in the dictionary mlr_tasks.
mlr3::Task
-> mlr3::TaskUnsupervised
-> TaskDens
mlr3::Task$add_strata()
mlr3::Task$cbind()
mlr3::Task$data()
mlr3::Task$divide()
mlr3::Task$droplevels()
mlr3::Task$filter()
mlr3::Task$format()
mlr3::Task$formula()
mlr3::Task$head()
mlr3::Task$help()
mlr3::Task$levels()
mlr3::Task$missings()
mlr3::Task$print()
mlr3::Task$rbind()
mlr3::Task$rename()
mlr3::Task$select()
mlr3::Task$set_col_roles()
mlr3::Task$set_levels()
mlr3::Task$set_row_roles()
new()
Creates a new instance of this R6 class.
TaskDens$new(id, backend, label = NA_character_)
id
(character(1)
)
Identifier for the new instance.
backend
(DataBackend)
Either a DataBackend, a matrix-like object, or a numeric vector.
If weights are used then two columns expected, otherwise one column. The weight column
must be clearly specified (via [Task]$col_roles
) or the learners will break.
label
(character(1)
)
Label for the new instance.
clone()
The objects of this class are cloneable with this method.
TaskDens$clone(deep = FALSE)
deep
Whether to make a deep clone.
Other Task:
TaskSurv
,
mlr_tasks_actg
,
mlr_tasks_faithful
,
mlr_tasks_gbcs
,
mlr_tasks_gbsg
,
mlr_tasks_grace
,
mlr_tasks_lung
,
mlr_tasks_mgus
,
mlr_tasks_pbc
,
mlr_tasks_precip
,
mlr_tasks_rats
,
mlr_tasks_unemployment
,
mlr_tasks_veteran
,
mlr_tasks_whas
task = TaskDens$new("precip", backend = precip) task$task_type
task = TaskDens$new("precip", backend = precip) task$task_type
This task specializes mlr3::Task and mlr3::TaskSupervised for possibly-censored survival problems. The target is comprised of survival times and an event indicator. Predefined tasks are stored in mlr3::mlr_tasks.
The task_type
is set to "surv"
.
mlr3::Task
-> mlr3::TaskSupervised
-> TaskSurv
censtype
(character(1)
)
Returns the type of censoring, one of "right"
, "left"
, "counting"
,
"interval"
, "interval2"
or "mstate"
.
Currently, only the "right"
-censoring type is fully supported, the rest
are experimental and the API will change in the future.
mlr3::Task$add_strata()
mlr3::Task$cbind()
mlr3::Task$data()
mlr3::Task$divide()
mlr3::Task$droplevels()
mlr3::Task$filter()
mlr3::Task$format()
mlr3::Task$head()
mlr3::Task$help()
mlr3::Task$levels()
mlr3::Task$missings()
mlr3::Task$print()
mlr3::Task$rbind()
mlr3::Task$rename()
mlr3::Task$select()
mlr3::Task$set_col_roles()
mlr3::Task$set_levels()
mlr3::Task$set_row_roles()
new()
Creates a new instance of this R6 class.
TaskSurv$new( id, backend, time = "time", event = "event", time2, type = c("right", "left", "interval", "counting", "interval2", "mstate"), label = NA_character_ )
id
(character(1)
)
Identifier for the new instance.
backend
(DataBackend)
Either a DataBackend, or any object which is convertible to a DataBackend with as_data_backend()
.
E.g., a data.frame()
will be converted to a DataBackendDataTable.
time
(character(1)
)
Name of the column for event time if data is right censored, otherwise starting time if
interval censored.
event
(character(1)
)
Name of the column giving the event indicator.
If data is right censored then "0"/FALSE
means alive (no event), "1"/TRUE
means dead
(event). If type
is "interval"
then "0" means right censored, "1" means dead (event),
"2" means left censored, and "3" means interval censored. If type
is "interval2"
then
event
is ignored.
time2
(character(1)
)
Name of the column for ending time of the interval for interval censored or
counting process data, otherwise ignored.
type
(character(1)
)
Name of the column giving the type of censoring. Default is 'right' censoring.
label
(character(1)
)
Label for the new instance.
Depending on the censoring type ("type"
), the output of a survival
task's "$target_names"
is a character()
vector with values the names
of the columns given by the above initialization arguments.
Specifically, the output is as follows (and in the specified order):
For type
= "right"
, "left"
or "mstate"
: ("time"
, "event"
)
For type
= "interval"
or "counting"
: ("time"
, "time2"
, "event"
)
For type
= "interval2"
: ("time"
, "time2
)
truth()
True response for specified row_ids
. This is the survival outcome
using the Surv format and depends on the censoring
type. Defaults to all rows with role "use"
.
TaskSurv$truth(rows = NULL)
rows
(integer()
)
Row indices.
formula()
Creates a formula for survival models with survival::Surv()
on the LHS
(left hand side).
TaskSurv$formula(rhs = NULL, reverse = FALSE)
rhs
If NULL
, RHS (right hand side) is "."
, otherwise RHS is "rhs"
.
reverse
If TRUE
then formula calculated with 1 - status.
times()
Returns the (unsorted) outcome times.
TaskSurv$times(rows = NULL)
rows
(integer()
)
Row indices.
numeric()
status()
Returns the event indicator (aka censoring/survival indicator).
If censtype
is "right"
or "left"
then 1
is event and 0
is censored.
If censtype
is "mstate"
then 0
is censored and all other values are different events.
If censtype
is "interval"
then 0
is right-censored, 1
is event, 2
is left-censored,
3
is interval-censored.
See survival::Surv()
.
TaskSurv$status(rows = NULL)
rows
(integer()
)
Row indices.
integer()
unique_times()
Returns the sorted unique outcome times for "right"
, "left"
and
"mstate"
types of censoring.
TaskSurv$unique_times(rows = NULL)
rows
(integer()
)
Row indices.
numeric()
unique_event_times()
Returns the sorted unique event (or failure) outcome times for "right"
,
"left"
and "mstate"
types of censoring.
TaskSurv$unique_event_times(rows = NULL)
rows
(integer()
)
Row indices.
numeric()
risk_set()
Returns the row_ids
of the observations at risk (not dead or censored
or had other events in case of multi-state tasks) at the specified time
.
Only designed for "right"
, "left"
and "mstate"
types of censoring.
TaskSurv$risk_set(time = NULL)
time
(numeric(1)
)
Time to return risk set for, if NULL
returns all row_ids
.
integer()
kaplan()
Calls survival::survfit()
to calculate the Kaplan-Meier estimator.
TaskSurv$kaplan(strata = NULL, rows = NULL, reverse = FALSE, ...)
strata
(character()
)
Stratification variables to use.
rows
(integer()
)
Subset of row indices.
reverse
(logical()
)
If TRUE
calculates Kaplan-Meier of censoring distribution (1-status). Default FALSE
.
...
(any)
Additional arguments passed down to survival::survfit.formula()
.
reverse()
Returns the same task with the status variable reversed, i.e., 1 - status.
Only designed for "left"
and "right"
censoring.
TaskSurv$reverse()
cens_prop()
Returns the proportion of censoring for this survival task.
By default, this is returned for all observations, otherwise only the
specified ones (rows
).
Only designed for "right"
and "left"
censoring.
TaskSurv$cens_prop(rows = NULL)
rows
(integer()
)
Row indices.
numeric()
admin_cens_prop()
Returns an estimated proportion of administratively censored observations (i.e. censored at or after a user-specified time point). Our main assumption here is that in an administratively censored dataset, the maximum censoring time is likely close to the maximum event time and so we expect higher proportion of censored subjects near the study end date.
Only designed for "right"
and "left"
censoring.
TaskSurv$admin_cens_prop(rows = NULL, admin_time = NULL, quantile_prob = 0.99)
rows
(integer()
)
Row indices.
admin_time
(numeric(1)
)
Administrative censoring time (in case it is known a priori).
quantile_prob
(numeric(1)
)
Quantile probability value with which we calculate the cutoff time for
administrative censoring. Ignored, if admin_time
is given.
By default, quantile_prob
is equal to , which translates to a
time point very close to the maximum outcome time in the dataset.
A lower value will result in an earlier time point and therefore in a more
relaxed definition (i.e. higher proportion) of administrative censoring.
numeric()
dep_cens_prop()
Returns the proportion of covariates (task features) that are found to be significantly associated with censoring. This function fits a logistic regression model via glm with the censoring status as the response and using all features as predictors. If a covariate is significantly associated with the censoring status, it suggests that censoring may be informative (dependent) rather than random (non-informative). This methodology is more suitable for low-dimensional datasets where the number of features is relatively small compared to the number of observations.
Only designed for "right"
and "left"
censoring.
TaskSurv$dep_cens_prop(rows = NULL, method = "holm", sign_level = 0.05)
rows
(integer()
)
Row indices.
method
(character(1)
)
Method to adjust p-values for multiple comparisons, see p.adjust.methods.
Default is "holm"
.
sign_level
(numeric(1)
)
Significance level for each coefficient's p-value from the logistic
regression model. Default is .
numeric()
prop_haz()
Checks if the data satisfy the proportional hazards (PH) assumption using the Grambsch-Therneau test, Grambsch (1994). Uses cox.zph. This method should be used only for low-dimensional datasets where the number of features is relatively small compared to the number of observations.
Only designed for "right"
and "left"
censoring.
TaskSurv$prop_haz()
numeric()
If no errors, the p-value of the global chi-square test.
A p-value is an indication of possible PH violation.
clone()
The objects of this class are cloneable with this method.
TaskSurv$clone(deep = FALSE)
deep
Whether to make a deep clone.
Grambsch, Patricia, Therneau, Terry (1994). “Proportional hazards tests and diagnostics based on weighted residuals.” Biometrika, 81(3), 515–526. doi:10.1093/biomet/81.3.515, https://doi.org/10.1093/biomet/81.3.515.
Other Task:
TaskDens
,
mlr_tasks_actg
,
mlr_tasks_faithful
,
mlr_tasks_gbcs
,
mlr_tasks_gbsg
,
mlr_tasks_grace
,
mlr_tasks_lung
,
mlr_tasks_mgus
,
mlr_tasks_pbc
,
mlr_tasks_precip
,
mlr_tasks_rats
,
mlr_tasks_unemployment
,
mlr_tasks_veteran
,
mlr_tasks_whas
library(mlr3) task = tsk("lung") # meta data task$target_names # target is always (time, status) for right-censoring tasks task$feature_names task$formula() # survival data task$truth() # survival::Surv() object task$times() # (unsorted) times task$status() # event indicators (1 = death, 0 = censored) task$unique_times() # sorted unique times task$unique_event_times() # sorted unique event times task$risk_set(time = 700) # observation ids that are not censored or dead at t = 700 task$kaplan(strata = "sex") # stratified Kaplan-Meier task$kaplan(reverse = TRUE) # Kaplan-Meier of the censoring distribution # proportion of censored observations across all dataset task$cens_prop() # proportion of censored observations at or after the 95% time quantile task$admin_cens_prop(quantile_prob = 0.95) # proportion of variables that are significantly associated with the # censoring status via a logistic regression model task$dep_cens_prop() # 0 indicates independent censoring # data barely satisfies proportional hazards assumption (p > 0.05) task$prop_haz() # veteran data is definitely non-PH (p << 0.05) tsk("veteran")$prop_haz()
library(mlr3) task = tsk("lung") # meta data task$target_names # target is always (time, status) for right-censoring tasks task$feature_names task$formula() # survival data task$truth() # survival::Surv() object task$times() # (unsorted) times task$status() # event indicators (1 = death, 0 = censored) task$unique_times() # sorted unique times task$unique_event_times() # sorted unique event times task$risk_set(time = 700) # observation ids that are not censored or dead at t = 700 task$kaplan(strata = "sex") # stratified Kaplan-Meier task$kaplan(reverse = TRUE) # Kaplan-Meier of the censoring distribution # proportion of censored observations across all dataset task$cens_prop() # proportion of censored observations at or after the 95% time quantile task$admin_cens_prop(quantile_prob = 0.95) # proportion of variables that are significantly associated with the # censoring status via a logistic regression model task$dep_cens_prop() # 0 indicates independent censoring # data barely satisfies proportional hazards assumption (p > 0.05) task$prop_haz() # veteran data is definitely non-PH (p << 0.05) tsk("veteran")$prop_haz()
whas dataset from Hosmer et al. (2008)
whas
whas
Identification Code
Age (per chart) (years).
Sex. 0 = Male. 1 = Female.
Peak cardiac enzyme (iu).
Cardiogenic shock complications. 1 = Yes. 0 = No.
Left heart failure complications. 1 = Yes. 0 = No.
MI Order. 1 = Recurrent. 0 = First.
MI Type. 1 = Q-wave. 2 = Not Q-wave. 3 = Indeterminate.
Cohort year.
Grouped cohort year.
Days in hospital.
Discharge status from hospital. 1 = Dead. 0 = Alive.
Total length of follow-up from hospital admission (days).
Status as of last follow-up. 1 = Dead. 0 = Alive.
https://onlinelibrary.wiley.com/doi/book/10.1002/9780470258019
Hosmer, D.W. and Lemeshow, S. and May, S. (2008) Applied Survival Analysis: Regression Modeling of Time to Event Data: Second Edition, John Wiley and Sons Inc., New York, NY