Robyn
Robyn copied to clipboard
Getting error when facilitating holidays data
Hello Robyn team,
I'm getting an error when facilitating holidays data, but it used to work previously before updating to latest Robyn version.
I'm working with daily data.
I'm loading the data using the following command (as in the demo):
data("dt_prophet_holidays")
After that, I set the following prophet related parameters to the input:
InputCollect <- robyn_inputs(
,dt_holidays = dt_prophet_holidays
,prophet_vars = c("trend", "season", "weekday", "holiday")
,prophet_signs = c("default","default", "default", "default")
,prophet_country = "ES"
...
And when assigning the input using the robyn_inputs function, I'm getting the following error:
<error/dplyr:::mutate_error>
Error in `dplyr::mutate()`:
! Problem while computing `ds = set_date(ds)`.
✖ `ds` must be size 500 or 1, not 502.
---
Backtrace:
1. Robyn::robyn_inputs(InputCollect = InputCollect, hyperparameters = hyperparameters)
16. dplyr:::mutate.data.frame(., ds = set_date(ds))
with the following trace:
<error/dplyr:::mutate_error>
Error in `dplyr::mutate()`:
! Problem while computing `ds = set_date(ds)`.
✖ `ds` must be size 500 or 1, not 502.
---
Backtrace:
▆
1. ├─Robyn::robyn_inputs(InputCollect = InputCollect, hyperparameters = hyperparameters)
2. │ └─Robyn:::robyn_engineering(InputCollect, ...)
3. │ └─Robyn:::prophet_decomp(...)
4. │ ├─stats::predict(mod, dt_regressors)
5. │ └─prophet:::predict.prophet(mod, dt_regressors)
6. │ └─prophet:::predict_seasonal_components(object, df)
7. │ └─prophet:::make_all_seasonality_features(m, df)
8. │ └─prophet:::make_holiday_features(m, df$ds, holidays)
9. │ └─... %>% tidyr::spread(holiday, x, fill = 0)
10. ├─tidyr::spread(., holiday, x, fill = 0)
11. ├─dplyr::mutate(., x = 1)
12. ├─dplyr::do(...)
13. ├─dplyr::filter(., dplyr::row_number() == 1)
14. ├─dplyr::group_by(., holiday, ds)
15. ├─dplyr::mutate(., ds = set_date(ds))
16. ├─dplyr:::mutate.data.frame(., ds = set_date(ds))
17. │ └─dplyr:::mutate_cols(.data, dplyr_quosures(...), caller_env = caller_env())
18. │ ├─base::withCallingHandlers(...)
19. │ └─mask$eval_all_mutate(quo)
20. ├─dplyr:::dplyr_internal_error(...)
21. │ └─rlang::abort(class = c(class, "dplyr:::internal_error"), dplyr_error_data = data)
22. │ └─rlang:::signal_abort(cnd, .file)
23. │ └─base::signalCondition(cnd)
24. └─dplyr (local) `<fn>`(`<dpl:::__>`)
25. └─rlang::abort(...)
I'm using the latest Robyn version and my R version 4.2.1.
The same problem has been reported in the forum (https://www.facebook.com/groups/robynmmm/posts( by @Stanislav_ Nosulenko on August 22. @laresbernardo has responded and raised an issue to the Prophet community (https://github.com/facebook/prophet/issues/2248).
While this issue is been solved, I would like to keep working with Robyn's Prophet feature. Is there a workaround for excluding the holidays from prophet and work with the other variables (trend, season, and weekday). I've tried to do so, but when I exclude the holidays, Robyn doesn't launch the Prophet analysis aparently.
Hi @omunozgarcia thanks for reporting this.
This bug hasn't actually been fixed yet. You are right this has been reported by a user in FB group and the prophet ticket I submitted. But still hasn't been fixed. I know that it's got to do with 1) daily level granularity and 2) prophet's fit function. Haven't discovered how to fix it yet.
We enable prophet to decompose trend and seasonality and enrich the dataset while minimizing the analyst's bias in doing so. You can of course turn it off as you mentioned if you'd like to but we encourage using this method. That said, can you further explain this use case in which you'd like to exclude holidays? Are excluding "holiday" from prophet_vars
? I've just checked and I do see the usage of prophet when excluding only holidays + the prophet_decomp.png output is generated correctly.
Hello @laresbernardo. Thanks a lot for your very quick response.
I'm excluding holiday from prophet vars and the prophet_decomp.png is not being generated to me. I'm working with 3.7.1 package version of Robyn.
Taking a look to Robyn's latest source code in line 213 of inputs.R (https://github.com/facebookexperimental/Robyn/blob/main/R/R/inputs.R) I'm thinking that the following code is preventing Robyn for executing Prophet, since I'm not providing holidays configuration.
## Check prophet
if (is.null(dt_holidays) | is.null(prophet_vars)) {
dt_holidays <- prophet_vars <- prophet_country <- prophet_signs <- NULL
}
That line of code is for when there is no dt_holidays
input (which is the data that contains the holidays) or prophet_vars
is NULL or doesn't contain anything (will simply turn prophet off). In your case, you have other elements: trend, season, etc.
Can you recheck if you are actually running on the latest dev version? No new updates available? You set prophet_vars = c("trend", "season", "weekday")
AND dt_holidays = dt_prophet_holidays
?
Potential fix PR in prophet's repo. CC: @bletham
Thanks a lot for your indications, Bernarno. I finally got prophet for trend season and weekday.
Could you please let us know as soon as the issue with Prophet and holidays is been solved?
+1, getting this error as well. Please let us know when it's resolved, thanks!!
- Even I'm getting the same error for daily data
Another user mentioned this same error in FB group.
@laresbernardo If it is any help at all, I'm receiving this error using weekly data, either prophet holidays or a custom holiday set, and weibull_pdf. It does not occur when I use geometric adstock parameters.
Also receiving this error on daily data regardless of adstock specification but it goes away when removing the holiday
selection for prophet_vars
Another user experiencing this same issue (FB Post)
Good news: the fix in prophet has landed on their dev version. So if any of you are experiencing this issue, you can update prophet to the latest dev version for now while we wait for CRAN version to land. To update to latest dev version, run: remotes::install_github("facebook/prophet/R")
.
Good news: the fix in prophet has landed on their dev version. So if any of you are experiencing this issue, you can update prophet to the latest dev version for now while we wait for CRAN version to land. To update to latest dev version, run:
remotes::install_github("facebook/prophet/R")
.
remotes::install_github("facebook/prophet/R")
packageVersion("prophet")
‘1.1.2’
packageVersion("Robyn")
‘3.9.1.9000’
but i have same warning
>> Running feature engineering...
NOTE: potential improvement on splitting channels for better exposure fitting. Threshold (Minimum R2) = 0.8
Check: InputCollect$plotNLSCollect outputs
Weak relationship for: "mo_kakao_clicks", "pc_google_clicks", "mo_google_clicks"and their spend
Warning message:
In prophet_decomp(dt_transform, dt_holidays = InputCollect$dt_holidays, :
Currently, there's a known issue with prophet that may crash this use case.
Read more here: https://github.com/facebookexperimental/Robyn/issues/472
Did it run successfully though? The warning is just a warning that will be removed once prophet lands a new version in CRAN @jupi-analyst
Hello Bernardo.
It is working well from our side.
Thank you very much!
Best regards
—
ÓSCAR MUÑOZ GARCÍA @.***
De: laresbernardo @.> Enviado: Thursday, February 16, 2023 4:55:26 PM Para: facebookexperimental/Robyn @.> Cc: Óscar Muñoz-García @.>; Mention @.> Asunto: Re: [facebookexperimental/Robyn] Getting error when facilitating holidays data (Issue #472)
Did it run successfully though? The warning is just a warning that will be removed once prophet lands a new version in CRAN @jupi-analysthttps://github.com/jupi-analyst
— Reply to this email directly, view it on GitHubhttps://github.com/facebookexperimental/Robyn/issues/472#issuecomment-1433311485, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACYAWTV4EHKN575T3WJ54NDWXZEW5ANCNFSM57OFWQ6Q. You are receiving this because you were mentioned.Message ID: @.***>
Thanks for the confirmation @omunozgarcia I'll proceed to closing this task given we have a (temporal) solution, and wait for prophet to land it's fix to CRAN anytime. Cheers!