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

calculate_oscillations returns only NAs as oscillations #151

Open
marioem opened this issue Apr 30, 2024 · 0 comments
Open

calculate_oscillations returns only NAs as oscillations #151

marioem opened this issue Apr 30, 2024 · 0 comments

Comments

@marioem
Copy link

marioem commented Apr 30, 2024

Running predict_parts with type set to oscillations of any kind results in a set of warnings of an argument being neither numeric or logical, with all oscillations in the result set to NA.

The problem is in the following code fragment

    tmp <- lapply(ids, function(id) {
      diffs <- x[x$`_vname_` == variable & x$`_ids_` == id,"_yhat_"] - observations[id,"_yhat_"]
      data.frame(`_vname_` = variable, `_ids_` = id, oscillations = mean(abs(diffs))) # <<<<<<<<
    })

diffs is a data.frame object, resulting in mean(abs(diffs)) returning NAs.

Following patch fixes the issue:

    tmp <- lapply(ids, function(id) {
      diffs <- x[x$`_vname_` == variable & x$`_ids_` == id,"_yhat_"] - observations[id,"_yhat_"]
      data.frame(`_vname_` = variable, `_ids_` = id, oscillations = mean(abs(diffs$`_yhat_`)))
    })
> packageVersion("ingredients")
[1] ‘2.3.0’

SessionInfo:

R version 4.3.3 (2024-02-29)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Sonoma 14.4.1

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-arm64/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: Europe/Stockholm
tzcode source: internal

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

other attached packages:
 [1] ggpp_0.5.6         rules_1.0.2        mixOmics_6.24.0    lattice_0.22-6     MASS_7.3-60.0.1    plsmod_1.0.0       conflicted_1.2.0   waterfalls_1.0.0   ggrepel_0.9.5      factoextra_1.0.7  
[11] yardstick_1.3.1    workflowsets_1.1.0 workflows_1.1.4    tune_1.2.1         rsample_1.2.1      recipes_1.0.10     parsnip_1.2.1      modeldata_1.3.0    infer_1.0.7        dials_1.2.1       
[21] scales_1.3.0       broom_1.0.5        tidymodels_1.2.0   pins_1.3.0         DALEXtra_2.3.0     DALEX_2.4.3        patchwork_1.2.0    lubridate_1.9.3    forcats_1.0.0      stringr_1.5.1     
[31] dplyr_1.1.4        purrr_1.0.2        readr_2.1.5        tidyr_1.3.1        tibble_3.2.1       ggplot2_3.5.1      tidyverse_2.0.0   

loaded via a namespace (and not attached):
 [1] polynom_1.4-1       gridExtra_2.3       kknn_1.3.1          rlang_1.1.3         magrittr_2.0.3      furrr_0.3.1         matrixStats_1.2.0   compiler_4.3.3      vctrs_0.6.5        
[10] reshape2_1.4.4      lhs_1.1.6           pkgconfig_2.0.3     shape_1.4.6.1       fastmap_1.1.1       backports_1.4.1     utf8_1.2.4          prodlim_2023.08.28  tzdb_0.4.0         
[19] xfun_0.43           glmnet_4.1-8        cachem_1.0.8        jsonlite_1.8.8      reshape_0.8.9       BiocParallel_1.34.1 vip_0.4.1           parallel_4.3.3      R6_2.5.1           
[28] stringi_1.8.3       RColorBrewer_1.1-3  GGally_2.2.1        parallelly_1.37.1   rpart_4.1.23        xgboost_1.7.7.1     Rcpp_1.0.12         iterators_1.0.14    knitr_1.45         
[37] future.apply_1.11.2 Matrix_1.6-5        splines_4.3.3       nnet_7.3-19         igraph_2.0.3        timechange_0.3.0    tidyselect_1.2.1    rstudioapi_0.16.0   timeDate_4032.109  
[46] codetools_0.2-19    listenv_0.9.1       plyr_1.8.9          withr_3.0.0         rARPACK_0.11-0      future_1.33.2       survival_3.6-4      ggstats_0.6.0       kernlab_0.9-32     
[55] pillar_1.9.0        DT_0.33             foreach_1.5.2       ellipse_0.5.0       generics_0.1.3      rprojroot_2.0.4     hms_1.1.3           munsell_0.5.1       globals_0.16.3     
[64] class_7.3-22        glue_1.7.0          tools_4.3.3         data.table_1.15.4   RSpectra_0.16-1     gower_1.0.1         fs_1.6.3            grid_4.3.3          ipred_0.9-14       
[73] colorspace_2.1-0    cli_3.6.2           DiceDesign_1.10     rappdirs_0.3.3      fansi_1.0.6         lava_1.8.0          corpcor_1.6.10      gtable_0.3.5        GPfit_1.0-8        
[82] digest_0.6.35       htmlwidgets_1.6.4   memoise_2.0.1       htmltools_0.5.8     lifecycle_1.0.4     hardhat_1.3.1       here_1.0.1  

BRs,

Mariusz

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

1 participant