Prophet: add_country_holidays with lower/upper window

Created on 11 Jan 2019  路  7Comments  路  Source: facebook/prophet

Can we access these holidays thru a dataframe so i can add upper and lower windows?

enhancement

Most helpful comment

That's a good point that one may want to have different upper/lower values for different holidays.

I think there is value to being able to do add_country_holidays(country_name) and get all of the holidays without having to construct the full list and iterate through it. So maybe the right interface would be to optionally pass along a dictionary like {'Christmas Day': (-2, 2)} that gives the lower/upper for any holiday that you'd want to specify. I'm not thrilled with that interface but it does allow for the most general use case while still keeping the simple use case simple.

All 7 comments

That would be a good feature to add. The interface could be

m.add_country_holidays(country_name, lower=0, upper=0)

In the meantime, you can get a dataframe of the country holidays to which upper and lower windows can be added by:

--- Python:

from fbprophet.make_holidays import make_holidays_df
year_list = [2015, 2016, 2017, 2018, 2019]
country_name = 'US'
df = make_holidays_df(year_list, country_name)

--- R:

library(prophet)
years <- c(2015, 2016, 2017, 2018, 2019)
country.name <- 'US'
df <- prophet:::make_holidays_df(years, country.name)

m.add_country_holidays(country_name, lower=0, upper=0)
In my opinion, this interface might not be a good one, as the holiday effect are usually different. As we can see Xmas tend to have strong prior and post holiday effect, while veterans day has little. It might be more reasonable to have a interface as:
m.add_country_holidays(country_name, holiday_name, lower=0, upper=0)

That's a good point that one may want to have different upper/lower values for different holidays.

I think there is value to being able to do add_country_holidays(country_name) and get all of the holidays without having to construct the full list and iterate through it. So maybe the right interface would be to optionally pass along a dictionary like {'Christmas Day': (-2, 2)} that gives the lower/upper for any holiday that you'd want to specify. I'm not thrilled with that interface but it does allow for the most general use case while still keeping the simple use case simple.

We're going to hold off on this for now, and leave make_holidays_df as the recommended way to handle this since it isn't clear what a good interface would look like otherwise.

It would be. great. if this feature was. there in Prophet.

hey everyone!

was testing a time series that seemed affected by this (ny taxi), using solution above improved significantly. used same ?)
upper/lower for all

My main doubt being, could assuming a default lower/upper window for all holidays give better results than assuming just the holiday date? (on average?) Wouldn't the specific coefficients be fitted per holiday/lags?
thx!

ps-posting holiday components before/after adding windows (-5,5)
next week effects were very noticeable on original time series, that's what triggered checking these options

image

image

Yes, the coefficients are fitted per holiday / per lag as you note. And it wouldn't surprise me if having a default >0 worked better on average - though it would greatly increase the number of parameters being used to fit holiday effects. For holidays that do have multi-day effects this will be very valuable, but for holidays that don't, the model may be a bit more likely to overfit effects in neighboring days since the default settings put very little regularization on the magnitude of holiday effects. It would probably be beneficial to decrease the holidays_prior_scale in that case. This is something that in the very least should be discussed in the documentation.

Was this page helpful?
0 / 5 - 0 ratings