albertoalmuinha / bayesmodels Goto Github PK
View Code? Open in Web Editor NEWThe Tidymodels Extension for Bayesian Models
Home Page: https://albertoalmuinha.github.io/bayesmodels/
License: Other
The Tidymodels Extension for Bayesian Models
Home Page: https://albertoalmuinha.github.io/bayesmodels/
License: Other
Hello Alberto, first of all thanks for the amazing work with the package.
I would like to know if there is any prospects for the package to be usable with the newer versions of R. Thanks
There is a bug where the date is being included in the formula when calling the bsts::bsts() model. This behavior should be corrected.
When there are no external regressors and the variable has no missing values, the "if" condition must be changed so that it does not go through the second condition. This causes that the predictions are not well calculated and a bug is produced.
I'm pretty sure this is related to Issue #8 - Something weird happens when using the formula interface. This is another reason I prefer the data.frame interface when developing parsnip functions.
Only 1 predicted value is being returned. Should be 52 predictions. - Again, I think the solution can be resolved by switching to data.frame interface as discussed in #8.
predict(modelo, testing(splits)) # will return only 1 predicted value
# A tibble: 1 x 1
.pred
<dbl>
1 0.220
library(bayesmodels)
library(tidymodels)
library(timetk)
library(modeltime)
library(modeltime.resample)
library(modeltime.ensemble)
data(iclaims)
names(initial.claims)
df <- timetk::tk_tbl(initial.claims)
df %>% plot_time_series(.date_var = index,
.value = iclaimsNSA,
.smooth = FALSE)
# Issue 1
# split
splits <- time_series_split(
data = df,
# date_var = 'date',
assess = 52,
cumulative = TRUE
)
# splits %>% tk_time_series_cv_plan() %>% plot_time_series_cv_plan(index, iclaimsNSA)
ss <- AddLocalLinearTrend(list(), training(splits)$iclaimsNSA)
ss <- AddSeasonal(ss, training(splits)$iclaimsNSA, nseasons = 52)
modelo <- bayesian_structural_reg() %>%
set_engine("stan", state.specification = ss, niter = 1000) %>%
fit(iclaimsNSA ~ index, data = training(splits))
modeltime_tbl <- modeltime_table(modelo)
calib_tbl <- modeltime_table(modelo) %>% modeltime_calibrate(testing(splits))
a <- calib_tbl %>%
modeltime_forecast(
new_data = testing(splits),
actual_data = training(splits),
)
# make the values NA in the test split
testing_tmp <- testing(splits)[c('index', 'iclaimsNSA')]
testing_tmp$iclaimsNSA <- NA
calib_tbl2 <- modeltime_tbl %>%
modeltime_calibrate(new_data = testing_tmp,
actural_data = training(splits))
a2 <- calib_tbl %>%
modeltime_forecast(
new_data = testing_tmp,
actual_data = training(splits),
)
# compare Tables a and a2: Table a has only one prediction value for all timestaps in the test split but a2 has different predicted values in testing_tmp
predict(modelo, testing(splits)) # will return only 1 predicted value
@AlbertoAlmuinha Is it mandatory that the seasonal parameters be known beforehand for the sarima_reg
or will the algorithm take what you give and adjust?
Calibration needs to be able to determine if transformations were applied.
Cannot determine if transformation is required on 'actual_data'
library(bayesmodels)
library(tidymodels)
library(timetk)
library(modeltime)
library(modeltime.resample)
library(modeltime.ensemble)
data(iclaims)
names(initial.claims)
df <- timetk::tk_tbl(initial.claims)
df %>% plot_time_series(.date_var = index,
.value = iclaimsNSA,
.smooth = FALSE)
# Issue 1
# split
splits <- time_series_split(
data = df,
# date_var = 'date',
assess = 52,
cumulative = TRUE
)
# splits %>% tk_time_series_cv_plan() %>% plot_time_series_cv_plan(index, iclaimsNSA)
ss <- AddLocalLinearTrend(list(), training(splits)$iclaimsNSA)
ss <- AddSeasonal(ss, training(splits)$iclaimsNSA, nseasons = 52)
modelo <- bayesian_structural_reg() %>%
set_engine("stan", state.specification = ss, niter = 1000) %>%
fit(iclaimsNSA ~ index, data = training(splits))
modeltime_tbl <- modeltime_table(modelo)
calib_tbl <- modeltime_table(modelo) %>% modeltime_calibrate(testing(splits))
Results in this:
Warning message:
Problem with `mutate()` column `.nested.col`.
i `.nested.col = purrr::map2(...)`.
i Cannot determine if transformation is required on 'actual_data'
Hello @AlbertoAlmuinha, I have installed bayesmodels from CRAN. But getting the following error when loading it.
library(bayesmodels)
Loading required package: parsnip
Loading required package: bayesforecast
Registered S3 method overwritten by 'quantmod':
method from
as.zoo.data.frame zoo
Registered S3 methods overwritten by 'bayesforecast':
method from
autoplot.ts forecast
forecast.ts forecast
fortify.ts forecast
print.garch tseries
Error: package or namespace load failed for ‘bayesforecast’ in .doLoadActions(where, attach):
error in load action .__A__.1 for package bayesforecast: Rcpp::loadModule(module = "stan_fit4SVM_mod", what = TRUE, env = ns, : Unable to load module "stan_fit4SVM_mod": function 'Rcpp_precious_remove' not provided by package 'Rcpp'
Error: package ‘bayesforecast’ could not be loaded
In addition: Warning messages:
1: package ‘bayesmodels’ was built under R version 4.1.1
2: package ‘bayesforecast’ was built under R version 4.1.1
A problem has been detected when calculating predictions in the bayesian_structural_reg() function for univariate problems. Actually this function was only working properly for problems where external regressors were used in the model.
Hi, I am trying to install the bayesmodels package with devtools::install_github("AlbertoAlmuinha/bayesmodels")
I get the following error:
Error: package or namespace load failed for ‘bayesmodels’:
.onLoad failed in loadNamespace() for 'bayesmodels', details:
call: check_mode_for_new_engine(model, eng, mode)
error: 'regression' is not a known mode for modelgen_additive_reg()
.
Error: loading failed
Execution halted
It seems that the parsnip defined modes are not properly passed during the installation.
Any idea how to fix that?
Session info:
R version 4.2.0 (2022-04-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Monterey 12.2.1Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRlapack.dyliblocale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8attached base packages:
[1] stats graphics grDevices utils datasets methods baseother attached packages:
[1] parsnip_0.2.1 rlang_1.0.2loaded via a namespace (and not attached):
[1] tidyselect_1.1.2 remotes_2.4.2 purrr_0.3.4 colorspace_2.0-3
[5] vctrs_0.4.1 generics_0.1.2 testthat_3.1.4 usethis_2.1.5
[9] utf8_1.2.2 pkgbuild_1.3.1 pillar_1.7.0 glue_1.6.2
[13] withr_2.5.0 DBI_1.1.2 sessioninfo_1.2.2 foreach_1.5.2
[17] lifecycle_1.0.1 munsell_0.5.0 gtable_0.3.0 devtools_2.4.3
[21] codetools_0.2-18 evaluate_0.15 memoise_2.0.1 callr_3.7.0
[25] fastmap_1.1.0 doParallel_1.0.17 ps_1.7.0 parallel_4.2.0
[29] curl_4.3.2 fansi_1.0.3 scales_1.2.0 cachem_1.0.6
[33] desc_1.4.1 pkgload_1.2.4 fs_1.5.2 brio_1.1.3
[37] ggplot2_3.3.6 png_0.1-7 digest_0.6.29 processx_3.5.3
[41] dplyr_1.0.9 grid_4.2.0 rprojroot_2.0.3 hardhat_0.2.0
[45] cli_3.3.0 tools_4.2.0 magrittr_2.0.3 tibble_3.1.7
[49] crayon_1.5.1 tidyr_1.2.0 pkgconfig_2.0.3 ellipsis_0.3.2
[53] prettyunits_1.1.1 assertthat_0.2.1 rstudioapi_0.13 iterators_1.0.14
[57] R6_2.5.1 compiler_4.2.0
Hello Alberto. Suddenly the package has stopped working. When trying to load the package it returns :
Error: package or namespace load failed for ‘bayesmodels’:
.onLoad failed in loadNamespace() for 'bayesmodels', details:
call: check_model_doesnt_exist(model)
error: Model sarima_reg
already exists
Session Information:
> sessionInfo()
R version 4.0.3 (2020-10-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19041)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] parallel stats graphics grDevices utils datasets methods base
other attached packages:
[1] bsts_0.9.6 BoomSpikeSlab_1.2.4 Boom_0.9.7
[4] MASS_7.3-54 bayesforecast_0.0.1 garchmodels_0.1.1
[7] rmgarch_1.3-7 rugarch_1.4-4 modeltime.h2o_0.1.1
[10] h2o_3.32.1.3 modeltime.ensemble_0.4.1 modeltime.resample_0.2.0
[13] tidyquant_1.0.3 quantmod_0.4.18 TTR_0.24.2
[16] PerformanceAnalytics_2.0.4 xts_0.12.1 zoo_1.8-9
[19] janitor_2.1.0 DBI_1.1.1 odbc_1.3.2
[22] timetk_2.6.1 lubridate_1.7.10 forcats_0.5.1
[25] stringr_1.4.0 readr_1.4.0 tidyverse_1.3.1
[28] modeltime_0.6.0 yardstick_0.0.8 workflowsets_0.0.2
[31] workflows_0.2.2 tune_0.1.5 tidyr_1.1.3
[34] tibble_3.1.2 rsample_0.1.0 recipes_0.1.16
[37] purrr_0.3.4 parsnip_0.1.6 modeldata_0.1.0
[40] infer_0.5.4 ggplot2_3.3.3 dplyr_1.0.6
[43] dials_0.0.9 scales_1.1.1 broom_0.7.6
[46] tidymodels_0.1.3 pacman_0.5.1
loaded via a namespace (and not attached):
[1] utf8_1.2.1 ks_1.13.1 tidyselect_1.1.1
[4] htmlwidgets_1.5.3 grid_4.0.3 gmp_0.6-2
[7] pROC_1.17.0.1 munsell_0.5.0 codetools_0.2-18
[10] xgboost_1.4.1.1 future_1.21.0 withr_2.4.2
[13] Brobdingnag_1.2-6 colorspace_2.0-1 rstudioapi_0.13
[16] stats4_4.0.3 bayesplot_1.8.0 listenv_0.8.0
[19] labeling_0.4.2 GeneralizedHyperbolic_0.8-4 rstan_2.21.2
[22] TeachingDemos_2.12 DistributionUtils_0.6-0 bit64_4.0.5
[25] DiceDesign_1.9 farver_2.1.0 bridgesampling_1.1-2
[28] coda_0.19-4 parallelly_1.25.0 vctrs_0.3.8
[31] generics_0.1.0 ipred_0.9-11 R6_2.5.0
[34] LICHospitalR_0.2.0 bitops_1.0-7 lhs_1.1.1
[37] assertthat_0.2.1 nnet_7.3-16 forecast_8.15
[40] gtable_0.3.0 globals_0.14.0 processx_3.5.2
[43] timeDate_3043.102 rlang_0.4.11 Bessel_0.6-0
[46] splines_4.0.3 lazyeval_0.2.2 earth_5.3.0
[49] SkewHyperbolic_0.4-0 inline_0.3.19 yaml_2.2.1
[52] modelr_0.1.8 crosstalk_1.1.1 backports_1.2.1
[55] tools_4.0.3 lava_1.6.9 ellipsis_0.3.2
[58] ff_4.0.4 Rsolnp_1.16 ggridges_0.5.3
[61] Rcpp_1.0.6 plyr_1.8.6 RCurl_1.98-1.3
[64] ps_1.6.0 prettyunits_1.1.1 rpart_4.1-15
[67] fracdiff_1.5-1 haven_2.4.1 fs_1.5.0
[70] furrr_0.2.2 magrittr_2.0.1 data.table_1.14.0
[73] lmtest_0.9-38 reprex_2.0.0 GPfit_1.0-8
[76] truncnorm_1.0-8 mvtnorm_1.1-1 matrixStats_0.59.0
[79] hms_1.1.0 mclust_5.4.7 readxl_1.3.1
[82] rstantools_2.1.1 gridExtra_2.3 compiler_4.0.3
[85] KernSmooth_2.23-20 V8_3.4.2 crayon_1.4.1
[88] StanHeaders_2.21.0-7 htmltools_0.5.1.1 corpcor_1.6.9
[91] pcaPP_1.9-74 Formula_1.2-4 RcppParallel_5.1.4
[94] dbplyr_2.1.1 Matrix_1.3-4 cli_2.5.0
[97] quadprog_1.5-8 gower_0.2.2 pkgconfig_2.0.3
[100] spd_2.0-1 numDeriv_2016.8-1.1 plotly_4.9.3
[103] xml2_1.3.2 foreach_1.5.1 hardhat_0.1.5
[106] plotmo_3.6.0 prodlim_2019.11.13 rvest_1.0.0
[109] snakecase_0.11.0 callr_3.7.0 digest_0.6.27
[112] pracma_2.3.3 cellranger_1.1.0 curl_4.3.1
[115] urca_1.3-0 nloptr_1.2.2.2 lifecycle_1.0.0
[118] nlme_3.1-152 jsonlite_1.7.2 tseries_0.10-48
[121] viridisLite_0.4.0 fansi_0.5.0 pillar_1.6.1
[124] loo_2.4.1 lattice_0.20-44 plotrix_3.8-1
[127] httr_1.4.2 pkgbuild_1.2.0 survival_3.2-11
[130] glue_1.4.2 iterators_1.0.13 bit_4.0.4
[133] class_7.3-19 stringi_1.6.2 prophet_1.0
[136] Quandl_2.10.0 blob_1.2.1 Rmpfr_0.8-4
Error Message:
> library("bayesmodels")
Error: package or namespace load failed for ‘bayesmodels’ in get(method, envir = home):
lazy-load database 'C:/Users/bha485/Documents/R/win-library/4.0/bayesmodels/R/bayesmodels.rdb' is corrupt
In addition: Warning messages:
1: package ‘bayesmodels’ was built under R version 4.0.5
2: In .registerS3method(fin[i, 1], fin[i, 2], fin[i, 3], fin[i, 4], :
restarting interrupted promise evaluation
3: In get(method, envir = home) :
restarting interrupted promise evaluation
4: In get(method, envir = home) : internal error -3 in R_decompress1
Ubuntu LTS, R latest, boostime latest, modeltime latest.
exponential_smoothing() runs forever...
Is there a way to reach rlgt.control() to get access to iterations etc.?
I tried set_engine('stan',iter=100) with no success.
Please don't give up with maintaining this package! It has great potential, since the bayes-thingy can be a nightmare manually.
bayesforecast
packagebayesforecast
packagebayesforecast
packagebayesforecast
packagebayesforecast
packageBASS
packagebrms
packagebsts
packageRlgt
packageBART
package (no rJava dependencies)I am just trying to install your package with no success. I did try on mac and on windows 10 under R version 4.1.1 and 4.1.2. When I try to install via cran it states, that this package is not available for my version of R.
When I try to install the development version, I get the following error:
Restarting R did not help.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.