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.49k stars 4.53k forks source link

Can prophet set the holiday positiveness or negativeness effect on the result of forecasting? #388

Closed axhiao closed 6 years ago

axhiao commented 6 years ago

As far as I know, some holidays or recurring events can be passed in Prophet. According to the docs, it seems that effects of a holiday will be an additional addictive bonus on the result of forecasting. But sometimes, there exist situations where some holidays will have a negative effect on the data. For example: ddd when having a holiday, there is a steep descent. So can Prophet set the holiday positiveness or negativeness effect? Thank you in advance!

bletham commented 6 years ago

"Additive" here means that the effect of the holiday will be to add a certain amount to the other components (like +100 if it is a holiday) as opposed to multiplying by a certain amount (like +10% if it is a holiday).

The amount that is added can be either a positive or negative amount. In this case it will learn that the holiday effect is negative and so it will learn a negative effect. No need to specify.

One thing about this time series though is that the holiday effect is multiplicative. You can see that the holiday effect gets stronger as the y values get larger - so the holiday effect should be -X% (multiplicative) instead of -X (additive).

You can get multiplicative holiday effects by using a log transform. So, take log(y) and pass that into prophet as y. Then take prophet's forecast yhat and take the exponent of it exp(forecast['yhat']) to get back to the original scale. This will also affect the trend model but I think for this time series it should work OK. Native handling of multiplicative seasonality will be coming in the next version.

axhiao commented 6 years ago

Really thank you for your advice! @bletham

bletham commented 6 years ago

No problem!

xiaoyaoyang commented 5 years ago

Is there a way to specify positive holiday? for example a promotion event will most likely drive sales. However, looks like if the holiday is not a fixed date (let's say this year is 05/01 and last year is 04/25) the model will only learn positive effect on 04/25 but not 05/01..

bletham commented 5 years ago

@xiaoyaoyang I'm not exactly sure what you mean. The model learns a single effect for a holiday, which is then applied to all dates for that holiday. So if you specify 05/01/19 and 04/25/18 as two dates of the same holiday, then the holiday effect on them will be the same. You can see this in the documentation if you look at the plot of the holiday effect: The spike is the same size on all of the playoff dates (https://facebook.github.io/prophet/docs/seasonality,_holiday_effects,_and_regressors.html#modeling-holidays-and-special-events).

As for specifying the sign of the holiday effect, there is currently no way to do that; it is entirely fit to the data.

xiaoyaoyang commented 5 years ago

@bletham Thanks, I think I made a mistake by including wide holiday windows...