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.53k stars 4.54k forks source link

Not getting what I expect from a Cross Validation using monthly data and cutoffs #2553

Open gvas7 opened 9 months ago

gvas7 commented 9 months ago

Alot of the data I use is only available on monthly schedules, and my forecasts are only important by month (or quarter) so I have to work within those parameters. My data is monthly data starting from 2015-01 and ending in 2023-12.

I build a model in the following manner and get a forecast:

model = Prophet(seasonality_mode='multiplicative')
model.fit(df)
future = model.make_future_dataframe(periods = 12*2, freq='MS')
forecast = model.predict(future)

I wanted to try to perform cross validation by month, but am having trouble getting the result I'd like since I have to use cutoffs. I created cutoffs in monthly starts (my data uses monthly starts as the date), so I write the following:

cutoffs = pd.date_range(start='2019-01-01', end = '2022-12-01', freq='MS')

This gives me what I would expect:

DatetimeIndex(['2019-01-01', '2019-02-01', '2019-03-01', '2019-04-01',
               '2019-05-01', ...
               '2022-09-01', '2022-10-01', '2022-11-01', '2022-12-01'],
              dtype='datetime64[ns]', freq='MS')

I setup my cross validation like this since I can't use a monthly freq (since months are not constant per other comments I've read):

df_cv = cross_validation(model=model, horizon='365 days', cutoffs=cutoffs)

My intention with the cross validation with the cutoff is:

But when I print the frame for cross validation, I get weird horizons that are sometimes a day apart: image

How do I get what I want in terms of CV if am forced to use monthly data? Thanks!

priamai commented 6 months ago

I have exactly the same problem!

asadwecr commented 5 months ago

Hi I face the same issue. Any resolution on this? Many thanks in advance!

aifaehnle commented 5 months ago

Also facing this same issue!