mlr-org / mlr3proba

Probabilistic Learning for mlr3
https://mlr3proba.mlr-org.com
GNU Lesser General Public License v3.0
126 stars 20 forks source link

New error exclusively for survival analysis #361

Closed beiwo07 closed 7 months ago

beiwo07 commented 7 months ago

Hi there, I have been having an error using mlr3 for survival analysis. I used the same code to successfully run survival analyses several months ago. May it be related to package updates? I tested with classification and regression tasks and they run fine, so I wonder if it's just with mlr3proba?

Error msg:

INFO  [08:03:37.957] [bbotk] Starting to optimize 1 parameter(s) with '<TunerGridSearch>' and '<TerminatorNone>'
INFO  [08:03:37.962] [bbotk] Evaluating 1 configuration(s)
INFO  [08:03:37.977] [mlr3] Running benchmark with 3 resampling iterations
INFO  [08:03:38.048] [mlr3] Applying learner 'surv.cv_glmnet' on task 'df' (iter 1/3)
INFO  [08:03:38.197] [mlr3] Applying learner 'surv.cv_glmnet' on task 'df' (iter 2/3)
INFO  [08:03:38.319] [mlr3] Applying learner 'surv.cv_glmnet' on task 'df' (iter 3/3)
Error in h(simpleError(msg, call)) : 
  error in evaluating the argument 'x' in selecting a method for function 'as.matrix': non-conformable arguments

Reproducible code:

library(dplyr)
library(survival)
library(survival)
library(glmnet)
library(mlr3)
library(mlr3proba)
library(mlr3tuning)
library(mlr3extralearners)

df<- survival::rats2
task<- as_task_surv(df, time= "time1", event="status")
measure<-  msr("surv.cindex")
cv<- rsmp("cv", folds=3)
alpha_vals<- seq(0,1,by=0.2)
tuner<- tnr("grid_search")
learner<- lrn("surv.cv_glmnet", 
             alpha= to_tune(c(alpha_vals)), 
             alignment= "lambda")
instance<- mlr3tuning::tune(
  tuner = tuner, 
  task = task, 
  learner = learner, 
  resampling = cv, 
  measure= measure
)

Session info

R version 4.3.2 (2023-10-31)
Platform: x86_64-apple-darwin20 (64-bit)
Running under: macOS Ventura 13.4

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: America/Chicago
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] mlr3learners_0.5.8      devtools_2.4.5          usethis_2.2.2           mlr3extralearners_0.7.0 mlr3tuning_0.19.2      
 [6] paradox_0.11.1          mlr3proba_0.5.7         mlr3_0.17.2             glmnet_4.1-8            Matrix_1.6-5           
[11] lubridate_1.9.3         forcats_1.0.0           stringr_1.5.1           readr_2.1.5             tidyverse_2.0.0        
[16] yardstick_1.3.0         workflowsets_1.0.1      workflows_1.1.3         tune_1.1.2              tidyr_1.3.1            
[21] tibble_3.2.1            rsample_1.2.0           recipes_1.0.9           purrr_1.0.2             parsnip_1.1.1          
[26] modeldata_1.3.0         infer_1.0.5             ggplot2_3.4.4           dials_1.2.0             scales_1.3.0           
[31] broom_1.0.5             tidymodels_1.1.1        survival_3.5-7          dplyr_1.1.4            

loaded via a namespace (and not attached):
  [1] rstudioapi_0.15.0     shape_1.4.6           magrittr_2.0.3        ooplah_0.2.0          fs_1.6.3              vctrs_0.6.5          
  [7] memoise_2.0.1         htmltools_0.5.7       distr6_1.8.4          curl_5.2.0            parallelly_1.36.0     desc_1.4.3           
 [13] htmlwidgets_1.6.4     palmerpenguins_0.1.1  cachem_1.0.8          uuid_1.2-0            mime_0.12             lifecycle_1.0.4      
 [19] iterators_1.0.14      pkgconfig_2.0.3       R6_2.5.1              fastmap_1.1.1         future_1.33.1         shiny_1.8.0          
 [25] digest_0.6.34         colorspace_2.1-0      furrr_0.3.1           ps_1.7.6              mlr3misc_0.13.0       pkgload_1.3.4        
 [31] fansi_1.0.6           timechange_0.3.0      compiler_4.3.2        proxy_0.4-27          remotes_2.4.2.1       withr_3.0.0          
 [37] backports_1.4.1       param6_0.2.4          pkgbuild_1.4.3        MASS_7.3-60           lava_1.7.3            sessioninfo_1.2.2    
 [43] tools_4.3.2           set6_0.2.6            httpuv_1.6.14         future.apply_1.11.1   nnet_7.3-19           glue_1.7.0           
 [49] lgr_0.4.4             callr_3.7.3           promises_1.2.1        grid_4.3.2            checkmate_2.3.1       generics_0.1.3       
 [55] gtable_0.3.4          tzdb_0.4.0            class_7.3-22          data.table_1.15.0     hms_1.1.3             utf8_1.2.4           
 [61] foreach_1.5.2         pillar_1.9.0          dictionar6_0.1.3      later_1.3.2           bbotk_0.7.3           splines_4.3.2        
 [67] lhs_1.1.6             lattice_0.21-9        renv_1.0.3            tidyselect_1.2.0      miniUI_0.1.1.1        knitr_1.45           
 [73] RhpcBLASctl_0.23-42   xfun_0.41             hardhat_1.3.0         timeDate_4032.109     stringi_1.8.3         DiceDesign_1.10      
 [79] codetools_0.2-19      mlr3viz_0.7.0         cli_3.6.2             rpart_4.1.21          xtable_1.8-4          munsell_0.5.0        
 [85] processx_3.8.3        Rcpp_1.0.12           globals_0.16.2        parallel_4.3.2        ellipsis_0.3.2        gower_1.0.1          
 [91] profvis_0.3.8         urlchecker_1.0.1      GPfit_1.0-8           listenv_0.9.1         mlr3pipelines_0.5.0-2 ipred_0.9-14         
 [97] e1071_1.7-14          prodlim_2023.08.28    crayon_1.5.2          rlang_1.1.3           mlr3measures_0.5.0   
bblodfon commented 7 months ago

@beiwo07 This runs just fine with my setup, try to always install the newest of all packages as they are all in active development. mlr3proba should be at mlr3proba_0.5.8, maybe that's it?

PS: It's nice practice to copy your code, run reprex::reprex(), copy-paste the result.

beiwo07 commented 7 months ago

@beiwo07 This runs just fine with my setup, try to always install the newest of all packages as they are all in active development. mlr3proba should be at mlr3proba_0.5.8, maybe that's it?

PS: It's nice practice to copy your code, run reprex::reprex(), copy-paste the result.

Thanks for the tips! I updated the packages. It turned out to be related to mlr3's version. I replaced mlr3_0.17.2 with mlr3_0.17.0, and it runs now.