facebook / prophet

Tool for producing high quality forecasts for time series data that has multiple seasonality with linear or non-linear growth.
https://facebook.github.io/prophet
MIT License
18.36k stars 4.52k forks source link

Feature request: support multiple country holidays #909

Open eromoe opened 5 years ago

eromoe commented 5 years ago

Hello,

This is because in some county like China Japan , people also would enjoy some foreign holidays . For example , chocolate sales would grow on Valentine's Day .
Cake and apple(yes apple) sales would have large increase on Christmas Eve .

Current behaviour

>>> m.add_country_holidays('CN')
>>> m.add_country_holidays('US')
WARNING:fbprophet:Changing country holidays from CN to US

Add a flag to determine whether appending or changing would be much better .

bletham commented 5 years ago

We had a lot of discussion about this when we were adding the country holidays feature. The big complication is with holidays that exist / overlap for both countries. Here are some examples of where things get weird:

Now maybe reasonable things will happen even if these identical holidays are not merged, but I think that'd need some extensive testing. Handling these in the "right" way (don't merge Thanksgivings, do merge New Years and Año nuevo) will be very hard to do without making a table of equivalent holidays.

I'll leave this open as an enhancement to look into more in the future, but that's why there isn't the option to automatically stack country holidays.

In the meantime, you can do this manually and make your own decision for which holiday should be merged or not. Here is how you get a holiday dataframe with country holidays:

from fbprophet.make_holidays import make_holidays_df

year_list = [2016, 2017, 2018, 2019, 2020]
holidays = make_holidays_df(year_list=year_list, country='CN')

You could then do the same thing for US, and then stack them after handling equivalent holidays as you'd like. Pass that dataframe in to Prophet(holidays=holidays).

goncaloperes commented 4 years ago

@bletham this SO thread may be useful as it considers one of the examples on how to handle the holidays. In this case, the question (and answer) will help people that only want to know in which dates for multiple regions there will be an holiday, and it merges the holidays that have the same date in the row of the first one that appears for that specific date.

This is how the output looks like: image

saccpp commented 4 years ago

Hello, Is France holidays available in the make_holidays_df?

bletham commented 4 years ago

Most holidays comes from the holidays package, and France is included there: https://github.com/dr-prodigy/python-holidays

brendan-r commented 3 years ago

Bit off topic, but @saccpp, "FR" fails due to the holidays package, but the data's there.

Until this PR lands to correct it, you can use "FRA" instead of "FR".

saccpp commented 3 years ago

Thanks, I'll check it out.

On Fri, 4 Dec 2020 at 5:28 AM, Brendan Rocks notifications@github.com wrote:

Bit off topic, but @saccpp https://github.com/saccpp, "FR" fails due to the holidays package, but the data's there.

Until this PR0 https://github.com/dr-prodigy/python-holidays/pull/372 lands to correct it, you can use "FRA" instead of "FR".

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/facebook/prophet/issues/909#issuecomment-738460251, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOTFNTSBLIAS6A77INNHPQ3STAQ3TANCNFSM4HCN5QXA .