Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

survival learner issues in via mlr3 #49

Closed
bblodfon opened this issue Apr 11, 2024 · 6 comments
Closed

survival learner issues in via mlr3 #49

bblodfon opened this issue Apr 11, 2024 · 6 comments

Comments

@bblodfon
Copy link

Hi Byron,

Just tried to use aorsf with survival data via mlr3extralearners and got this error:

library(mlr3extralearners)
library(mlr3pipelines)
library(mlr3proba)
#> Loading required package: mlr3

task = tsk('lung')
pre = po('encode', method = 'treatment') %>>%
  po('imputelearner', lrn('regr.rpart'))
task = pre$train(task)[[1]]
task
#> <TaskSurv:lung> (228 x 10): Lung Cancer
#> * Target: time, status
#> * Properties: -
#> * Features (8):
#>   - int (7): age, inst, meal.cal, pat.karno, ph.ecog, ph.karno, wt.loss
#>   - dbl (1): sex

aorsf = lrn('surv.aorsf', control_type = 'fast',
  oobag_pred_type = 'surv', importance = 'anova',
  attach_data = TRUE)

aorsf$train(task)
#> Error: some variables have unsupported type:
#>  <status> has type <logical>
#> supported types are numeric, integer, units, factor, and Surv
aorsf$errors
#> character(0)

Created on 2024-04-11 with reprex v2.0.2

Maybe you haven't updated it with recent changes? I see for example that the oobag_pred_type default is risk now, not surv.

@bblodfon
Copy link
Author

bblodfon commented Apr 11, 2024

Btw is the mort prediction type the same as in RSFs? Eg adding the cumulative hazard for all time points for each observation? Something like:

cumH = -log(surv_matrix) # surv_mat is (obs x times)
cumH[cumH == Inf] <- 0
rowSums(cumH)

PS: I think it is so after looking a bit at the doc and running some examples, but good to verify it form you!

I am using the oobag error for wrapped-based feature selection with aorsf via mlr3extralearners and I think that using mort as a default oob_pred_type might be the best option as it is time-independent, rather than calculating the C-index on the median survival time that is the default now. What do you think?

@bcjaeger
Copy link
Collaborator

Hi John, great questions!

  1. The error you received is due to status being a logical variable. I wrote that feature a long time ago and it seems kind of unnecessary now. Would it be helpful if I made a small patch in aorsf so that logical variables are converted to numeric 0/1 integer-type variables?
  2. You caught me. I made the change to default risk when growing trees. It always bugged me that the default oobag prediction type in aorsf was survival while the default predict type was risk. I am sorry if this caused backward compatibility issues. =[
  3. Yes, mort is intended to match the mortality prediction in RSF. I agree with using mort to guide variable selection. In fact, mort is automatically used in aorsf's built-in variable selection function: orsf_vs

@bblodfon
Copy link
Author

  1. Yes please! It make sense with status, only a few datasets have TRUE/FALSE instead of an integer 0 or 1 and if you want to go multi event in the future, checking/converting to integer is the way to go.
  2. Haha yes, let's just make sure everything is updated when you have the time in mlr3extralearners, I can double-check the PR if you want. Including the response = rmst prediction could be also included as an extra that would be nice.
  3. Super

I will be heavily using aorsf soon and I was glad to find other things to be solved. There was some C++ issue when running with extremely large datasets (~30K features) if I find it again, I will let you know!

@bcjaeger
Copy link
Collaborator

I will be heavily using aorsf soon

This absolutely made my day. Thank you!!

I will get to work on the patch and the addition of rmst in mlr3extralearners soon (sorry I have been slow on the rmst PR - it is on my short list of priorities now).

@bblodfon
Copy link
Author

Hi @bcjaeger! Would you have time to quickly look and update the PR in mlr3extralearners?

@bblodfon
Copy link
Author

I updated the tsk("lung") of mlr3proba to encode status as 0/1 so the original issue is no longer present.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants