mlr3pipelines
mlr3pipelines copied to clipboard
`PipeOpUpdateTarget` doesn't work for survival tasks with 2 target columns
library(mlr3proba)
#> Loading required package: mlr3
task = tsk('lung')
trgs = task$data(cols = task$target_names)
trgs
#> time status
#> 1: 306 TRUE
#> 2: 455 TRUE
#> 3: 1010 FALSE
#> 4: 210 TRUE
#> 5: 883 TRUE
#> ---
#> 224: 188 FALSE
#> 225: 191 FALSE
#> 226: 105 FALSE
#> 227: 174 FALSE
#> 228: 177 FALSE
trafo_fun = function(x) {
x$time = ceiling(x$time / 7) # change time from days to weeks
x
}
trafo_fun(trgs) # works
#> time status
#> 1: 44 TRUE
#> 2: 65 TRUE
#> 3: 145 FALSE
#> 4: 30 TRUE
#> 5: 127 TRUE
#> ---
#> 224: 27 FALSE
#> 225: 28 FALSE
#> 226: 15 FALSE
#> 227: 25 FALSE
#> 228: 26 FALSE
pout = mlr3pipelines:::PipeOpUpdateTarget$new(param_vals = list(trafo = trafo_fun))
pout$train(list(task)) # doesn't work
#> Error in initialize(...): unused argument (target = c("time", "status"))
#> This happened PipeOp update_target's $train()
Created on 2023-09-05 with reprex v2.0.2