diff --git a/DESCRIPTION b/DESCRIPTION index d2a4e7840..059c5ed8d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: mlr3proba Title: Probabilistic Supervised Learning for 'mlr3' -Version: 0.7.0 +Version: 0.7.1 Authors@R: c(person(given = "Raphael", family = "Sonabend", @@ -140,18 +140,11 @@ Collate: 'PipeOpDistrCompositor.R' 'PipeOpPredClassifSurvDiscTime.R' 'PipeOpPredClassifSurvIPCW.R' - 'PipeOpTransformer.R' - 'PipeOpPredTransformer.R' - 'PipeOpPredRegrSurv.R' - 'PipeOpPredSurvRegr.R' 'PipeOpProbregrCompositor.R' 'PipeOpResponseCompositor.R' 'PipeOpSurvAvg.R' - 'PipeOpTaskRegrSurv.R' 'PipeOpTaskSurvClassifDiscTime.R' 'PipeOpTaskSurvClassifIPCW.R' - 'PipeOpTaskSurvRegr.R' - 'PipeOpTaskTransformer.R' 'PredictionDataDens.R' 'PredictionDataSurv.R' 'PredictionDens.R' diff --git a/NAMESPACE b/NAMESPACE index 07043bb42..2febffe65 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -72,18 +72,11 @@ export(PipeOpCrankCompositor) export(PipeOpDistrCompositor) export(PipeOpPredClassifSurvDiscTime) export(PipeOpPredClassifSurvIPCW) -export(PipeOpPredRegrSurv) -export(PipeOpPredSurvRegr) -export(PipeOpPredTransformer) export(PipeOpProbregr) export(PipeOpResponseCompositor) export(PipeOpSurvAvg) -export(PipeOpTaskRegrSurv) export(PipeOpTaskSurvClassifDiscTime) export(PipeOpTaskSurvClassifIPCW) -export(PipeOpTaskSurvRegr) -export(PipeOpTaskTransformer) -export(PipeOpTransformer) export(PredictionDens) export(PredictionSurv) export(TaskDens) @@ -102,7 +95,6 @@ export(get_mortality) export(pecs) export(pipeline_survtoclassif_IPCW) export(pipeline_survtoclassif_disctime) -export(pipeline_survtoregr) export(plot_probregr) import(checkmate) import(data.table) diff --git a/NEWS.md b/NEWS.md index 47f1d9a36..b5d0d64cf 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# mlr3proba 0.7.1 + +* Removed all `PipeOp`s and pipelines related to survival => regression reduction techniques (see #414) + # mlr3proba 0.7.0 * Add `mlr3pipelines` to `Imports` and set minimum latest version from CRAN (`0.7.0`) diff --git a/R/PipeOpPredClassifSurvDiscTime.R b/R/PipeOpPredClassifSurvDiscTime.R index 9de1203e6..a9fa17587 100644 --- a/R/PipeOpPredClassifSurvDiscTime.R +++ b/R/PipeOpPredClassifSurvDiscTime.R @@ -34,7 +34,7 @@ #' #' @references #' `r format_bib("tutz_2016")` -#' @family PipeOps +#' @seealso [pipeline_survtoclassif_disctime] #' @family Transformation PipeOps #' @export PipeOpPredClassifSurvDiscTime = R6Class("PipeOpPredClassifSurvDiscTime", diff --git a/R/PipeOpPredClassifSurvIPCW.R b/R/PipeOpPredClassifSurvIPCW.R index dffff1e70..b5e6b8b57 100644 --- a/R/PipeOpPredClassifSurvIPCW.R +++ b/R/PipeOpPredClassifSurvIPCW.R @@ -36,7 +36,7 @@ #' @references #' `r format_bib("vock_2016")` #' -#' @family PipeOps +#' @seealso [pipeline_survtoclassif_IPCW] #' @family Transformation PipeOps #' @export PipeOpPredClassifSurvIPCW = R6Class("PipeOpPredClassifSurvIPCW", diff --git a/R/PipeOpPredRegrSurv.R b/R/PipeOpPredRegrSurv.R deleted file mode 100644 index a0d3798d9..000000000 --- a/R/PipeOpPredRegrSurv.R +++ /dev/null @@ -1,105 +0,0 @@ -#' @title PipeOpPredRegrSurv -#' @name mlr_pipeops_trafopred_regrsurv -#' @template param_pipelines -#' -#' @description -#' Transform [PredictionRegr] to [PredictionSurv]. -#' -#' @section Input and Output Channels: -#' 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. -#' -#' @section State: -#' The `$state` is a named `list` with the `$state` elements inherited from [`PipeOpPredTransformer`]. -#' -#' @section Parameters: -#' The parameters are -#' -#' * `status :: (numeric(1))`\cr -#' 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. -#' -#' @examplesIf mlr3misc::require_namespaces(c("mlr3pipelines"), quietly = TRUE) -#' \dontrun{ -#' 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()) -#' } -#' @family PipeOps -#' @family Transformation PipeOps -#' @include PipeOpPredTransformer.R -#' @export -PipeOpPredRegrSurv = R6Class("PipeOpPredRegrSurv", - inherit = PipeOpPredTransformer, - public = list( - #' @description - #' Creates a new instance of this [R6][R6::R6Class] class. - initialize = function(id = "trafopred_regrsurv", param_vals = list()) { - - ps = ps( - target_type = p_fct(default = "response", levels = c("crank", "response", "lp")) - ) - - super$initialize(id = id, - param_set = ps, - param_vals = param_vals, - input = data.table(name = c("pred", "task"), train = "NULL", - predict = c("PredictionRegr", "*")), - output = data.table(name = "output", train = "NULL", predict = "PredictionSurv") - ) - } - ), - - private = list( - .transform = function(input) { - task = input$task - input = input$pred$clone(deep = TRUE) - - if (!is.null(task)) { - assert_class(task, "TaskSurv") - task = task$clone(deep = TRUE) - truth = task$truth() - } else { - truth = Surv(input$truth) - } - - distr = try(input$distr, silent = TRUE) - if (inherits(distr, "try-error") || is.null(distr)) { - distr = NULL - } - - response = lp = NULL - target_type = self$param_set$values$target_type - if (is.null(target_type) || target_type == "response") { - response = input$response - } else if (target_type == "lp") { - lp = input$response - } - - PredictionSurv$new(row_ids = input$row_ids, truth = truth, - distr = distr, crank = input$response, response = response, - lp = lp) - } - ) -) - -register_pipeop("trafopred_regrsurv", PipeOpPredRegrSurv) diff --git a/R/PipeOpPredSurvRegr.R b/R/PipeOpPredSurvRegr.R deleted file mode 100644 index 98b23447c..000000000 --- a/R/PipeOpPredSurvRegr.R +++ /dev/null @@ -1,56 +0,0 @@ -#' @title PipeOpPredSurvRegr -#' @name mlr_pipeops_trafopred_survregr -#' @template param_pipelines -#' -#' @description -#' Transform [PredictionSurv] to [PredictionRegr]. -#' -#' @section Input and Output Channels: -#' 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. -#' -#' @section State: -#' The `$state` is a named `list` with the `$state` elements inherited from [PipeOpPredTransformer]. -#' -#' @examplesIf mlr3misc::require_namespaces(c("mlr3pipelines"), quietly = TRUE) -#' \dontrun{ -#' 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) -#' } -#' @family PipeOps -#' @family Transformation PipeOps -#' @include PipeOpPredTransformer.R -#' @export -PipeOpPredSurvRegr = R6Class("PipeOpPredSurvRegr", - inherit = PipeOpPredTransformer, - public = list( - #' @description - #' Creates a new instance of this [R6][R6::R6Class] class. - initialize = function(id = "trafopred_survregr") { - super$initialize(id = id, - input = data.table(name = "input", train = "NULL", predict = "PredictionSurv"), - output = data.table(name = "output", train = "NULL", predict = "PredictionRegr") - ) - } - ), - - private = list( - .transform = function(input) { - input = input[[1]] - PredictionRegr$new(row_ids = input$row_ids, truth = input$truth[, 1L], - distr = input$distr, response = input$response) - } - ) -) - -register_pipeop("trafopred_survregr", PipeOpPredSurvRegr) diff --git a/R/PipeOpPredTransformer.R b/R/PipeOpPredTransformer.R deleted file mode 100644 index 9e52b851e..000000000 --- a/R/PipeOpPredTransformer.R +++ /dev/null @@ -1,54 +0,0 @@ -#' @title PipeOpPredTransformer -#' -#' @template param_pipelines -#' @template param_param_set -#' @template param_packages -#' @template param_input_output -#' -#' @description -#' Parent class for [PipeOp][mlr3pipelines::PipeOp]s that transform [Prediction][mlr3::Prediction] -#' objects to different types. -#' -#' @section Input and Output Channels: -#' [`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. -#' -#' @section State: -#' 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`. -#' -#' @section Internals: -#' Classes inheriting from [`PipeOpPredTransformer`] transform [Prediction][mlr3::Prediction] -#' objects from one class (e.g. regr, classif) to another. -#' -#' @family PipeOps -#' @family Transformers -#' @include PipeOpTransformer.R -#' @export -PipeOpPredTransformer = R6Class("PipeOpPredTransformer", - inherit = PipeOpTransformer, - public = list( - #' @description - #' Creates a new instance of this [R6][R6::R6Class] class. - initialize = function(id, param_set = ps(), param_vals = list(), - packages = character(0), input = data.table(), output = data.table()) { - super$initialize(id = id, - param_set = param_set, - param_vals = param_vals, - packages = c("mlr3proba", packages), - input = input, - output = output - ) - } - ), - - private = list( - .train = function(inputs) { - list(NULL) - } - ) -) diff --git a/R/PipeOpSurvAvg.R b/R/PipeOpSurvAvg.R index d9ac42263..862348842 100644 --- a/R/PipeOpSurvAvg.R +++ b/R/PipeOpSurvAvg.R @@ -30,6 +30,7 @@ #' Inherits from [PipeOpEnsemble][mlr3pipelines::PipeOpEnsemble] by implementing the #' `private$weighted_avg_predictions()` method. #' +#' @seealso [pipeline_survaverager] #' @family PipeOps #' @family Ensembles #' @export diff --git a/R/PipeOpTaskRegrSurv.R b/R/PipeOpTaskRegrSurv.R deleted file mode 100644 index e258ae2b5..000000000 --- a/R/PipeOpTaskRegrSurv.R +++ /dev/null @@ -1,87 +0,0 @@ -#' @title PipeOpTaskRegrSurv -#' @name mlr_pipeops_trafotask_regrsurv -#' @template param_pipelines -#' -#' @description -#' Transform [TaskRegr] to [TaskSurv]. -#' -#' @section Input and Output Channels: -#' Input and output channels are inherited from [PipeOpTaskTransformer]. -#' -#' The output is the input [TaskRegr] transformed to a [TaskSurv]. -#' -#' @section State: -#' The `$state` is a named `list` with the `$state` elements inherited from [PipeOpTaskTransformer]. -#' -#' @section Parameters: -#' The parameters are -#' -#' * `status :: (numeric(1))`\cr -#' 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. -#' -#' @examplesIf mlr3misc::require_namespaces(c("mlr3pipelines"), quietly = TRUE) -#' \dontrun{ -#' 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() -#' } -#' @family PipeOps -#' @family Transformation PipeOps -#' @include PipeOpPredTransformer.R -#' @export -PipeOpTaskRegrSurv = R6Class("PipeOpTaskRegrSurv", - inherit = PipeOpTaskTransformer, - public = list( - #' @description - #' Creates a new instance of this [R6][R6::R6Class] class. - initialize = function(id = "trafotask_regrsurv") { - super$initialize(id = id, - input = data.table(name = c("task_regr", "task_surv"), - train = c("TaskRegr", "*"), - predict = c("TaskRegr", "*")), - output = data.table(name = "output", train = "TaskSurv", predict = "TaskSurv") - ) - } - ), - - private = list( - .private = function(inputs) { - list(private$.transform(inputs)) - }, - - .transform = function(input) { - - task_surv = input$task_surv - input = input$task_regr$clone(deep = TRUE) - backend = copy(input$data()) - - - if (!is.null(task_surv)) { - assert_class(task_surv, "TaskSurv") - task_surv = task_surv$clone(deep = TRUE) - backend$status = task_surv$truth()[, 2] - } else { - backend$status = 1 - } - - TaskSurv$new(id = input$id, backend = backend, time = input$target_names, event = "status") - } - ) -) - -register_pipeop("trafotask_regrsurv", PipeOpTaskRegrSurv) diff --git a/R/PipeOpTaskSurvClassifDiscTime.R b/R/PipeOpTaskSurvClassifDiscTime.R index ec8617797..ed600fede 100644 --- a/R/PipeOpTaskSurvClassifDiscTime.R +++ b/R/PipeOpTaskSurvClassifDiscTime.R @@ -81,7 +81,7 @@ #' @references #' `r format_bib("tutz_2016")` #' -#' @family PipeOps +#' @seealso [pipeline_survtoclassif_disctime] #' @family Transformation PipeOps #' @export PipeOpTaskSurvClassifDiscTime = R6Class("PipeOpTaskSurvClassifDiscTime", diff --git a/R/PipeOpTaskSurvClassifIPCW.R b/R/PipeOpTaskSurvClassifIPCW.R index 4d54d1313..4c9de1549 100644 --- a/R/PipeOpTaskSurvClassifIPCW.R +++ b/R/PipeOpTaskSurvClassifIPCW.R @@ -61,7 +61,7 @@ #' @references #' `r format_bib("vock_2016")` #' -#' @family PipeOps +#' @seealso [pipeline_survtoclassif_IPCW] #' @family Transformation PipeOps #' @examplesIf mlr3misc::require_namespaces(c("mlr3pipelines", "mlr3learners"), quietly = TRUE) #' \dontrun{ diff --git a/R/PipeOpTaskSurvRegr.R b/R/PipeOpTaskSurvRegr.R deleted file mode 100644 index 19fe0ec0d..000000000 --- a/R/PipeOpTaskSurvRegr.R +++ /dev/null @@ -1,322 +0,0 @@ -#' @title PipeOpTaskSurvRegr -#' @template param_pipelines -#' @name mlr_pipeops_trafotask_survregr -#' -#' @description -#' Transform [TaskSurv] to [TaskRegr][mlr3::TaskRegr]. -#' -#' @section Input and Output Channels: -#' Input and output channels are inherited from [PipeOpTaskTransformer]. -#' -#' The output is the input [TaskSurv] transformed to a [TaskRegr][mlr3::TaskRegr]. -#' -#' @section State: -#' The `$state` is a named `list` with the `$state` elements -#' -#' * `instatus`: Censoring status from input training task. -#' * `outstatus` : Censoring status from input prediction task. -#' -#' @section Parameters: -#' The parameters are -#' -#' * `method` :: `character(1)`\cr -#' 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)`\cr -#' 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)`\cr -#' 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 -#' \eqn{(\delta + \alpha(1-\delta))/G(t)} where \eqn{\delta} is the censoring indicator. -#' * `eps` :: `numeric(1)`\cr -#' Small value to replace `0` survival probabilities with in IPCW to prevent infinite weights. -#' * `lambda` :: `numeric(1)`\cr -#' Nearest neighbours parameter for the `"akritas"` estimator in the [mlr3extralearners package](https://mlr3extralearners.mlr-org.com/), default `0.5`. -#' * `features, target` :: `character()`\cr -#' For `"reorder"` method, specify which columns become features and targets. -#' * `learner cneter, mimpu, iter.bj, max.cycle, mstop, nu`\cr -#' Passed to [bujar::bujar]. -#' -#' @references -#' `r format_bib("buckley_1979", "klein_2003", "vock_2016")` -#' -#' @examplesIf mlr3misc::require_namespaces(c("mlr3pipelines"), quietly = TRUE) -#' \dontrun{ -#' 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) -#' } -#' @family PipeOps -#' @family Transformation PipeOps -#' @include PipeOpPredTransformer.R -#' @export -PipeOpTaskSurvRegr = R6Class("PipeOpTaskSurvRegr", - inherit = PipeOpTaskTransformer, - public = list( - #' @description - #' Creates a new instance of this [R6][R6::R6Class] class. - initialize = function(id = "trafotask_survregr", param_vals = list()) { - ps = ps( - method = p_fct(default = "ipcw", levels = c("ipcw", "mrl", "bj", "delete", "omit", "reorder"), tags = "train"), - estimator = p_fct( - default = "kaplan", levels = c("kaplan", "akritas", "cox"), tags = "train", depends = quote(method %in% c("ipcw", "mrl"))), - alpha = p_dbl(0, 1, default = 1, tags = "train", depends = quote(method == "ipcw")), - lambda = p_dbl(0, 1, default = 0.5, tags = "train", depends = quote(estimator == "akritas")), - eps = p_dbl(0, 1, default = 1e-15, tags = "train", depends = quote(method == "ipcw")), - features = p_uty(tags = "train", depends = quote(method == "reorder")), - target = p_uty(tags = "train", depends = quote(method == "reorder")), - learner = p_fct(default = "linear.regression", - levels = c("linear.regression", "mars", "pspline", "tree", "acosso", "enet", "enet2", "mnet", "snet"), - tags = c("train", "bj"), - depends = quote(method == "bj")), - center = p_lgl(default = TRUE, tags = c("train", "bj"), depends = quote(method == "bj")), - mimpu = p_lgl(default = NULL, special_vals = list(NULL), tags = c("train", "bj"), depends = quote(method == "bj")), - iter.bj = p_int(2L, default = 20L, tags = c("train", "bj"), depends = quote(method == "bj")), - max.cycle = p_int(1L, default = 5L, tags = c("train", "bj")), - mstop = p_int(1L, default = 50L, tags = c("train", "bj"), depends = quote(method == "bj")), - nu = p_dbl(0, default = 0.1, tags = c("train", "bj"), depends = quote(method == "bj")) - ) - - super$initialize(id = id, - param_set = ps, - param_vals = param_vals, - input = data.table(name = c("input", "input_features"), - train = c("TaskSurv", "*"), - predict = c("TaskSurv", "*")), - output = data.table(name = "output", train = "TaskRegr", predict = "TaskRegr") - ) - } - ), - - private = list( - .predict = function(inputs) { - pv = self$param_set$values - target = pv$target - if (is.null(target)) { - target = inputs[[1L]]$target_names[1L] - } - backend = private$.reorder(copy(inputs[[1L]]$data()), pv$features, target, inputs[[2L]]) - return(list(TaskRegr$new(id = inputs[[1L]]$id, backend = backend, target = target))) - }, - - .transform = function(inputs) { - - input = inputs[[1L]] - backend = copy(input$data()) - time = input$target_names[1L] - status = input$target_names[2L] - - pv = self$param_set$values - - method = pv$method - if (is.null(method)) { - method = "ipcw" - } - estimator = pv$estimator - if (is.null(estimator)) { - estimator = "kaplan" - } - eps = pv$eps - if (is.null(eps)) { - eps = 1e-15 - } - - backend = switch(method, - ipcw = private$.ipcw(backend, status, time, estimator, eps), - mrl = private$.mrl(backend, status, time, input, estimator), - bj = private$.bj(backend, status, time), - delete = private$.delete(backend, status), - omit = private$.omit(backend, status), - reorder = private$.reorder(backend, pv$features, pv$target, inputs[[2]]) - ) - - target = if (method == "reorder") pv$target else time - - new_task = TaskRegr$new(id = input$id, backend = backend, target = target) - - if (method == "ipcw") { - new_task$col_roles$weight = "ipc_weights" - } - - return(new_task) - }, - - .ipcw = function(backend, status, time, estimator, eps) { - cens = backend[[status]] == 0 - new_backend = copy(backend) - new_backend[[status]] = 1 - new_backend[[status]] - task = TaskSurv$new("ipcw", new_backend, time, status) - - est = switch(estimator, - kaplan = LearnerSurvKaplan, - cox = LearnerSurvCoxPH, - akritas = get_akritas_learner() - )$new() - if (estimator == "akritas") { - est$param_set$values$lambda = self$param_set$values$lambda - } - - est = est$train(task)$predict(task)$distr - if (inherits(est, c("Matdist", "Arrdist"))) { - weights = diag(est$survival(task$truth()[, 1L])) - } else { - weights = as.numeric(est$survival(data = matrix(task$truth()[, 1L], nrow = 1L))) - } - weights[weights == 0] = eps - weights = 1 / weights - - alpha = self$param_set$values$alpha - if (!is.null(alpha)) { - # catch 0 * Inf error - if (alpha == 0) { - weights[cens] = 0 - } else { - weights[cens] = weights[cens] * alpha - } - } - - backend$ipc_weights = weights - return(subset(backend, select = -status)) - }, - - .mrl = function(backend, status, time, input, estimator) { - - cens = backend[[status]] == 0 - upper = max(backend[[time]]) - unique_times = sort(unique(backend[[time]])) - - if (estimator == "kaplan") { - est = LearnerSurvKaplan$new()$train(input)$predict(input, row_ids = 1)$distr[1L] - den = est$survival(backend[[time]][cens]) - num = sapply(backend[[time]][cens], function(x) { - est$survivalAntiDeriv(x) - }) - mrl = num / den - } else { - if (estimator == "cox") { - est = LearnerSurvCoxPH$new()$train(input)$predict(input)$distr - } else { - est = get_akritas_learner()$new() - est$param_set$values$lambda = self$param_set$values$lambda - est = est$train(input)$predict(input)$distr - } - den = as.numeric(est$survival(data = matrix(backend[[time]], nrow = 1L)))[cens] - mrl = numeric(sum(cens)) - for (i in seq_along(mrl)) { - x = backend[cens, ][[time]][i] - int_range = unique_times[x <= unique_times & upper >= unique_times] - num = (sum(est[i]$survival(int_range)) * (diff(range(int_range)) / length(int_range))) - mrl[i] = num / den[i] - } - } - - backend[[time]][cens] = backend[[time]][cens] + mrl - return(subset(backend, select = -status)) - }, - - .bj = function(backend, status, time) { - require_namespaces("bujar") - - x = data.frame(backend)[, colnames(backend) %nin% c(time, status), drop = FALSE] - x = model.matrix(~., x)[, -1L] - - bj = invoke(bujar::bujar, - y = backend[[time]], - cens = backend[[status]], - x = x, - tuning = FALSE, - vimpint = FALSE, - .args = self$param_set$get_values(tags = "bj") - ) - backend[[time]] = bj$ynew - return(backend) - }, - - .delete = function(backend, status) { - subset(backend, status == 1, select = -status) - }, - - .omit = function(backend, status) { - subset(backend, select = -status) - }, - - .reorder = function(backend, features, target, task) { - if (is.null(task)) { - if (is.null(features)) { - stop("One of 'features' or 'task' must be provided.") - } - features = subset(backend, select = features) - } else { - assert_class(task, "TaskSurv") - features = copy(task$data(cols = task$feature_names)) - } - - if (target %nin% colnames(features)) { - target = subset(backend, select = target) - return(cbind(features, target)) - } else { - return(features) - } - } - ) -) - -register_pipeop("trafotask_survregr", PipeOpTaskSurvRegr) diff --git a/R/PipeOpTaskTransformer.R b/R/PipeOpTaskTransformer.R deleted file mode 100644 index 8be55fdb2..000000000 --- a/R/PipeOpTaskTransformer.R +++ /dev/null @@ -1,50 +0,0 @@ -#' @title PipeOpTaskTransformer -#' @template param_pipelines -#' @template param_param_set -#' @template param_packages -#' @template param_input_output -#' -#' @description -#' Parent class for [PipeOp][mlr3pipelines::PipeOp]s that transform task objects to different types. -#' -#' @section Input and Output Channels: -#' [`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. -#' -#' @section State: -#' The `$state` is left empty (`list()`). -#' -#' @section Internals: -#' 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. -#' -#' @family PipeOps -#' @family Transformers -#' @include PipeOpTransformer.R -#' @export -PipeOpTaskTransformer = R6Class("PipeOpTaskTransformer", - inherit = PipeOpTransformer, - public = list( - #' @description - #' Creates a new instance of this [R6][R6::R6Class] class. - initialize = function(id, param_set = ps(), param_vals = list(), - packages = character(0), input, output) { - - super$initialize(id = id, - param_set = param_set, - param_vals = param_vals, - packages = packages, - input = input, - output = output - ) - } - ), - - private = list( - .predict = function(inputs) { - list(inputs[[1]]$clone(deep = TRUE)) - } - ) -) diff --git a/R/PipeOpTransformer.R b/R/PipeOpTransformer.R deleted file mode 100644 index f12ef014e..000000000 --- a/R/PipeOpTransformer.R +++ /dev/null @@ -1,53 +0,0 @@ -#' @title PipeOpTransformer -#' @template param_pipelines -#' @template param_param_set -#' @template param_packages -#' @template param_input_output -#' -#' @description -#' Parent class for [PipeOp][mlr3pipelines::PipeOp]s that transform [Task][mlr3::Task] and [Prediction][mlr3::Prediction] -#' objects to different types. -#' -#' @section Input and Output Channels: -#' Determined by child classes. -#' -#' @section State: -#' The `$state` is left empty (`list()`). -#' -#' @section Internals: -#' The commonality of methods using [PipeOpTransformer] is that they take a [Task][mlr3::Task] -#' or [Prediction][mlr3::Prediction] of one type (e.g. regr or classif) and transform it to -#' another type. -#' -#' @family PipeOps -#' @family Transformers -#' @export -PipeOpTransformer = R6Class("PipeOpTransformer", - inherit = mlr3pipelines::PipeOp, - public = list( - #' @description - #' Creates a new instance of this [R6][R6::R6Class] class. - initialize = function(id, param_set = ps(), param_vals = list(), - packages = character(), input = data.table(), - output = data.table()) { - - super$initialize( - id = id, param_set = param_set, param_vals = param_vals, - packages = unique(c("mlr3proba", packages)), input = input, - output = output - ) - } - ), - - private = list( - .train = function(inputs) { - list(private$.transform(inputs)) - }, - - .predict = function(inputs) { - list(private$.transform(inputs)) - }, - - .transform = function(...) stop("Abstract.") - ) -) diff --git a/R/pipelines.R b/R/pipelines.R index ffff3b68e..b61e0670b 100644 --- a/R/pipelines.R +++ b/R/pipelines.R @@ -330,207 +330,6 @@ pipeline_probregr = function(learner, learner_se = NULL, dist = "Uniform", create_grlrn(gr, graph_learner) } -#' @name mlr_graphs_survtoregr -#' @title Survival to Regression Reduction Pipeline -#' @description Wrapper around multiple [PipeOp][mlr3pipelines::PipeOp]s to help in creation -#' of complex survival reduction methods. Three reductions are currently implemented, -#' see details. -#' `r lifecycle::badge("experimental")` -#' -#' @details -#' Three reduction strategies are implemented, these are: -#' -#' \enumerate{ -#' \item Survival to Deterministic Regression A -#' \enumerate{ -#' \item [PipeOpTaskSurvRegr] Converts [TaskSurv] to [TaskRegr][mlr3::TaskRegr]. -#' \item A [LearnerRegr] is fit and predicted on the new `TaskRegr`. -#' \item [PipeOpPredRegrSurv] transforms the resulting [PredictionRegr][mlr3::PredictionRegr] -#' to [PredictionSurv]. -#' } -#' \item Survival to Probabilistic Regression -#' \enumerate{ -#' \item [PipeOpTaskSurvRegr] Converts [TaskSurv] to [TaskRegr][mlr3::TaskRegr]. -#' \item A [LearnerRegr] is fit on the new `TaskRegr` to predict `response`, optionally a second -#' `LearnerRegr` can be fit to predict `se`. -#' \item [PipeOpProbregr] composes a `distr` prediction from the learner(s). -#' \item [PipeOpPredRegrSurv] transforms the resulting [PredictionRegr][mlr3::PredictionRegr] -#' to [PredictionSurv]. -#' } -#' \item Survival to Deterministic Regression B -#' \enumerate{ -#' \item [PipeOpLearnerCV][mlr3pipelines::PipeOpLearnerCV] cross-validates and makes predictions from -#' a linear [LearnerSurv] with `lp` predict type on the original [TaskSurv]. -#' \item [PipeOpTaskSurvRegr] transforms the `lp` predictions into the target of a -#' [TaskRegr][mlr3::TaskRegr] with the same features as the original [TaskSurv]. -#' \item A [LearnerRegr] is fit and predicted on the new `TaskRegr`. -#' \item [PipeOpPredRegrSurv] transforms the resulting [PredictionRegr][mlr3::PredictionRegr] -#' to [PredictionSurv]. -#' \item Optionally: [PipeOpDistrCompositor] is used to compose a `distr` predict_type from the -#' predicted `lp` predict_type. -#' } -#' } -#' -#' Interpretation: -#' -#' 1. Once a dataset has censoring removed (by a given method) then a regression -#' learner can predict the survival time as the `response`. -#' 2. 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. -#' 3. 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. -#' -#' @param method (`integer(1)`)\cr -#' Reduction method to use, corresponds to those in `details`. Default is `1`. -#' @param regr_learner [LearnerRegr][mlr3::LearnerRegr]\cr -#' Regression learner to fit to the transformed [TaskRegr][mlr3::TaskRegr]. If `regr_se_learner` is -#' `NULL` in method `2`, then `regr_learner` must have `se` predict_type. -#' @param distrcompose (`logical(1)`)\cr -#' For method `3` if `TRUE` (default) then [PipeOpDistrCompositor] is utilised to -#' transform the deterministic predictions to a survival distribution. -#' @param distr_estimator [LearnerSurv]\cr -#' For methods `1` and `3` if `distrcompose = TRUE` then specifies the learner to estimate the -#' baseline hazard, must have predict_type `distr`. -#' @param regr_se_learner [LearnerRegr][mlr3::LearnerRegr]\cr -#' For method `2` if `regr_learner` is not used to predict the `se` then a `LearnerRegr` with `se` -#' predict_type must be provided. -#' @param surv_learner [LearnerSurv]\cr -#' For method `3`, a [LearnerSurv] with `lp` predict type to estimate linear predictors. -#' @param survregr_params (`list()`)\cr -#' Parameters passed to [PipeOpTaskSurvRegr], default are survival to regression transformation -#' via `ipcw`, with weighting determined by Kaplan-Meier and no additional penalty for censoring. -#' @param distrcompose_params (`list()`)\cr -#' Parameters passed to [PipeOpDistrCompositor], default is accelerated failure time model form. -#' @param probregr_params (`list()`)\cr -#' Parameters passed to [PipeOpProbregr], default is [Uniform][distr6::Uniform] -#' distribution for composition. -#' @param learnercv_params (`list()`)\cr -#' Parameters passed to [PipeOpLearnerCV][mlr3pipelines::PipeOpLearnerCV], default is to use -#' insampling. -#' @param graph_learner (`logical(1)`)\cr -#' If `TRUE` returns wraps the [Graph][mlr3pipelines::Graph] as a -#' [GraphLearner][mlr3pipelines::GraphLearner] otherwise (default) returns as a `Graph`. -#' -#' @examplesIf mlr3misc::require_namespaces(c("mlr3pipelines"), quietly = TRUE) -#' \dontrun{ -#' 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) -#' } -#' @export -pipeline_survtoregr = function(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) { - - if (method == 1) { - gr = Graph$new()$ - add_pipeop(po("nop", id = "task_surv"))$ - add_pipeop(po("trafotask_survregr", param_vals = survregr_params))$ - add_pipeop(po("learner", regr_learner, id = "regr_learner"))$ - add_pipeop(po("trafopred_regrsurv"))$ - add_edge("task_surv", "trafotask_survregr", dst_channel = "input")$ - add_edge("trafotask_survregr", "regr_learner")$ - add_edge("regr_learner", "trafopred_regrsurv", dst_channel = "pred")$ - add_edge("task_surv", "trafopred_regrsurv", dst_channel = "task") - } else if (method == 2) { - gr = Graph$new()$ - add_pipeop(po("nop", id = "task_surv"))$ - add_pipeop(po("trafotask_survregr", param_vals = survregr_params))$ - add_pipeop(po("compose_probregr", param_vals = probregr_params))$ - add_pipeop(po("trafopred_regrsurv"))$ - add_edge("compose_probregr", "trafopred_regrsurv", dst_channel = "pred")$ - add_edge("task_surv", "trafopred_regrsurv", dst_channel = "task") - - if (!is.null(regr_se_learner)) { - regr_se_learner$predict_type = "se" - - gr$add_pipeop(po("learner", regr_learner, id = "regr_learner"))$ - add_pipeop(po("learner", regr_se_learner, id = "regr_se_learner"))$ - add_edge("trafotask_survregr", "regr_se_learner")$ - add_edge("regr_se_learner", "compose_probregr", dst_channel = "input_se") - } else { - regr_learner$predict_type = "se" - gr$add_pipeop(po("learner", regr_learner, id = "regr_learner"))$ - add_edge("regr_learner", "compose_probregr", dst_channel = "input_se") - } - - gr$add_edge("trafotask_survregr", "regr_learner")$ - add_edge("regr_learner", "compose_probregr", dst_channel = "input_response") - - } else if (method == 3) { - assert("lp" %in% surv_learner$predict_types) - - gr = Graph$new()$ - add_pipeop(po("nop", id = "task_surv_train"))$ - add_pipeop(po("nop", id = "task_surv_predict"))$ - add_pipeop(po("learner_cv", surv_learner, id = "surv_learner", param_vals = learnercv_params))$ - add_pipeop(po("trafotask_survregr", method = "reorder", target = "surv_learner.lp"))$ - add_pipeop(po("learner", regr_learner, id = "regr_learner"))$ - add_pipeop(po("trafopred_regrsurv", target_type = "lp"))$ - add_edge("surv_learner", "trafotask_survregr", dst_channel = "input")$ - add_edge("task_surv_train", "trafotask_survregr", dst_channel = "input_features")$ - add_edge("trafotask_survregr", "regr_learner")$ - add_edge("regr_learner", "trafopred_regrsurv", dst_channel = "pred")$ - add_edge("task_surv_predict", "trafopred_regrsurv", dst_channel = "task") - - if (distrcompose) { - assert("distr" %in% distr_estimator$predict_types) - - gr$add_pipeop(po("learner", distr_estimator, id = "distr_estimator"))$ - add_pipeop(po("distrcompose", param_vals = distrcompose_params))$ - add_edge("trafopred_regrsurv", dst_id = "distrcompose", dst_channel = "pred")$ - add_edge("distr_estimator", dst_id = "distrcompose", dst_channel = "base") - } - } - - create_grlrn(gr, graph_learner) -} - #' @template pipeline #' @templateVar pipeop [PipeOpTaskSurvClassifDiscTime] and [PipeOpPredClassifSurvDiscTime] #' @templateVar id survtoclassif_disctime @@ -688,7 +487,6 @@ register_graph("crankcompositor", pipeline_crankcompositor) register_graph("distrcompositor", pipeline_distrcompositor) register_graph("responsecompositor", pipeline_responsecompositor) register_graph("probregr", pipeline_probregr) -register_graph("survtoregr", pipeline_survtoregr) register_graph("survtoclassif_disctime", pipeline_survtoclassif_disctime) register_graph("survtoclassif_IPCW", pipeline_survtoclassif_IPCW) register_graph("survtoclassif_vock", pipeline_survtoclassif_IPCW) # alias diff --git a/man/PipeOpPredTransformer.Rd b/man/PipeOpPredTransformer.Rd deleted file mode 100644 index 8dd916acd..000000000 --- a/man/PipeOpPredTransformer.Rd +++ /dev/null @@ -1,135 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/PipeOpPredTransformer.R -\name{PipeOpPredTransformer} -\alias{PipeOpPredTransformer} -\title{PipeOpPredTransformer} -\description{ -Parent class for \link[mlr3pipelines:PipeOp]{PipeOp}s that transform \link[mlr3:Prediction]{Prediction} -objects to different types. -} -\section{Input and Output Channels}{ - -\code{\link{PipeOpPredTransformer}} has one input and output channel named \code{"input"} and \code{"output"}. -In training and testing these expect and produce \link[mlr3:Prediction]{mlr3::Prediction} objects with the type -depending on the transformers. -} - -\section{State}{ - -The \verb{$state} is a named \code{list} with the \verb{$state} elements -\itemize{ -\item \code{inpredtypes}: Predict types in the input prediction object during training. -\item \code{outpredtypes} : Predict types in the input prediction object during prediction, checked -against \code{inpredtypes}. -} -} - -\section{Internals}{ - -Classes inheriting from \code{\link{PipeOpPredTransformer}} transform \link[mlr3:Prediction]{Prediction} -objects from one class (e.g. regr, classif) to another. -} - -\seealso{ -Other PipeOps: -\code{\link{PipeOpTaskTransformer}}, -\code{\link{PipeOpTransformer}}, -\code{\link{mlr_pipeops_survavg}}, -\code{\link{mlr_pipeops_trafopred_classifsurv_IPCW}}, -\code{\link{mlr_pipeops_trafopred_classifsurv_disctime}}, -\code{\link{mlr_pipeops_trafopred_regrsurv}}, -\code{\link{mlr_pipeops_trafopred_survregr}}, -\code{\link{mlr_pipeops_trafotask_regrsurv}}, -\code{\link{mlr_pipeops_trafotask_survclassif_IPCW}}, -\code{\link{mlr_pipeops_trafotask_survclassif_disctime}}, -\code{\link{mlr_pipeops_trafotask_survregr}} - -Other Transformers: -\code{\link{PipeOpTaskTransformer}}, -\code{\link{PipeOpTransformer}} -} -\concept{PipeOps} -\concept{Transformers} -\section{Super classes}{ -\code{\link[mlr3pipelines:PipeOp]{mlr3pipelines::PipeOp}} -> \code{\link[mlr3proba:PipeOpTransformer]{mlr3proba::PipeOpTransformer}} -> \code{PipeOpPredTransformer} -} -\section{Methods}{ -\subsection{Public methods}{ -\itemize{ -\item \href{#method-PipeOpPredTransformer-new}{\code{PipeOpPredTransformer$new()}} -\item \href{#method-PipeOpPredTransformer-clone}{\code{PipeOpPredTransformer$clone()}} -} -} -\if{html}{\out{ -
Inherited methods - -
-}} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-PipeOpPredTransformer-new}{}}} -\subsection{Method \code{new()}}{ -Creates a new instance of this \link[R6:R6Class]{R6} class. -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{PipeOpPredTransformer$new( - id, - param_set = ps(), - param_vals = list(), - packages = character(0), - input = data.table(), - output = data.table() -)}\if{html}{\out{
}} -} - -\subsection{Arguments}{ -\if{html}{\out{
}} -\describe{ -\item{\code{id}}{(\code{character(1)})\cr -Identifier of the resulting object.} - -\item{\code{param_set}}{(\link[paradox:ParamSet]{paradox::ParamSet})\cr -Set of hyperparameters.} - -\item{\code{param_vals}}{(\code{list()})\cr -List of hyperparameter settings, overwriting the hyperparameter settings that would -otherwise be set during construction.} - -\item{\code{packages}}{(\code{character()})\cr -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 \code{\link[=requireNamespace]{requireNamespace()}}.} - -\item{\code{input}}{\link[data.table:data.table]{data.table::data.table}\cr -\code{data.table} with columns \code{name} (\code{character}), \code{train} (\code{character}), \code{predict} (\code{character}). -Sets the \verb{$input} slot, see \link[mlr3pipelines:PipeOp]{PipeOp}.} - -\item{\code{output}}{\link[data.table:data.table]{data.table::data.table}\cr -\code{data.table} with columns \code{name} (\code{character}), \code{train} (\code{character}), \code{predict} (\code{character}). -Sets the \verb{$output} slot, see \link[mlr3pipelines:PipeOp]{PipeOp}.} -} -\if{html}{\out{
}} -} -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-PipeOpPredTransformer-clone}{}}} -\subsection{Method \code{clone()}}{ -The objects of this class are cloneable with this method. -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{PipeOpPredTransformer$clone(deep = FALSE)}\if{html}{\out{
}} -} - -\subsection{Arguments}{ -\if{html}{\out{
}} -\describe{ -\item{\code{deep}}{Whether to make a deep clone.} -} -\if{html}{\out{
}} -} -} -} diff --git a/man/PipeOpTaskTransformer.Rd b/man/PipeOpTaskTransformer.Rd deleted file mode 100644 index bcf0230f1..000000000 --- a/man/PipeOpTaskTransformer.Rd +++ /dev/null @@ -1,130 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/PipeOpTaskTransformer.R -\name{PipeOpTaskTransformer} -\alias{PipeOpTaskTransformer} -\title{PipeOpTaskTransformer} -\description{ -Parent class for \link[mlr3pipelines:PipeOp]{PipeOp}s that transform task objects to different types. -} -\section{Input and Output Channels}{ - -\code{\link{PipeOpTaskTransformer}} has one input and output channel named \code{"input"} and \code{"output"}. -In training and testing these expect and produce \link[mlr3:Task]{mlr3::Task} objects with the type depending on -the transformers. -} - -\section{State}{ - -The \verb{$state} is left empty (\code{list()}). -} - -\section{Internals}{ - -The commonality of methods using \code{\link{PipeOpTaskTransformer}} is that they take a \link[mlr3:Task]{mlr3::Task} of -one class and transform it to another class. This usually involves transformation of the data, -which can be controlled via parameters. -} - -\seealso{ -Other PipeOps: -\code{\link{PipeOpPredTransformer}}, -\code{\link{PipeOpTransformer}}, -\code{\link{mlr_pipeops_survavg}}, -\code{\link{mlr_pipeops_trafopred_classifsurv_IPCW}}, -\code{\link{mlr_pipeops_trafopred_classifsurv_disctime}}, -\code{\link{mlr_pipeops_trafopred_regrsurv}}, -\code{\link{mlr_pipeops_trafopred_survregr}}, -\code{\link{mlr_pipeops_trafotask_regrsurv}}, -\code{\link{mlr_pipeops_trafotask_survclassif_IPCW}}, -\code{\link{mlr_pipeops_trafotask_survclassif_disctime}}, -\code{\link{mlr_pipeops_trafotask_survregr}} - -Other Transformers: -\code{\link{PipeOpPredTransformer}}, -\code{\link{PipeOpTransformer}} -} -\concept{PipeOps} -\concept{Transformers} -\section{Super classes}{ -\code{\link[mlr3pipelines:PipeOp]{mlr3pipelines::PipeOp}} -> \code{\link[mlr3proba:PipeOpTransformer]{mlr3proba::PipeOpTransformer}} -> \code{PipeOpTaskTransformer} -} -\section{Methods}{ -\subsection{Public methods}{ -\itemize{ -\item \href{#method-PipeOpTaskTransformer-new}{\code{PipeOpTaskTransformer$new()}} -\item \href{#method-PipeOpTaskTransformer-clone}{\code{PipeOpTaskTransformer$clone()}} -} -} -\if{html}{\out{ -
Inherited methods - -
-}} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-PipeOpTaskTransformer-new}{}}} -\subsection{Method \code{new()}}{ -Creates a new instance of this \link[R6:R6Class]{R6} class. -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{PipeOpTaskTransformer$new( - id, - param_set = ps(), - param_vals = list(), - packages = character(0), - input, - output -)}\if{html}{\out{
}} -} - -\subsection{Arguments}{ -\if{html}{\out{
}} -\describe{ -\item{\code{id}}{(\code{character(1)})\cr -Identifier of the resulting object.} - -\item{\code{param_set}}{(\link[paradox:ParamSet]{paradox::ParamSet})\cr -Set of hyperparameters.} - -\item{\code{param_vals}}{(\code{list()})\cr -List of hyperparameter settings, overwriting the hyperparameter settings that would -otherwise be set during construction.} - -\item{\code{packages}}{(\code{character()})\cr -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 \code{\link[=requireNamespace]{requireNamespace()}}.} - -\item{\code{input}}{\link[data.table:data.table]{data.table::data.table}\cr -\code{data.table} with columns \code{name} (\code{character}), \code{train} (\code{character}), \code{predict} (\code{character}). -Sets the \verb{$input} slot, see \link[mlr3pipelines:PipeOp]{PipeOp}.} - -\item{\code{output}}{\link[data.table:data.table]{data.table::data.table}\cr -\code{data.table} with columns \code{name} (\code{character}), \code{train} (\code{character}), \code{predict} (\code{character}). -Sets the \verb{$output} slot, see \link[mlr3pipelines:PipeOp]{PipeOp}.} -} -\if{html}{\out{
}} -} -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-PipeOpTaskTransformer-clone}{}}} -\subsection{Method \code{clone()}}{ -The objects of this class are cloneable with this method. -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{PipeOpTaskTransformer$clone(deep = FALSE)}\if{html}{\out{
}} -} - -\subsection{Arguments}{ -\if{html}{\out{
}} -\describe{ -\item{\code{deep}}{Whether to make a deep clone.} -} -\if{html}{\out{
}} -} -} -} diff --git a/man/PipeOpTransformer.Rd b/man/PipeOpTransformer.Rd deleted file mode 100644 index 9e5131023..000000000 --- a/man/PipeOpTransformer.Rd +++ /dev/null @@ -1,129 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/PipeOpTransformer.R -\name{PipeOpTransformer} -\alias{PipeOpTransformer} -\title{PipeOpTransformer} -\description{ -Parent class for \link[mlr3pipelines:PipeOp]{PipeOp}s that transform \link[mlr3:Task]{Task} and \link[mlr3:Prediction]{Prediction} -objects to different types. -} -\section{Input and Output Channels}{ - -Determined by child classes. -} - -\section{State}{ - -The \verb{$state} is left empty (\code{list()}). -} - -\section{Internals}{ - -The commonality of methods using \link{PipeOpTransformer} is that they take a \link[mlr3:Task]{Task} -or \link[mlr3:Prediction]{Prediction} of one type (e.g. regr or classif) and transform it to -another type. -} - -\seealso{ -Other PipeOps: -\code{\link{PipeOpPredTransformer}}, -\code{\link{PipeOpTaskTransformer}}, -\code{\link{mlr_pipeops_survavg}}, -\code{\link{mlr_pipeops_trafopred_classifsurv_IPCW}}, -\code{\link{mlr_pipeops_trafopred_classifsurv_disctime}}, -\code{\link{mlr_pipeops_trafopred_regrsurv}}, -\code{\link{mlr_pipeops_trafopred_survregr}}, -\code{\link{mlr_pipeops_trafotask_regrsurv}}, -\code{\link{mlr_pipeops_trafotask_survclassif_IPCW}}, -\code{\link{mlr_pipeops_trafotask_survclassif_disctime}}, -\code{\link{mlr_pipeops_trafotask_survregr}} - -Other Transformers: -\code{\link{PipeOpPredTransformer}}, -\code{\link{PipeOpTaskTransformer}} -} -\concept{PipeOps} -\concept{Transformers} -\section{Super class}{ -\code{\link[mlr3pipelines:PipeOp]{mlr3pipelines::PipeOp}} -> \code{PipeOpTransformer} -} -\section{Methods}{ -\subsection{Public methods}{ -\itemize{ -\item \href{#method-PipeOpTransformer-new}{\code{PipeOpTransformer$new()}} -\item \href{#method-PipeOpTransformer-clone}{\code{PipeOpTransformer$clone()}} -} -} -\if{html}{\out{ -
Inherited methods - -
-}} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-PipeOpTransformer-new}{}}} -\subsection{Method \code{new()}}{ -Creates a new instance of this \link[R6:R6Class]{R6} class. -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{PipeOpTransformer$new( - id, - param_set = ps(), - param_vals = list(), - packages = character(), - input = data.table(), - output = data.table() -)}\if{html}{\out{
}} -} - -\subsection{Arguments}{ -\if{html}{\out{
}} -\describe{ -\item{\code{id}}{(\code{character(1)})\cr -Identifier of the resulting object.} - -\item{\code{param_set}}{(\link[paradox:ParamSet]{paradox::ParamSet})\cr -Set of hyperparameters.} - -\item{\code{param_vals}}{(\code{list()})\cr -List of hyperparameter settings, overwriting the hyperparameter settings that would -otherwise be set during construction.} - -\item{\code{packages}}{(\code{character()})\cr -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 \code{\link[=requireNamespace]{requireNamespace()}}.} - -\item{\code{input}}{\link[data.table:data.table]{data.table::data.table}\cr -\code{data.table} with columns \code{name} (\code{character}), \code{train} (\code{character}), \code{predict} (\code{character}). -Sets the \verb{$input} slot, see \link[mlr3pipelines:PipeOp]{PipeOp}.} - -\item{\code{output}}{\link[data.table:data.table]{data.table::data.table}\cr -\code{data.table} with columns \code{name} (\code{character}), \code{train} (\code{character}), \code{predict} (\code{character}). -Sets the \verb{$output} slot, see \link[mlr3pipelines:PipeOp]{PipeOp}.} -} -\if{html}{\out{
}} -} -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-PipeOpTransformer-clone}{}}} -\subsection{Method \code{clone()}}{ -The objects of this class are cloneable with this method. -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{PipeOpTransformer$clone(deep = FALSE)}\if{html}{\out{
}} -} - -\subsection{Arguments}{ -\if{html}{\out{
}} -\describe{ -\item{\code{deep}}{Whether to make a deep clone.} -} -\if{html}{\out{
}} -} -} -} diff --git a/man/mlr_graphs_survtoregr.Rd b/man/mlr_graphs_survtoregr.Rd deleted file mode 100644 index 30a23285f..000000000 --- a/man/mlr_graphs_survtoregr.Rd +++ /dev/null @@ -1,161 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/pipelines.R -\name{mlr_graphs_survtoregr} -\alias{mlr_graphs_survtoregr} -\alias{pipeline_survtoregr} -\title{Survival to Regression Reduction Pipeline} -\usage{ -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 -) -} -\arguments{ -\item{method}{(\code{integer(1)})\cr -Reduction method to use, corresponds to those in \code{details}. Default is \code{1}.} - -\item{regr_learner}{\link[mlr3:LearnerRegr]{LearnerRegr}\cr -Regression learner to fit to the transformed \link[mlr3:TaskRegr]{TaskRegr}. If \code{regr_se_learner} is -\code{NULL} in method \code{2}, then \code{regr_learner} must have \code{se} predict_type.} - -\item{distrcompose}{(\code{logical(1)})\cr -For method \code{3} if \code{TRUE} (default) then \link{PipeOpDistrCompositor} is utilised to -transform the deterministic predictions to a survival distribution.} - -\item{distr_estimator}{\link{LearnerSurv}\cr -For methods \code{1} and \code{3} if \code{distrcompose = TRUE} then specifies the learner to estimate the -baseline hazard, must have predict_type \code{distr}.} - -\item{regr_se_learner}{\link[mlr3:LearnerRegr]{LearnerRegr}\cr -For method \code{2} if \code{regr_learner} is not used to predict the \code{se} then a \code{LearnerRegr} with \code{se} -predict_type must be provided.} - -\item{surv_learner}{\link{LearnerSurv}\cr -For method \code{3}, a \link{LearnerSurv} with \code{lp} predict type to estimate linear predictors.} - -\item{survregr_params}{(\code{list()})\cr -Parameters passed to \link{PipeOpTaskSurvRegr}, default are survival to regression transformation -via \code{ipcw}, with weighting determined by Kaplan-Meier and no additional penalty for censoring.} - -\item{distrcompose_params}{(\code{list()})\cr -Parameters passed to \link{PipeOpDistrCompositor}, default is accelerated failure time model form.} - -\item{probregr_params}{(\code{list()})\cr -Parameters passed to \link{PipeOpProbregr}, default is \link[distr6:Uniform]{Uniform} -distribution for composition.} - -\item{learnercv_params}{(\code{list()})\cr -Parameters passed to \link[mlr3pipelines:mlr_pipeops_learner_cv]{PipeOpLearnerCV}, default is to use -insampling.} - -\item{graph_learner}{(\code{logical(1)})\cr -If \code{TRUE} returns wraps the \link[mlr3pipelines:Graph]{Graph} as a -\link[mlr3pipelines:mlr_learners_graph]{GraphLearner} otherwise (default) returns as a \code{Graph}.} -} -\description{ -Wrapper around multiple \link[mlr3pipelines:PipeOp]{PipeOp}s to help in creation -of complex survival reduction methods. Three reductions are currently implemented, -see details. -\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} -} -\details{ -Three reduction strategies are implemented, these are: - -\enumerate{ -\item Survival to Deterministic Regression A -\enumerate{ -\item \link{PipeOpTaskSurvRegr} Converts \link{TaskSurv} to \link[mlr3:TaskRegr]{TaskRegr}. -\item A \link{LearnerRegr} is fit and predicted on the new \code{TaskRegr}. -\item \link{PipeOpPredRegrSurv} transforms the resulting \link[mlr3:PredictionRegr]{PredictionRegr} -to \link{PredictionSurv}. -} -\item Survival to Probabilistic Regression -\enumerate{ -\item \link{PipeOpTaskSurvRegr} Converts \link{TaskSurv} to \link[mlr3:TaskRegr]{TaskRegr}. -\item A \link{LearnerRegr} is fit on the new \code{TaskRegr} to predict \code{response}, optionally a second -\code{LearnerRegr} can be fit to predict \code{se}. -\item \link{PipeOpProbregr} composes a \code{distr} prediction from the learner(s). -\item \link{PipeOpPredRegrSurv} transforms the resulting \link[mlr3:PredictionRegr]{PredictionRegr} -to \link{PredictionSurv}. -} -\item Survival to Deterministic Regression B -\enumerate{ -\item \link[mlr3pipelines:mlr_pipeops_learner_cv]{PipeOpLearnerCV} cross-validates and makes predictions from -a linear \link{LearnerSurv} with \code{lp} predict type on the original \link{TaskSurv}. -\item \link{PipeOpTaskSurvRegr} transforms the \code{lp} predictions into the target of a -\link[mlr3:TaskRegr]{TaskRegr} with the same features as the original \link{TaskSurv}. -\item A \link{LearnerRegr} is fit and predicted on the new \code{TaskRegr}. -\item \link{PipeOpPredRegrSurv} transforms the resulting \link[mlr3:PredictionRegr]{PredictionRegr} -to \link{PredictionSurv}. -\item Optionally: \link{PipeOpDistrCompositor} is used to compose a \code{distr} predict_type from the -predicted \code{lp} predict_type. -} -} - -Interpretation: -\enumerate{ -\item Once a dataset has censoring removed (by a given method) then a regression -learner can predict the survival time as the \code{response}. -\item 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. -\item 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. -} -} -\examples{ -\dontshow{if (mlr3misc::require_namespaces(c("mlr3pipelines"), quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} -\dontrun{ - 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) -} -\dontshow{\}) # examplesIf} -} diff --git a/man/mlr_pipeops_survavg.Rd b/man/mlr_pipeops_survavg.Rd index 1fee0908a..aa56240e5 100644 --- a/man/mlr_pipeops_survavg.Rd +++ b/man/mlr_pipeops_survavg.Rd @@ -57,18 +57,7 @@ Inherits from \link[mlr3pipelines:PipeOpEnsemble]{PipeOpEnsemble} by implementin \dontshow{\}) # examplesIf} } \seealso{ -Other PipeOps: -\code{\link{PipeOpPredTransformer}}, -\code{\link{PipeOpTaskTransformer}}, -\code{\link{PipeOpTransformer}}, -\code{\link{mlr_pipeops_trafopred_classifsurv_IPCW}}, -\code{\link{mlr_pipeops_trafopred_classifsurv_disctime}}, -\code{\link{mlr_pipeops_trafopred_regrsurv}}, -\code{\link{mlr_pipeops_trafopred_survregr}}, -\code{\link{mlr_pipeops_trafotask_regrsurv}}, -\code{\link{mlr_pipeops_trafotask_survclassif_IPCW}}, -\code{\link{mlr_pipeops_trafotask_survclassif_disctime}}, -\code{\link{mlr_pipeops_trafotask_survregr}} +\link{pipeline_survaverager} } \concept{Ensembles} \concept{PipeOps} diff --git a/man/mlr_pipeops_trafopred_classifsurv_IPCW.Rd b/man/mlr_pipeops_trafopred_classifsurv_IPCW.Rd index 5a5c356f8..2cc6dff55 100644 --- a/man/mlr_pipeops_trafopred_classifsurv_IPCW.Rd +++ b/man/mlr_pipeops_trafopred_classifsurv_IPCW.Rd @@ -47,29 +47,13 @@ Vock, M D, Wolfson, Julian, Bandyopadhyay, Sunayan, Adomavicius, Gediminas, John \doi{https://doi.org/10.1016/j.jbi.2016.03.009}, \url{https://www.sciencedirect.com/science/article/pii/S1532046416000496}. } \seealso{ -Other PipeOps: -\code{\link{PipeOpPredTransformer}}, -\code{\link{PipeOpTaskTransformer}}, -\code{\link{PipeOpTransformer}}, -\code{\link{mlr_pipeops_survavg}}, -\code{\link{mlr_pipeops_trafopred_classifsurv_disctime}}, -\code{\link{mlr_pipeops_trafopred_regrsurv}}, -\code{\link{mlr_pipeops_trafopred_survregr}}, -\code{\link{mlr_pipeops_trafotask_regrsurv}}, -\code{\link{mlr_pipeops_trafotask_survclassif_IPCW}}, -\code{\link{mlr_pipeops_trafotask_survclassif_disctime}}, -\code{\link{mlr_pipeops_trafotask_survregr}} +\link{pipeline_survtoclassif_IPCW} Other Transformation PipeOps: \code{\link{mlr_pipeops_trafopred_classifsurv_disctime}}, -\code{\link{mlr_pipeops_trafopred_regrsurv}}, -\code{\link{mlr_pipeops_trafopred_survregr}}, -\code{\link{mlr_pipeops_trafotask_regrsurv}}, \code{\link{mlr_pipeops_trafotask_survclassif_IPCW}}, -\code{\link{mlr_pipeops_trafotask_survclassif_disctime}}, -\code{\link{mlr_pipeops_trafotask_survregr}} +\code{\link{mlr_pipeops_trafotask_survclassif_disctime}} } -\concept{PipeOps} \concept{Transformation PipeOps} \section{Super class}{ \code{\link[mlr3pipelines:PipeOp]{mlr3pipelines::PipeOp}} -> \code{PipeOpPredClassifSurvIPCW} diff --git a/man/mlr_pipeops_trafopred_classifsurv_disctime.Rd b/man/mlr_pipeops_trafopred_classifsurv_disctime.Rd index a30fc3d4f..4a7db8b4c 100644 --- a/man/mlr_pipeops_trafopred_classifsurv_disctime.Rd +++ b/man/mlr_pipeops_trafopred_classifsurv_disctime.Rd @@ -48,29 +48,13 @@ Springer International Publishing. ISBN 978-3-319-28156-8 978-3-319-28158-2, \url{http://link.springer.com/10.1007/978-3-319-28158-2}. } \seealso{ -Other PipeOps: -\code{\link{PipeOpPredTransformer}}, -\code{\link{PipeOpTaskTransformer}}, -\code{\link{PipeOpTransformer}}, -\code{\link{mlr_pipeops_survavg}}, -\code{\link{mlr_pipeops_trafopred_classifsurv_IPCW}}, -\code{\link{mlr_pipeops_trafopred_regrsurv}}, -\code{\link{mlr_pipeops_trafopred_survregr}}, -\code{\link{mlr_pipeops_trafotask_regrsurv}}, -\code{\link{mlr_pipeops_trafotask_survclassif_IPCW}}, -\code{\link{mlr_pipeops_trafotask_survclassif_disctime}}, -\code{\link{mlr_pipeops_trafotask_survregr}} +\link{pipeline_survtoclassif_disctime} Other Transformation PipeOps: \code{\link{mlr_pipeops_trafopred_classifsurv_IPCW}}, -\code{\link{mlr_pipeops_trafopred_regrsurv}}, -\code{\link{mlr_pipeops_trafopred_survregr}}, -\code{\link{mlr_pipeops_trafotask_regrsurv}}, \code{\link{mlr_pipeops_trafotask_survclassif_IPCW}}, -\code{\link{mlr_pipeops_trafotask_survclassif_disctime}}, -\code{\link{mlr_pipeops_trafotask_survregr}} +\code{\link{mlr_pipeops_trafotask_survclassif_disctime}} } -\concept{PipeOps} \concept{Transformation PipeOps} \section{Super class}{ \code{\link[mlr3pipelines:PipeOp]{mlr3pipelines::PipeOp}} -> \code{PipeOpPredClassifSurvDiscTime} diff --git a/man/mlr_pipeops_trafopred_regrsurv.Rd b/man/mlr_pipeops_trafopred_regrsurv.Rd deleted file mode 100644 index 8805ce1d7..000000000 --- a/man/mlr_pipeops_trafopred_regrsurv.Rd +++ /dev/null @@ -1,143 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/PipeOpPredRegrSurv.R -\name{mlr_pipeops_trafopred_regrsurv} -\alias{mlr_pipeops_trafopred_regrsurv} -\alias{PipeOpPredRegrSurv} -\title{PipeOpPredRegrSurv} -\description{ -Transform \link{PredictionRegr} to \link{PredictionSurv}. -} -\section{Input and Output Channels}{ - -Input and output channels are inherited from \link{PipeOpPredTransformer}. - -The output is the input \link{PredictionRegr} transformed to a \link{PredictionSurv}. Censoring can be -added with the \code{status} hyper-parameter. \code{se} is ignored. -} - -\section{State}{ - -The \verb{$state} is a named \code{list} with the \verb{$state} elements inherited from \code{\link{PipeOpPredTransformer}}. -} - -\section{Parameters}{ - -The parameters are -\itemize{ -\item \verb{status :: (numeric(1))}\cr -If \code{NULL} then assumed no censoring in the dataset. Otherwise should be a vector of \code{0/1}s -of same length as the prediction object, where \code{1} is dead and \code{0} censored. -} -} - -\examples{ -\dontshow{if (mlr3misc::require_namespaces(c("mlr3pipelines"), quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} -\dontrun{ - 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()) -} -\dontshow{\}) # examplesIf} -} -\seealso{ -Other PipeOps: -\code{\link{PipeOpPredTransformer}}, -\code{\link{PipeOpTaskTransformer}}, -\code{\link{PipeOpTransformer}}, -\code{\link{mlr_pipeops_survavg}}, -\code{\link{mlr_pipeops_trafopred_classifsurv_IPCW}}, -\code{\link{mlr_pipeops_trafopred_classifsurv_disctime}}, -\code{\link{mlr_pipeops_trafopred_survregr}}, -\code{\link{mlr_pipeops_trafotask_regrsurv}}, -\code{\link{mlr_pipeops_trafotask_survclassif_IPCW}}, -\code{\link{mlr_pipeops_trafotask_survclassif_disctime}}, -\code{\link{mlr_pipeops_trafotask_survregr}} - -Other Transformation PipeOps: -\code{\link{mlr_pipeops_trafopred_classifsurv_IPCW}}, -\code{\link{mlr_pipeops_trafopred_classifsurv_disctime}}, -\code{\link{mlr_pipeops_trafopred_survregr}}, -\code{\link{mlr_pipeops_trafotask_regrsurv}}, -\code{\link{mlr_pipeops_trafotask_survclassif_IPCW}}, -\code{\link{mlr_pipeops_trafotask_survclassif_disctime}}, -\code{\link{mlr_pipeops_trafotask_survregr}} -} -\concept{PipeOps} -\concept{Transformation PipeOps} -\section{Super classes}{ -\code{\link[mlr3pipelines:PipeOp]{mlr3pipelines::PipeOp}} -> \code{\link[mlr3proba:PipeOpTransformer]{mlr3proba::PipeOpTransformer}} -> \code{\link[mlr3proba:PipeOpPredTransformer]{mlr3proba::PipeOpPredTransformer}} -> \code{PipeOpPredRegrSurv} -} -\section{Methods}{ -\subsection{Public methods}{ -\itemize{ -\item \href{#method-PipeOpPredRegrSurv-new}{\code{PipeOpPredRegrSurv$new()}} -\item \href{#method-PipeOpPredRegrSurv-clone}{\code{PipeOpPredRegrSurv$clone()}} -} -} -\if{html}{\out{ -
Inherited methods - -
-}} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-PipeOpPredRegrSurv-new}{}}} -\subsection{Method \code{new()}}{ -Creates a new instance of this \link[R6:R6Class]{R6} class. -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{PipeOpPredRegrSurv$new(id = "trafopred_regrsurv", param_vals = list())}\if{html}{\out{
}} -} - -\subsection{Arguments}{ -\if{html}{\out{
}} -\describe{ -\item{\code{id}}{(\code{character(1)})\cr -Identifier of the resulting object.} - -\item{\code{param_vals}}{(\code{list()})\cr -List of hyperparameter settings, overwriting the hyperparameter settings that would -otherwise be set during construction.} -} -\if{html}{\out{
}} -} -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-PipeOpPredRegrSurv-clone}{}}} -\subsection{Method \code{clone()}}{ -The objects of this class are cloneable with this method. -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{PipeOpPredRegrSurv$clone(deep = FALSE)}\if{html}{\out{
}} -} - -\subsection{Arguments}{ -\if{html}{\out{
}} -\describe{ -\item{\code{deep}}{Whether to make a deep clone.} -} -\if{html}{\out{
}} -} -} -} diff --git a/man/mlr_pipeops_trafopred_survregr.Rd b/man/mlr_pipeops_trafopred_survregr.Rd deleted file mode 100644 index edc4218ea..000000000 --- a/man/mlr_pipeops_trafopred_survregr.Rd +++ /dev/null @@ -1,119 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/PipeOpPredSurvRegr.R -\name{mlr_pipeops_trafopred_survregr} -\alias{mlr_pipeops_trafopred_survregr} -\alias{PipeOpPredSurvRegr} -\title{PipeOpPredSurvRegr} -\description{ -Transform \link{PredictionSurv} to \link{PredictionRegr}. -} -\section{Input and Output Channels}{ - -Input and output channels are inherited from \link{PipeOpPredTransformer}. - -The output is the input \link{PredictionSurv} transformed to a \link{PredictionRegr}. Censoring is ignored. -\code{crank} and \code{lp} predictions are also ignored. -} - -\section{State}{ - -The \verb{$state} is a named \code{list} with the \verb{$state} elements inherited from \link{PipeOpPredTransformer}. -} - -\examples{ -\dontshow{if (mlr3misc::require_namespaces(c("mlr3pipelines"), quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} -\dontrun{ - 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) -} -\dontshow{\}) # examplesIf} -} -\seealso{ -Other PipeOps: -\code{\link{PipeOpPredTransformer}}, -\code{\link{PipeOpTaskTransformer}}, -\code{\link{PipeOpTransformer}}, -\code{\link{mlr_pipeops_survavg}}, -\code{\link{mlr_pipeops_trafopred_classifsurv_IPCW}}, -\code{\link{mlr_pipeops_trafopred_classifsurv_disctime}}, -\code{\link{mlr_pipeops_trafopred_regrsurv}}, -\code{\link{mlr_pipeops_trafotask_regrsurv}}, -\code{\link{mlr_pipeops_trafotask_survclassif_IPCW}}, -\code{\link{mlr_pipeops_trafotask_survclassif_disctime}}, -\code{\link{mlr_pipeops_trafotask_survregr}} - -Other Transformation PipeOps: -\code{\link{mlr_pipeops_trafopred_classifsurv_IPCW}}, -\code{\link{mlr_pipeops_trafopred_classifsurv_disctime}}, -\code{\link{mlr_pipeops_trafopred_regrsurv}}, -\code{\link{mlr_pipeops_trafotask_regrsurv}}, -\code{\link{mlr_pipeops_trafotask_survclassif_IPCW}}, -\code{\link{mlr_pipeops_trafotask_survclassif_disctime}}, -\code{\link{mlr_pipeops_trafotask_survregr}} -} -\concept{PipeOps} -\concept{Transformation PipeOps} -\section{Super classes}{ -\code{\link[mlr3pipelines:PipeOp]{mlr3pipelines::PipeOp}} -> \code{\link[mlr3proba:PipeOpTransformer]{mlr3proba::PipeOpTransformer}} -> \code{\link[mlr3proba:PipeOpPredTransformer]{mlr3proba::PipeOpPredTransformer}} -> \code{PipeOpPredSurvRegr} -} -\section{Methods}{ -\subsection{Public methods}{ -\itemize{ -\item \href{#method-PipeOpPredSurvRegr-new}{\code{PipeOpPredSurvRegr$new()}} -\item \href{#method-PipeOpPredSurvRegr-clone}{\code{PipeOpPredSurvRegr$clone()}} -} -} -\if{html}{\out{ -
Inherited methods - -
-}} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-PipeOpPredSurvRegr-new}{}}} -\subsection{Method \code{new()}}{ -Creates a new instance of this \link[R6:R6Class]{R6} class. -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{PipeOpPredSurvRegr$new(id = "trafopred_survregr")}\if{html}{\out{
}} -} - -\subsection{Arguments}{ -\if{html}{\out{
}} -\describe{ -\item{\code{id}}{(\code{character(1)})\cr -Identifier of the resulting object.} -} -\if{html}{\out{
}} -} -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-PipeOpPredSurvRegr-clone}{}}} -\subsection{Method \code{clone()}}{ -The objects of this class are cloneable with this method. -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{PipeOpPredSurvRegr$clone(deep = FALSE)}\if{html}{\out{
}} -} - -\subsection{Arguments}{ -\if{html}{\out{
}} -\describe{ -\item{\code{deep}}{Whether to make a deep clone.} -} -\if{html}{\out{
}} -} -} -} diff --git a/man/mlr_pipeops_trafotask_regrsurv.Rd b/man/mlr_pipeops_trafotask_regrsurv.Rd deleted file mode 100644 index b4f0910e5..000000000 --- a/man/mlr_pipeops_trafotask_regrsurv.Rd +++ /dev/null @@ -1,135 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/PipeOpTaskRegrSurv.R -\name{mlr_pipeops_trafotask_regrsurv} -\alias{mlr_pipeops_trafotask_regrsurv} -\alias{PipeOpTaskRegrSurv} -\title{PipeOpTaskRegrSurv} -\description{ -Transform \link{TaskRegr} to \link{TaskSurv}. -} -\section{Input and Output Channels}{ - -Input and output channels are inherited from \link{PipeOpTaskTransformer}. - -The output is the input \link{TaskRegr} transformed to a \link{TaskSurv}. -} - -\section{State}{ - -The \verb{$state} is a named \code{list} with the \verb{$state} elements inherited from \link{PipeOpTaskTransformer}. -} - -\section{Parameters}{ - -The parameters are -\itemize{ -\item \verb{status :: (numeric(1))}\cr -If \code{NULL} then assumed no censoring in the dataset. Otherwise should be a vector of \code{0/1}s -of same length as the prediction object, where \code{1} is dead and \code{0} censored. -} -} - -\examples{ -\dontshow{if (mlr3misc::require_namespaces(c("mlr3pipelines"), quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} -\dontrun{ - 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() -} -\dontshow{\}) # examplesIf} -} -\seealso{ -Other PipeOps: -\code{\link{PipeOpPredTransformer}}, -\code{\link{PipeOpTaskTransformer}}, -\code{\link{PipeOpTransformer}}, -\code{\link{mlr_pipeops_survavg}}, -\code{\link{mlr_pipeops_trafopred_classifsurv_IPCW}}, -\code{\link{mlr_pipeops_trafopred_classifsurv_disctime}}, -\code{\link{mlr_pipeops_trafopred_regrsurv}}, -\code{\link{mlr_pipeops_trafopred_survregr}}, -\code{\link{mlr_pipeops_trafotask_survclassif_IPCW}}, -\code{\link{mlr_pipeops_trafotask_survclassif_disctime}}, -\code{\link{mlr_pipeops_trafotask_survregr}} - -Other Transformation PipeOps: -\code{\link{mlr_pipeops_trafopred_classifsurv_IPCW}}, -\code{\link{mlr_pipeops_trafopred_classifsurv_disctime}}, -\code{\link{mlr_pipeops_trafopred_regrsurv}}, -\code{\link{mlr_pipeops_trafopred_survregr}}, -\code{\link{mlr_pipeops_trafotask_survclassif_IPCW}}, -\code{\link{mlr_pipeops_trafotask_survclassif_disctime}}, -\code{\link{mlr_pipeops_trafotask_survregr}} -} -\concept{PipeOps} -\concept{Transformation PipeOps} -\section{Super classes}{ -\code{\link[mlr3pipelines:PipeOp]{mlr3pipelines::PipeOp}} -> \code{\link[mlr3proba:PipeOpTransformer]{mlr3proba::PipeOpTransformer}} -> \code{\link[mlr3proba:PipeOpTaskTransformer]{mlr3proba::PipeOpTaskTransformer}} -> \code{PipeOpTaskRegrSurv} -} -\section{Methods}{ -\subsection{Public methods}{ -\itemize{ -\item \href{#method-PipeOpTaskRegrSurv-new}{\code{PipeOpTaskRegrSurv$new()}} -\item \href{#method-PipeOpTaskRegrSurv-clone}{\code{PipeOpTaskRegrSurv$clone()}} -} -} -\if{html}{\out{ -
Inherited methods - -
-}} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-PipeOpTaskRegrSurv-new}{}}} -\subsection{Method \code{new()}}{ -Creates a new instance of this \link[R6:R6Class]{R6} class. -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{PipeOpTaskRegrSurv$new(id = "trafotask_regrsurv")}\if{html}{\out{
}} -} - -\subsection{Arguments}{ -\if{html}{\out{
}} -\describe{ -\item{\code{id}}{(\code{character(1)})\cr -Identifier of the resulting object.} -} -\if{html}{\out{
}} -} -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-PipeOpTaskRegrSurv-clone}{}}} -\subsection{Method \code{clone()}}{ -The objects of this class are cloneable with this method. -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{PipeOpTaskRegrSurv$clone(deep = FALSE)}\if{html}{\out{
}} -} - -\subsection{Arguments}{ -\if{html}{\out{
}} -\describe{ -\item{\code{deep}}{Whether to make a deep clone.} -} -\if{html}{\out{
}} -} -} -} diff --git a/man/mlr_pipeops_trafotask_survclassif_IPCW.Rd b/man/mlr_pipeops_trafotask_survclassif_IPCW.Rd index fddf5a5be..be486afb3 100644 --- a/man/mlr_pipeops_trafotask_survclassif_IPCW.Rd +++ b/man/mlr_pipeops_trafotask_survclassif_IPCW.Rd @@ -113,29 +113,13 @@ Vock, M D, Wolfson, Julian, Bandyopadhyay, Sunayan, Adomavicius, Gediminas, John \doi{https://doi.org/10.1016/j.jbi.2016.03.009}, \url{https://www.sciencedirect.com/science/article/pii/S1532046416000496}. } \seealso{ -Other PipeOps: -\code{\link{PipeOpPredTransformer}}, -\code{\link{PipeOpTaskTransformer}}, -\code{\link{PipeOpTransformer}}, -\code{\link{mlr_pipeops_survavg}}, -\code{\link{mlr_pipeops_trafopred_classifsurv_IPCW}}, -\code{\link{mlr_pipeops_trafopred_classifsurv_disctime}}, -\code{\link{mlr_pipeops_trafopred_regrsurv}}, -\code{\link{mlr_pipeops_trafopred_survregr}}, -\code{\link{mlr_pipeops_trafotask_regrsurv}}, -\code{\link{mlr_pipeops_trafotask_survclassif_disctime}}, -\code{\link{mlr_pipeops_trafotask_survregr}} +\link{pipeline_survtoclassif_IPCW} Other Transformation PipeOps: \code{\link{mlr_pipeops_trafopred_classifsurv_IPCW}}, \code{\link{mlr_pipeops_trafopred_classifsurv_disctime}}, -\code{\link{mlr_pipeops_trafopred_regrsurv}}, -\code{\link{mlr_pipeops_trafopred_survregr}}, -\code{\link{mlr_pipeops_trafotask_regrsurv}}, -\code{\link{mlr_pipeops_trafotask_survclassif_disctime}}, -\code{\link{mlr_pipeops_trafotask_survregr}} +\code{\link{mlr_pipeops_trafotask_survclassif_disctime}} } -\concept{PipeOps} \concept{Transformation PipeOps} \section{Super class}{ \code{\link[mlr3pipelines:PipeOp]{mlr3pipelines::PipeOp}} -> \code{PipeOpTaskSurvClassifIPCW} diff --git a/man/mlr_pipeops_trafotask_survclassif_disctime.Rd b/man/mlr_pipeops_trafotask_survclassif_disctime.Rd index fc6186024..02966e8d2 100644 --- a/man/mlr_pipeops_trafotask_survclassif_disctime.Rd +++ b/man/mlr_pipeops_trafotask_survclassif_disctime.Rd @@ -98,29 +98,13 @@ Springer International Publishing. ISBN 978-3-319-28156-8 978-3-319-28158-2, \url{http://link.springer.com/10.1007/978-3-319-28158-2}. } \seealso{ -Other PipeOps: -\code{\link{PipeOpPredTransformer}}, -\code{\link{PipeOpTaskTransformer}}, -\code{\link{PipeOpTransformer}}, -\code{\link{mlr_pipeops_survavg}}, -\code{\link{mlr_pipeops_trafopred_classifsurv_IPCW}}, -\code{\link{mlr_pipeops_trafopred_classifsurv_disctime}}, -\code{\link{mlr_pipeops_trafopred_regrsurv}}, -\code{\link{mlr_pipeops_trafopred_survregr}}, -\code{\link{mlr_pipeops_trafotask_regrsurv}}, -\code{\link{mlr_pipeops_trafotask_survclassif_IPCW}}, -\code{\link{mlr_pipeops_trafotask_survregr}} +\link{pipeline_survtoclassif_disctime} Other Transformation PipeOps: \code{\link{mlr_pipeops_trafopred_classifsurv_IPCW}}, \code{\link{mlr_pipeops_trafopred_classifsurv_disctime}}, -\code{\link{mlr_pipeops_trafopred_regrsurv}}, -\code{\link{mlr_pipeops_trafopred_survregr}}, -\code{\link{mlr_pipeops_trafotask_regrsurv}}, -\code{\link{mlr_pipeops_trafotask_survclassif_IPCW}}, -\code{\link{mlr_pipeops_trafotask_survregr}} +\code{\link{mlr_pipeops_trafotask_survclassif_IPCW}} } -\concept{PipeOps} \concept{Transformation PipeOps} \section{Super class}{ \code{\link[mlr3pipelines:PipeOp]{mlr3pipelines::PipeOp}} -> \code{PipeOpTaskSurvClassifDiscTime} diff --git a/man/mlr_pipeops_trafotask_survregr.Rd b/man/mlr_pipeops_trafotask_survregr.Rd deleted file mode 100644 index 60cc7ceff..000000000 --- a/man/mlr_pipeops_trafotask_survregr.Rd +++ /dev/null @@ -1,217 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/PipeOpTaskSurvRegr.R -\name{mlr_pipeops_trafotask_survregr} -\alias{mlr_pipeops_trafotask_survregr} -\alias{PipeOpTaskSurvRegr} -\title{PipeOpTaskSurvRegr} -\description{ -Transform \link{TaskSurv} to \link[mlr3:TaskRegr]{TaskRegr}. -} -\section{Input and Output Channels}{ - -Input and output channels are inherited from \link{PipeOpTaskTransformer}. - -The output is the input \link{TaskSurv} transformed to a \link[mlr3:TaskRegr]{TaskRegr}. -} - -\section{State}{ - -The \verb{$state} is a named \code{list} with the \verb{$state} elements -\itemize{ -\item \code{instatus}: Censoring status from input training task. -\item \code{outstatus} : Censoring status from input prediction task. -} -} - -\section{Parameters}{ - -The parameters are -\itemize{ -\item \code{method} :: \code{character(1)}\cr -Method to use for dealing with censoring. Options are \code{"ipcw"} (Vock et al., 2016): censoring -column is removed and a \code{weights} column is added, weights are inverse estimated survival -probability of the censoring distribution evaluated at survival time; -\code{"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; \code{"bj"} (Buckley and James, 1979): Buckley-James imputation assuming an AFT -model form, calls \link[bujar:bujar]{bujar::bujar}; \code{"delete"}: censored observations are deleted from the -data-set - should be used with caution if censoring is informative; \code{"omit"}: the censoring -status column is deleted - again should be used with caution; \code{"reorder"}: selects features and -targets and sets the target in the new task object. Note that \code{"mrl"} and \code{"ipcw"} will perform -worse with Type I censoring. -\item \code{estimator} :: \code{character(1)}\cr -Method for calculating censoring weights or mean residual lifetime in \code{"mrl"}, -current options are: \code{"kaplan"}: unconditional Kaplan-Meier estimator; -\code{"akritas"}: conditional non-parameteric nearest-neighbours estimator; -\code{"cox"}. -\item \code{alpha} :: \code{numeric(1)}\cr -When \code{ipcw} is used, optional hyper-parameter that adds an extra penalty to the weighting for -censored observations. If set to \code{0} then censored observations are given zero weight and -deleted, weighting only the non-censored observations. A weight for an observation is then -\eqn{(\delta + \alpha(1-\delta))/G(t)} where \eqn{\delta} is the censoring indicator. -\item \code{eps} :: \code{numeric(1)}\cr -Small value to replace \code{0} survival probabilities with in IPCW to prevent infinite weights. -\item \code{lambda} :: \code{numeric(1)}\cr -Nearest neighbours parameter for the \code{"akritas"} estimator in the \href{https://mlr3extralearners.mlr-org.com/}{mlr3extralearners package}, default \code{0.5}. -\item \verb{features, target} :: \code{character()}\cr -For \code{"reorder"} method, specify which columns become features and targets. -\item \verb{learner cneter, mimpu, iter.bj, max.cycle, mstop, nu}\cr -Passed to \link[bujar:bujar]{bujar::bujar}. -} -} - -\examples{ -\dontshow{if (mlr3misc::require_namespaces(c("mlr3pipelines"), quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} -\dontrun{ - 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) -} -\dontshow{\}) # examplesIf} -} -\references{ -Buckley, Jonathan, James, Ian (1979). -\dQuote{Linear Regression with Censored Data.} -\emph{Biometrika}, \bold{66}(3), 429--436. -\doi{10.2307/2335161}, \url{https://www.jstor.org/stable/2335161}. - -Klein, P J, Moeschberger, L M (2003). -\emph{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). -\dQuote{Adapting machine learning techniques to censored time-to-event health record data: A general-purpose approach using inverse probability of censoring weighting.} -\emph{Journal of Biomedical Informatics}, \bold{61}, 119--131. -\doi{https://doi.org/10.1016/j.jbi.2016.03.009}, \url{https://www.sciencedirect.com/science/article/pii/S1532046416000496}. -} -\seealso{ -Other PipeOps: -\code{\link{PipeOpPredTransformer}}, -\code{\link{PipeOpTaskTransformer}}, -\code{\link{PipeOpTransformer}}, -\code{\link{mlr_pipeops_survavg}}, -\code{\link{mlr_pipeops_trafopred_classifsurv_IPCW}}, -\code{\link{mlr_pipeops_trafopred_classifsurv_disctime}}, -\code{\link{mlr_pipeops_trafopred_regrsurv}}, -\code{\link{mlr_pipeops_trafopred_survregr}}, -\code{\link{mlr_pipeops_trafotask_regrsurv}}, -\code{\link{mlr_pipeops_trafotask_survclassif_IPCW}}, -\code{\link{mlr_pipeops_trafotask_survclassif_disctime}} - -Other Transformation PipeOps: -\code{\link{mlr_pipeops_trafopred_classifsurv_IPCW}}, -\code{\link{mlr_pipeops_trafopred_classifsurv_disctime}}, -\code{\link{mlr_pipeops_trafopred_regrsurv}}, -\code{\link{mlr_pipeops_trafopred_survregr}}, -\code{\link{mlr_pipeops_trafotask_regrsurv}}, -\code{\link{mlr_pipeops_trafotask_survclassif_IPCW}}, -\code{\link{mlr_pipeops_trafotask_survclassif_disctime}} -} -\concept{PipeOps} -\concept{Transformation PipeOps} -\section{Super classes}{ -\code{\link[mlr3pipelines:PipeOp]{mlr3pipelines::PipeOp}} -> \code{\link[mlr3proba:PipeOpTransformer]{mlr3proba::PipeOpTransformer}} -> \code{\link[mlr3proba:PipeOpTaskTransformer]{mlr3proba::PipeOpTaskTransformer}} -> \code{PipeOpTaskSurvRegr} -} -\section{Methods}{ -\subsection{Public methods}{ -\itemize{ -\item \href{#method-PipeOpTaskSurvRegr-new}{\code{PipeOpTaskSurvRegr$new()}} -\item \href{#method-PipeOpTaskSurvRegr-clone}{\code{PipeOpTaskSurvRegr$clone()}} -} -} -\if{html}{\out{ -
Inherited methods - -
-}} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-PipeOpTaskSurvRegr-new}{}}} -\subsection{Method \code{new()}}{ -Creates a new instance of this \link[R6:R6Class]{R6} class. -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{PipeOpTaskSurvRegr$new(id = "trafotask_survregr", param_vals = list())}\if{html}{\out{
}} -} - -\subsection{Arguments}{ -\if{html}{\out{
}} -\describe{ -\item{\code{id}}{(\code{character(1)})\cr -Identifier of the resulting object.} - -\item{\code{param_vals}}{(\code{list()})\cr -List of hyperparameter settings, overwriting the hyperparameter settings that would -otherwise be set during construction.} -} -\if{html}{\out{
}} -} -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-PipeOpTaskSurvRegr-clone}{}}} -\subsection{Method \code{clone()}}{ -The objects of this class are cloneable with this method. -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{PipeOpTaskSurvRegr$clone(deep = FALSE)}\if{html}{\out{
}} -} - -\subsection{Arguments}{ -\if{html}{\out{
}} -\describe{ -\item{\code{deep}}{Whether to make a deep clone.} -} -\if{html}{\out{
}} -} -} -} diff --git a/tests/testthat/test_survtoregr.R b/tests/testthat/test_survtoregr.R deleted file mode 100644 index 67443182f..000000000 --- a/tests/testthat/test_survtoregr.R +++ /dev/null @@ -1,52 +0,0 @@ -skip("Due to bugs in survtoregr methods") -test_that("resample survtoregr", { - grlrn = ppl("survtoregr", method = 1, distrcompose = FALSE, graph_learner = TRUE) - rr = resample(task, grlrn, rsmp("cv", folds = 2L)) - expect_numeric(rr$aggregate()) -}) - -test_that("survtoregr 1", { - pipe = ppl("survtoregr", method = 1) - expect_class(pipe, "Graph") - grlrn = ppl("survtoregr", method = 1, graph_learner = TRUE) - expect_class(grlrn, "GraphLearner") - p = grlrn$train(task)$predict(task) - expect_prediction_surv(p) - expect_true("response" %in% p$predict_types) -}) - -test_that("survtoregr 2", { - pipe = ppl("survtoregr", method = 2) - expect_class(pipe, "Graph") - pipe = ppl("survtoregr", method = 2, graph_learner = TRUE) - expect_class(pipe, "GraphLearner") - pipe$train(task) - p = pipe$predict(task) - expect_prediction_surv(p) - expect_true("distr" %in% p$predict_types) - - pipe = ppl("survtoregr", method = 2, regr_se_learner = lrn("regr.featureless"), - graph_learner = TRUE) - expect_class(pipe, "GraphLearner") - pipe$train(task) - p = pipe$predict(task) - expect_prediction_surv(p) - expect_true("distr" %in% p$predict_types) -}) - -test_that("survtoregr 3", { - pipe = ppl("survtoregr", method = 3, distrcompose = FALSE) - expect_class(pipe, "Graph") - pipe = ppl("survtoregr", method = 3, distrcompose = FALSE, graph_learner = TRUE) - expect_class(pipe, "GraphLearner") - suppressWarnings(pipe$train(task)) # suppress loglik warning - p = pipe$predict(task) - expect_prediction_surv(p) - - pipe = ppl("survtoregr", method = 3, distrcompose = TRUE, graph_learner = TRUE) - expect_class(pipe, "GraphLearner") - suppressWarnings(pipe$train(task)) # suppress loglik warning - p = pipe$predict(task) - expect_prediction_surv(p) - expect_true("distr" %in% p$predict_types) -}) diff --git a/tests/testthat/test_unload.R b/tests/testthat/test_unload.R index 2ca6fdd47..e9576fc6a 100644 --- a/tests/testthat/test_unload.R +++ b/tests/testthat/test_unload.R @@ -19,11 +19,9 @@ test_that("unloading leaves no trace", { # compose prediction types "crankcompose", "distrcompose", "responsecompose", "breslowcompose", # transform prediction type - "trafopred_classifsurv_disctime", "trafopred_survregr", "trafopred_regrsurv", - "trafopred_classifsurv_IPCW", + "trafopred_classifsurv_disctime", "trafopred_classifsurv_IPCW", # transform task type - "trafotask_regrsurv", "trafotask_survregr", "trafotask_survclassif_disctime", - "trafotask_survclassif_IPCW" + "trafotask_survclassif_disctime", "trafotask_survclassif_IPCW" ) expect_in(proba_pipeops, mlr_pipeops$keys()) @@ -34,7 +32,7 @@ test_that("unloading leaves no trace", { # compose prediction types "crankcompositor", "distrcompositor", "responsecompositor", # transform surv to other tasks - "survtoregr", "survtoclassif_disctime", "survtoclassif_IPCW", "survtoclassif_vock" + "survtoclassif_disctime", "survtoclassif_IPCW", "survtoclassif_vock" ) expect_in(proba_graphs, mlr_graphs$keys())