business-science / modeltime

Modeltime unlocks time series forecast models and machine learning in one framework
https://business-science.github.io/modeltime/
Other
522 stars 79 forks source link

Cannot set Prophet yearly.seasonality #43

Closed paul-cris closed 3 years ago

paul-cris commented 3 years ago

suppressMessages(library(tidyverse)) suppressMessages(library(tidyquant)) suppressMessages(library(timetk)) suppressMessages(library(tidymodels)) suppressMessages(library(modeltime)) sessionInfo()

> R version 4.0.2 (2020-06-22)

> Platform: x86_64-pc-linux-gnu (64-bit)

> Running under: CentOS Linux 7 (Core)

>

> Matrix products: default

> BLAS/LAPACK: /usr/lib64/libopenblasp-r0.3.3.so

>

> locale:

> [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C

> [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8

> [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8

> [7] LC_PAPER=en_US.UTF-8 LC_NAME=C

> [9] LC_ADDRESS=C LC_TELEPHONE=C

> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

>

> attached base packages:

> [1] stats graphics grDevices utils datasets methods base

>

> other attached packages:

> [1] modeltime_0.2.1 yardstick_0.0.7

> [3] workflows_0.2.1 tune_0.1.1.9000

> [5] rsample_0.0.8 recipes_0.1.13

> [7] parsnip_0.1.3 modeldata_0.0.2

> [9] infer_0.5.2 dials_0.0.9

> [11] scales_1.1.1 broom_0.7.0

> [13] tidymodels_0.1.1 timetk_2.3.0

> [15] tidyquant_1.0.1 quantmod_0.4.17

> [17] TTR_0.23-6 PerformanceAnalytics_2.0.4

> [19] xts_0.12-0 zoo_1.8-8

> [21] lubridate_1.7.9 forcats_0.5.0

> [23] stringr_1.4.0 dplyr_1.0.2

> [25] purrr_0.3.4 readr_1.3.1

> [27] tidyr_1.1.2 tibble_3.0.4

> [29] ggplot2_3.3.2 tidyverse_1.3.0

>

> loaded via a namespace (and not attached):

> [1] colorspace_1.4-1 ellipsis_0.3.1 class_7.3-17

> [4] fs_1.5.0 rstudioapi_0.11 listenv_0.8.0

> [7] furrr_0.2.0 prodlim_2019.11.13 fansi_0.4.1

> [10] xml2_1.3.2 codetools_0.2-16 splines_4.0.2

> [13] knitr_1.29.4 jsonlite_1.7.1 pROC_1.16.2

> [16] dbplyr_1.4.4 compiler_4.0.2 httr_1.4.2

> [19] backports_1.1.10 assertthat_0.2.1 Matrix_1.2-18

> [22] cli_2.1.0 htmltools_0.5.0 tools_4.0.2

> [25] gtable_0.3.0 glue_1.4.2 Rcpp_1.0.5

> [28] cellranger_1.1.0 DiceDesign_1.8-1 vctrs_0.3.4

> [31] iterators_1.0.12 timeDate_3043.102 gower_0.2.2

> [34] xfun_0.17 globals_0.13.1 rvest_0.3.5

> [37] lifecycle_0.2.0 future_1.19.1 MASS_7.3-51.6

> [40] ipred_0.9-9 hms_0.5.3 parallel_4.0.2

> [43] yaml_2.2.1 curl_4.3 StanHeaders_2.21.0-6

> [46] rpart_4.1-15 stringi_1.5.3 highr_0.8

> [49] foreach_1.5.0 lhs_1.1.0 lava_1.6.8

> [52] rlang_0.4.8 pkgconfig_2.0.3 evaluate_0.14

> [55] lattice_0.20-41 tidyselect_1.1.0 plyr_1.8.6

> [58] magrittr_1.5 R6_2.4.1 generics_0.0.2

> [61] DBI_1.1.0 pillar_1.4.6 haven_2.3.1

> [64] withr_2.3.0 survival_3.1-12 nnet_7.3-14

> [67] modelr_0.1.8 crayon_1.3.4 Quandl_2.10.0

> [70] rmarkdown_2.3 grid_4.0.2 readxl_1.3.1

> [73] blob_1.2.1 reprex_0.3.0 digest_0.6.25

> [76] RcppParallel_5.0.2 munsell_0.5.0 GPfit_1.0-8

> [79] quadprog_1.5-8

bike_transactions_tbl <- bike_sharing_daily %>% select(dteday, cnt) %>% set_names(c("date", "value"))

splits <- bike_transactions_tbl %>% time_series_split(assess = "3 months", cumulative = TRUE)

> Using date_var: date

Prophet

model_fit_prophet <- prophet_reg() %>% set_engine("prophet", yearly.seasonality=TRUE) %>% fit(value ~ date, training(splits))

> Warning: The following arguments cannot be manually modified and were removed:

> yearly.seasonality.

> Disabling yearly seasonality. Run prophet with yearly.seasonality=TRUE to override this.

> Disabling daily seasonality. Run prophet with daily.seasonality=TRUE to override this.

Created on 2020-10-15 by the reprex package (v0.3.0)

mdancho84 commented 3 years ago

Yearly seasonality has been incorporated as part of prophet_reg(seasonality_yearly).

Resource: https://business-science.github.io/modeltime/reference/prophet_reg.html

image

mdancho84 commented 3 years ago

Also, make sure to read the implementation details for how to use the specific arguments. For example, logistic_cap and logistic_floor are now numeric values.

paul-cris commented 3 years ago

Still does not work

model_fit_prophet <- prophet_reg() %>%

  • set_engine("prophet", seasonality_yearly = TRUE) %>%
  • fit(value ~ date, training(splits)) Disabling yearly seasonality. Run prophet with yearly.seasonality=TRUE to override this. Disabling daily seasonality. Run prophet with daily.seasonality=TRUE to override this.
mdancho84 commented 3 years ago

That's because you have it as an argument in set_engine(). Move the argument to prophet_reg().

paul-cris commented 3 years ago

Sorry missed that, thank you

mdancho84 commented 3 years ago

Sounds good. Good luck!

mdancho84 commented 3 years ago

I've updated the example here: https://www.business-science.io/code-tools/2020/06/29/introducing-modeltime.html

image