tuneRanger icon indicating copy to clipboard operation
tuneRanger copied to clipboard

How to use tuneRanger with makeSurvTask

Open sibipx opened this issue 1 year ago • 1 comments

Hi!

I used tuneRanger for binary and multiclass classification and I am happy with the results and the performance of the package. I would like to use it for survival problems as well.

The help page says "task The mlr task created by makeClassifTask, makeRegrTask or makeSurvTask." I don't seem to be able to make it work. A simple example below:

library(survival)
library(tuneRanger)

head(lung)

lung$status <- ifelse(lung$status == 2, 1, 0)
lung <- lung[complete.cases(lung),]

# build model
#measure <- list(auc)
measure <- NULL
task <- makeSurvTask(data = lung,
                     target = c("time", "status"))

parameters <- list(replace = TRUE)

res <- tuneRanger(task, measure = measure,
                  num.trees = 500, 
                  iters = 20, 
                  show.info = TRUE,
                  tune.parameters = c("mtry", "min.node.size"),
                  parameters = parameters)

gives me error below:

Computing y column(s) for design. Not provided. Error in UseMethod("getOOBPredsLearner") : no applicable method for 'getOOBPredsLearner' applied to an object of class "c('surv.ranger', 'RLearnerSurv', 'RLearner', 'Learner')"

Thanks for any help on this!

sibipx avatar Aug 01 '23 13:08 sibipx

Sorry for the late response. It would be needed to write a getOOBPredsLearner.surv.ranger like here.

https://github.com/mlr-org/mlr/blob/main/R/RLearner_regr_ranger.R

This does not exist yet.

PhilippPro avatar May 15 '24 14:05 PhilippPro