This object stores the predictions returned by a learner of class LearnerCompRisks.
The task_type is set to "cmprsk".
For accessing survival and hazard functions, as well as other complex methods from a LearnerCompRisks object is not possible atm.
See also
Other Prediction:
PredictionDens,
PredictionSurv
Super class
mlr3::Prediction -> PredictionCompRisks
Active bindings
- truth
- ( - Surv)
 True (observed) outcome.
- cif
- ( - list())
 Access the stored CIFs.
Methods
Method new()
Creates a new instance of this R6 class.
Usage
PredictionCompRisks$new(
  task = NULL,
  row_ids = task$row_ids,
  truth = task$truth(),
  cif = NULL,
  check = TRUE
)Arguments
- task
- (TaskSurv) 
 Task, used to extract defaults for- row_idsand- truth.
- row_ids
- ( - integer())
 Row ids of the predicted observations, i.e. the row ids of the test set.
- truth
- ( - survival::Surv())
 True (observed) response.
- cif
- ( - list())
 A- listof two or more- matrixobjects. Each matrix represents a different competing event and it stores the Cumulative Incidence function for each test observation. In each matrix, rows represent observations and columns time points. The names of the- listmust correspond to the competing event names (- task$cmp_events).
- check
- ( - logical(1))
 If- TRUE, performs argument checks and predict type conversions.
Examples
library(mlr3)
task = tsk("pbc")
learner = lrn("cmprsk.aalen")
part = partition(task)
p = learner$train(task, part$train)$predict(task, part$test)
p
#> 
#> ── <PredictionCompRisks> for 91 observations: ──────────────────────────────────
#>  row_ids time event       CIF
#>        1   13     2 <list[2]>
#>        6   60     0 <list[2]>
#>       18   44     2 <list[2]>
#>      ---  ---   ---       ---
#>      264   42     0 <list[2]>
#>      269   39     0 <list[2]>
#>      275   27     0 <list[2]>
# CIF list: 1 matrix (obs x times) per competing event
names(p$cif) # competing events
#> [1] "1" "2"
# CIF matrix for competing event 1 (first 5 test observations and 20 time points)
p$cif[["1"]][1:5, 1:20]
#>      1 2 4 6 7 9 10 11 12 16          17          18          19          20
#> [1,] 0 0 0 0 0 0  0  0  0  0 0.005405405 0.005405405 0.005405405 0.005405405
#> [2,] 0 0 0 0 0 0  0  0  0  0 0.005405405 0.005405405 0.005405405 0.005405405
#> [3,] 0 0 0 0 0 0  0  0  0  0 0.005405405 0.005405405 0.005405405 0.005405405
#> [4,] 0 0 0 0 0 0  0  0  0  0 0.005405405 0.005405405 0.005405405 0.005405405
#> [5,] 0 0 0 0 0 0  0  0  0  0 0.005405405 0.005405405 0.005405405 0.005405405
#>               22         24         25         26         27         28
#> [1,] 0.005405405 0.01081081 0.01081081 0.01081081 0.01624979 0.02168877
#> [2,] 0.005405405 0.01081081 0.01081081 0.01081081 0.01624979 0.02168877
#> [3,] 0.005405405 0.01081081 0.01081081 0.01081081 0.01624979 0.02168877
#> [4,] 0.005405405 0.01081081 0.01081081 0.01081081 0.01624979 0.02168877
#> [5,] 0.005405405 0.01081081 0.01081081 0.01081081 0.01624979 0.02168877
# CIF matrix for competing event 2 (first 5 test observations and 20 time points)
p$cif[["2"]][1:5, 1:20]
#>               1          2          4          6          7          9
#> [1,] 0.01081081 0.02162162 0.03243243 0.04324324 0.04864865 0.05405405
#> [2,] 0.01081081 0.02162162 0.03243243 0.04324324 0.04864865 0.05405405
#> [3,] 0.01081081 0.02162162 0.03243243 0.04324324 0.04864865 0.05405405
#> [4,] 0.01081081 0.02162162 0.03243243 0.04324324 0.04864865 0.05405405
#> [5,] 0.01081081 0.02162162 0.03243243 0.04324324 0.04864865 0.05405405
#>              10         11         12         16         17         18
#> [1,] 0.05945946 0.06486486 0.07027027 0.07567568 0.07567568 0.08108108
#> [2,] 0.05945946 0.06486486 0.07027027 0.07567568 0.07567568 0.08108108
#> [3,] 0.05945946 0.06486486 0.07027027 0.07567568 0.07567568 0.08108108
#> [4,] 0.05945946 0.06486486 0.07027027 0.07567568 0.07567568 0.08108108
#> [5,] 0.05945946 0.06486486 0.07027027 0.07567568 0.07567568 0.08108108
#>              19         20        22        24        25        26        27
#> [1,] 0.08648649 0.09189189 0.0972973 0.1027027 0.1135135 0.1189525 0.1189525
#> [2,] 0.08648649 0.09189189 0.0972973 0.1027027 0.1135135 0.1189525 0.1189525
#> [3,] 0.08648649 0.09189189 0.0972973 0.1027027 0.1135135 0.1189525 0.1189525
#> [4,] 0.08648649 0.09189189 0.0972973 0.1027027 0.1135135 0.1189525 0.1189525
#> [5,] 0.08648649 0.09189189 0.0972973 0.1027027 0.1135135 0.1189525 0.1189525
#>             28
#> [1,] 0.1298305
#> [2,] 0.1298305
#> [3,] 0.1298305
#> [4,] 0.1298305
#> [5,] 0.1298305
# data.table conversion
tab = as.data.table(p)
tab$CIF[[1]] # for first test observation, list of CIF vectors
#> $`1`
#>           1           2           4           6           7           9 
#> 0.000000000 0.000000000 0.000000000 0.000000000 0.000000000 0.000000000 
#>          10          11          12          16          17          18 
#> 0.000000000 0.000000000 0.000000000 0.000000000 0.005405405 0.005405405 
#>          19          20          22          24          25          26 
#> 0.005405405 0.005405405 0.005405405 0.010810811 0.010810811 0.010810811 
#>          27          28          29          30          31          32 
#> 0.016249790 0.021688770 0.027127749 0.027127749 0.027127749 0.027127749 
#>          33          35          37          38          39          40 
#> 0.027127749 0.038224746 0.038224746 0.038224746 0.038224746 0.038224746 
#>          41          42          43          44          46          47 
#> 0.038224746 0.038224746 0.038224746 0.038224746 0.038224746 0.044505371 
#>          48          49          50          51          53          54 
#> 0.044505371 0.050895708 0.057286045 0.057286045 0.057286045 0.057286045 
#>          55          57          58          60          61          62 
#> 0.057286045 0.057286045 0.057286045 0.057286045 0.057286045 0.057286045 
#>          63          64          66          67          69          70 
#> 0.057286045 0.057286045 0.057286045 0.057286045 0.057286045 0.057286045 
#>          71          72          73          74          75          76 
#> 0.057286045 0.057286045 0.057286045 0.057286045 0.057286045 0.057286045 
#>          77          78          79          80          81          83 
#> 0.057286045 0.057286045 0.057286045 0.057286045 0.075731410 0.075731410 
#>          84          85          86          87          89          90 
#> 0.075731410 0.075731410 0.075731410 0.075731410 0.075731410 0.075731410 
#>          91          93          94          96          97          98 
#> 0.075731410 0.075731410 0.075731410 0.075731410 0.075731410 0.075731410 
#>         100         101         103         104         106         107 
#> 0.075731410 0.075731410 0.075731410 0.075731410 0.075731410 0.075731410 
#>         108         109         110         111         112         117 
#> 0.075731410 0.075731410 0.075731410 0.075731410 0.075731410 0.075731410 
#>         118         120         123         125         126         128 
#> 0.075731410 0.075731410 0.075731410 0.075731410 0.075731410 0.075731410 
#>         129         131         132         133         134         135 
#> 0.075731410 0.075731410 0.075731410 0.075731410 0.075731410 0.075731410 
#>         137         139         143         145         147         149 
#> 0.075731410 0.075731410 0.075731410 0.075731410 0.075731410 0.075731410 
#> 
#> $`2`
#>          1          2          4          6          7          9         10 
#> 0.01081081 0.02162162 0.03243243 0.04324324 0.04864865 0.05405405 0.05945946 
#>         11         12         16         17         18         19         20 
#> 0.06486486 0.07027027 0.07567568 0.07567568 0.08108108 0.08648649 0.09189189 
#>         22         24         25         26         27         28         29 
#> 0.09729730 0.10270270 0.11351351 0.11895249 0.11895249 0.12983045 0.14070841 
#>         30         31         32         33         35         37         38 
#> 0.14070841 0.14618317 0.14618317 0.15169443 0.16833993 0.17388843 0.18514395 
#>         39         40         41         42         43         44         46 
#> 0.20202724 0.20202724 0.20202724 0.20202724 0.20202724 0.20202724 0.21438087 
#>         47         48         49         50         51         53         54 
#> 0.22066149 0.22699626 0.22699626 0.22699626 0.23344417 0.23344417 0.23344417 
#>         55         57         58         60         61         62         63 
#> 0.24019912 0.24701965 0.25384019 0.26804377 0.26804377 0.26804377 0.27545773 
#>         64         66         67         69         70         71         72 
#> 0.27545773 0.27545773 0.28340125 0.29134478 0.29134478 0.29134478 0.29134478 
#>         73         74         75         76         77         78         79 
#> 0.29134478 0.29969567 0.31639744 0.31639744 0.31639744 0.33429220 0.34323958 
#>         80         81         83         84         85         86         87 
#> 0.34323958 0.35246226 0.36168494 0.37122026 0.38109612 0.38109612 0.38109612 
#>         89         90         91         93         94         96         97 
#> 0.38109612 0.39154175 0.40198737 0.41264617 0.41264617 0.41264617 0.41264617 
#>         98        100        101        103        104        106        107 
#> 0.41264617 0.41264617 0.43700914 0.43700914 0.44983176 0.46265438 0.47584335 
#>        108        109        110        111        112        117        118 
#> 0.47584335 0.47584335 0.48985664 0.50386993 0.51836644 0.54843326 0.54843326 
#>        120        123        125        126        128        129        131 
#> 0.54843326 0.56633018 0.56633018 0.60400791 0.60400791 0.60400791 0.60400791 
#>        132        133        134        135        137        139        143 
#> 0.60400791 0.60400791 0.63312252 0.63312252 0.66547208 0.66547208 0.66547208 
#>        145        147        149 
#> 0.66547208 0.66547208 0.66547208 
#>