This task specializes mlr3::Task and mlr3::TaskSupervised for possibly-censored survival problems. The target is comprised of survival times and an event indicator. Predefined tasks are stored in mlr3::mlr_tasks.

The task_type is set to "surv".

Format

R6::R6Class object inheriting from Task/TaskSupervised.

Construction

TaskSurv$new(id, backend, time, time2,
  event = c("right","left", "counting","interval","interval2","mstate"))
  • id :: character(1)
    Name of the task.

  • backend :: DataBackend

  • time :: numeric()
    Event time if data is right censored. Starting time if interval censored.

  • time2 :: numeric()
    Ending time for interval censored data. Ignored otherwise.

  • event :: integer() | logical()
    Event indicator. If data is right censored then "0"/FALSE means alive (no event), "1"/TRUE means dead (event). If type is "interval" then "0" means right censored, "1" means dead (event), "2" means left censored, and "3" means interval censored. If type is "interval2" then event is ignored.

  • type :: character()
    Type of censoring. Default is 'right' censoring.

Fields

All fields from mlr3::TaskSupervised, and additionally:

  • censtype :: character()
    Returns the type of censoring, one of "right", "left", "counting", "interval", "interval2" or "mstate".

Methods

See mlr3::TaskSupervised.

Examples

library(mlr3) lung = mlr3misc::load_dataset("lung", package = "survival") lung$status = (lung$status == 2L) b = as_data_backend(lung) task = TaskSurv$new("lung", backend = b, time = "time", event = "status") task$target_names
#> [1] "time" "status"
task$feature_names
#> [1] "age" "inst" "meal.cal" "pat.karno" "ph.ecog" "ph.karno" #> [7] "sex" "wt.loss"
task$formula()
#> Surv(time, status, type = "right") ~ . #> <environment: namespace:survival>
task$truth()
#> [1] 306 455 1010+ 210 883 1022+ 310 361 218 166 170 654 #> [13] 728 71 567 144 613 707 61 88 301 81 624 371 #> [25] 394 520 574 118 390 12 473 26 533 107 53 122 #> [37] 814 965+ 93 731 460 153 433 145 583 95 303 519 #> [49] 643 765 735 189 53 246 689 65 5 132 687 345 #> [61] 444 223 175 60 163 65 208 821+ 428 230 840+ 305 #> [73] 11 132 226 426 705 363 11 176 791 95 196+ 167 #> [85] 806+ 284 641 147 740+ 163 655 239 88 245 588+ 30 #> [97] 179 310 477 166 559+ 450 364 107 177 156 529+ 11 #> [109] 429 351 15 181 283 201 524 13 212 524 288 363 #> [121] 442 199 550 54 558 207 92 60 551+ 543+ 293 202 #> [133] 353 511+ 267 511+ 371 387 457 337 201 404+ 222 62 #> [145] 458+ 356+ 353 163 31 340 229 444+ 315+ 182 156 329 #> [157] 364+ 291 179 376+ 384+ 268 292+ 142 413+ 266+ 194 320 #> [169] 181 285 301+ 348 197 382+ 303+ 296+ 180 186 145 269+ #> [181] 300+ 284+ 350 272+ 292+ 332+ 285 259+ 110 286 270 81 #> [193] 131 225+ 269 225+ 243+ 279+ 276+ 135 79 59 240+ 202+ #> [205] 235+ 105 224+ 239 237+ 173+ 252+ 221+ 185+ 92+ 13 222+ #> [217] 192+ 183 211+ 175+ 197+ 203+ 116 188+ 191+ 105+ 174+ 177+