I am trying to forecast a time series sequence using facebook's prophet
library. My input data is in weekly format and represents some financial data coming every week. I have weekly finance data for 1 year starting 2022-11-27 and ending in 2023-11-19. I observe 3 seasonalities in my data, fall in values from mid of December till start of January, normal values during January to September mid and then again growth in values from September till November mid. Hence I decided to go for three custom seasonalities.
def week_season(low, high, ds):
date = pd.to_datetime(ds)
return (date.weekofyear>=low) and (date.weekofyear<=high)
growth_season = partial(week_season, 38,46)
fall_season = partial(week_season, 47,52)
off_season = partial(week_season, 1,37)
m = Prophet(interval_width=0.95,uncertainty_samples=1000, seasonality_mode='additive',
growth='linear', yearly_seasonality=False, weekly_seasonality=False, daily_seasonality=False)
m.add_seasonality(name='monthly_off', period= 30.5, fourier_order=8, condition_name="off_season")
m.add_seasonality(name='monthly_growth', period= 30.5, fourier_order=8, condition_name="growth_season")
m.add_seasonality(name='monthly_fall', period= 30.5, fourier_order=8, condition_name="fall_season")
df['off_season'] = df['ds'].apply(off_season)
df['growth_season'] = df['ds'].apply(growth_season)
df['fall_season'] = df['ds'].apply(fall_season)
m.fit(df)
future_dates = m.make_future_dataframe(periods=n_forecast, freq='W-SUN', include_history=True)
future_dates['off_season'] = future_dates['ds'].apply(off_season)
future_dates['growth_season'] = future_dates['ds'].apply(growth_season)
future_dates['fall_season'] = future_dates['ds'].apply(fall_season)
forecast = m.predict(future_dates)
I get the output like this:
For two future week start dates 2023-12-10 and 2023-12-17, I am getting 0 as forecast value (marked in red in the above picture). Even the forecast for week starting on 2023-12-3 and 2023-12-24 are also not matching the pattern observed in historical input data. What am I doing wrong or my understanding of prophets forecast is wrong?
I am attaching the plot of prophets component plot for reference.