Skip to content
New issue

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

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

Already on GitHub? # to your account

Error message encountered with mlr3 parametric learner #96

Open
Lee-xli opened this issue Sep 19, 2024 · 0 comments
Open

Error message encountered with mlr3 parametric learner #96

Lee-xli opened this issue Sep 19, 2024 · 0 comments

Comments

@Lee-xli
Copy link

Lee-xli commented Sep 19, 2024

Hi survex team,

I encountered the following error message "Error in vecdist$wrappedModels()[[i]]: wrong arguments for subsetting an environment" when applying model_survshap function with aft_weibull model from mlr3. This has not been a problem with other models/learners from mlr3 in my experience.

Any insight and suggestion on how this may be debugged would be very much appreciated!

library(mlr3)
library(mlr3extralearners)
library(mlr3pipelines)
library('mlr3proba') 
library(survival)
library(survex)

lung = tsk('lung')$data()

aft=lrn('surv.parametric')
aft$train(tsk('lung'))

class(aft) = c(class(aft), 'LearnerSurv')

aft_exp_lung = explain(aft,
                       data= lung[, -c(1,2)],
                       y=Surv(lung$time, lung$status),
                       label = 'aft')
#> Preparation of a new explainer is initiated 
#>   -> model label       :  aft 
#>   -> data              :  168  rows  7  cols 
#>   -> target variable   :  168  values ( 121 events and 47 censored ) 
#>   -> times             :  50 unique time points , min = 8 , median survival time = 320 , max = 918 
#>   -> times             :  (  generated from y as uniformly distributed survival quantiles based on Kaplan-Meier estimator  ) 
#>   -> predict function  :  predict_newdata()$crank will be used ( �[33m default �[39m ) 
#>   -> predict survival function  :  predict_newdata()$distr$survival will be used ( �[33m default �[39m ) 
#>   -> predict cumulative hazard function  :  predict_newdata()$distr$cumHazard will be used ( �[33m default �[39m ) 
#>   -> model_info        :  package mlr3proba , ver. 0.6.3 , task survival ( �[33m default �[39m ) 
#>   A new explainer has been created!
kernelSHAP_aft_lung = model_survshap(explainer = aft_exp_lung,
                                     calculation_method = 'kernelshap',
                                     aggregation_method = 'integral',  
                                     output_type = 'risk')
#> Error in vecdist$wrappedModels()[[i]]: wrong arguments for subsetting an environment

Created on 2024-09-19 by the reprex package (v2.0.1)

Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value                       
#>  version  R version 4.1.1 (2021-08-10)
#>  os       macOS Big Sur 10.16         
#>  system   x86_64, darwin17.0          
#>  ui       X11                         
#>  language (EN)                        
#>  collate  en_US.UTF-8                 
#>  ctype    en_US.UTF-8                 
#>  tz       Australia/Adelaide          
#>  date     2024-09-19                  
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package           * version    date       lib
#>  backports           1.5.0      2024-05-23 [1]
#>  checkmate           2.3.1      2023-12-04 [1]
#>  cli                 3.6.3      2024-06-21 [1]
#>  codetools           0.2-18     2020-11-04 [2]
#>  colorspace          2.1-0      2023-01-23 [1]
#>  crayon              1.4.1      2021-02-08 [2]
#>  DALEX               2.4.3      2023-01-15 [1]
#>  data.table          1.15.4     2024-03-30 [1]
#>  dictionar6          0.1.3      2021-09-13 [1]
#>  digest              0.6.36     2024-06-23 [1]
#>  distr6              1.8.4      2024-06-13 [1]
#>  dplyr               1.1.3      2023-09-03 [1]
#>  evaluate            0.24.0     2024-06-10 [1]
#>  fansi               1.0.6      2023-12-08 [1]
#>  fastmap             1.1.0      2021-01-25 [2]
#>  foreach             1.5.1      2020-10-15 [2]
#>  fs                  1.5.0      2020-07-31 [2]
#>  future              1.33.2     2024-03-26 [1]
#>  generics            0.1.3      2022-07-05 [1]
#>  ggplot2             3.5.1      2024-04-23 [1]
#>  globals             0.16.3     2024-03-08 [1]
#>  glue                1.7.0      2024-01-09 [1]
#>  gtable              0.3.5      2024-04-22 [1]
#>  highr               0.9        2021-04-16 [2]
#>  htmltools           0.5.6      2023-08-10 [1]
#>  iterators           1.0.13     2020-10-15 [2]
#>  kernelshap          0.6.0      2024-07-12 [1]
#>  knitr               1.33       2021-04-24 [2]
#>  lattice             0.20-44    2021-05-02 [2]
#>  lgr                 0.4.4      2022-09-05 [1]
#>  lifecycle           1.0.4      2023-11-07 [1]
#>  listenv             0.9.1      2024-01-29 [1]
#>  magrittr            2.0.3      2022-03-30 [1]
#>  Matrix              1.3-4      2021-06-01 [2]
#>  mlr3              * 0.20.0     2024-06-28 [1]
#>  mlr3extralearners * 0.8.0-9000 2024-06-15 [1]
#>  mlr3misc            0.15.1     2024-06-24 [1]
#>  mlr3pipelines     * 0.6.0      2024-07-16 [1]
#>  mlr3proba         * 0.6.3      2024-06-13 [1]
#>  mlr3viz             0.9.0      2024-07-01 [1]
#>  munsell             0.5.1      2024-04-01 [1]
#>  ooplah              0.2.0      2022-01-21 [1]
#>  palmerpenguins      0.1.1      2022-08-15 [1]
#>  paradox             1.0.1      2024-07-09 [1]
#>  parallelly          1.37.1     2024-02-29 [1]
#>  param6              0.2.4      2023-11-22 [1]
#>  patchwork           1.2.0      2024-01-08 [1]
#>  pillar              1.9.0      2023-03-22 [1]
#>  pkgconfig           2.0.3      2019-09-22 [2]
#>  pracma              2.3.3      2021-01-23 [2]
#>  R6                  2.5.1      2021-08-19 [1]
#>  Rcpp                1.0.12     2024-01-09 [1]
#>  reprex              2.0.1      2021-08-05 [1]
#>  RhpcBLASctl         0.23-42    2023-02-11 [1]
#>  rlang               1.1.4      2024-06-04 [1]
#>  rmarkdown           2.10       2021-08-06 [2]
#>  rstudioapi          0.15.0     2023-07-07 [1]
#>  scales              1.3.0      2023-11-28 [1]
#>  sessioninfo         1.1.1      2018-11-05 [2]
#>  set6                0.2.6      2023-11-22 [1]
#>  stringi             1.7.3      2021-07-16 [2]
#>  stringr             1.5.0      2022-12-02 [1]
#>  survex            * 1.2.0      2023-10-24 [1]
#>  survival          * 3.7-0      2024-06-05 [1]
#>  survivalmodels      0.1.19     2024-06-26 [1]
#>  tibble              3.2.1      2023-03-20 [1]
#>  tidyselect          1.2.0      2022-10-10 [1]
#>  utf8                1.2.4      2023-10-22 [1]
#>  uuid                1.2-0      2024-01-14 [1]
#>  vctrs               0.6.5      2023-12-01 [1]
#>  withr               3.0.0      2024-01-16 [1]
#>  xfun                0.25       2021-08-06 [2]
#>  yaml                2.2.1      2020-02-01 [2]
#>  source                                    
#>  CRAN (R 4.1.1)                            
#>  CRAN (R 4.1.1)                            
#>  CRAN (R 4.1.1)                            
#>  CRAN (R 4.1.1)                            
#>  CRAN (R 4.1.2)                            
#>  CRAN (R 4.1.0)                            
#>  CRAN (R 4.1.2)                            
#>  CRAN (R 4.1.1)                            
#>  CRAN (R 4.1.0)                            
#>  CRAN (R 4.1.1)                            
#>  Github (xoopR/distr6@95d7359)             
#>  CRAN (R 4.1.1)                            
#>  CRAN (R 4.1.1)                            
#>  CRAN (R 4.1.1)                            
#>  CRAN (R 4.1.0)                            
#>  CRAN (R 4.1.0)                            
#>  CRAN (R 4.1.0)                            
#>  CRAN (R 4.1.1)                            
#>  CRAN (R 4.1.2)                            
#>  CRAN (R 4.1.1)                            
#>  CRAN (R 4.1.1)                            
#>  CRAN (R 4.1.1)                            
#>  CRAN (R 4.1.1)                            
#>  CRAN (R 4.1.0)                            
#>  CRAN (R 4.1.1)                            
#>  CRAN (R 4.1.0)                            
#>  CRAN (R 4.1.1)                            
#>  CRAN (R 4.1.0)                            
#>  CRAN (R 4.1.1)                            
#>  CRAN (R 4.1.2)                            
#>  CRAN (R 4.1.1)                            
#>  CRAN (R 4.1.1)                            
#>  CRAN (R 4.1.2)                            
#>  CRAN (R 4.1.1)                            
#>  CRAN (R 4.1.1)                            
#>  Github (mlr-org/mlr3extralearners@6dc6965)
#>  CRAN (R 4.1.1)                            
#>  Github (mlr-org/mlr3pipelines@c542a26)    
#>  Github (mlr-org/mlr3proba@5205752)        
#>  CRAN (R 4.1.1)                            
#>  CRAN (R 4.1.1)                            
#>  CRAN (R 4.1.2)                            
#>  CRAN (R 4.1.2)                            
#>  CRAN (R 4.1.1)                            
#>  CRAN (R 4.1.1)                            
#>  Github (xoopR/param6@0fa3577)             
#>  CRAN (R 4.1.1)                            
#>  CRAN (R 4.1.2)                            
#>  CRAN (R 4.1.0)                            
#>  CRAN (R 4.1.0)                            
#>  CRAN (R 4.1.0)                            
#>  CRAN (R 4.1.1)                            
#>  CRAN (R 4.1.0)                            
#>  CRAN (R 4.1.2)                            
#>  CRAN (R 4.1.1)                            
#>  CRAN (R 4.1.0)                            
#>  CRAN (R 4.1.1)                            
#>  CRAN (R 4.1.1)                            
#>  CRAN (R 4.1.0)                            
#>  Github (xoopR/set6@a901255)               
#>  CRAN (R 4.1.0)                            
#>  CRAN (R 4.1.2)                            
#>  CRAN (R 4.1.1)                            
#>  CRAN (R 4.1.1)                            
#>  Github (RaphaelS1/survivalmodels@9c78ea6) 
#>  CRAN (R 4.1.2)                            
#>  CRAN (R 4.1.2)                            
#>  CRAN (R 4.1.1)                            
#>  CRAN (R 4.1.1)                            
#>  CRAN (R 4.1.1)                            
#>  CRAN (R 4.1.1)                            
#>  CRAN (R 4.1.0)                            
#>  CRAN (R 4.1.0)                            
#> 
#> [1] /Users/Lee/Library/R/x86_64/4.1/library
#> [2] /Library/Frameworks/R.framework/Versions/4.1/Resources/library
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant