marceloasr
marceloasr

Reputation: 375

Trying to Understand FB Prophet Cross Validation

I have a dataset with 84 Monthly Sales (from 01/2013 to 12/2019) - just months, not days.

Month 01 | Sale 1

Month 02 | Sale 2

Month 03 | Sale 3

....     |   ...

Month 84 | Sale 84

By visualization it looks like that the model fits very well... but I need to check it....

So what I understood is that cross val does not support Months, and so what I did was convert to use it w/ days(although there is no day info into my original df)...

I wanted to try my model w/ the first five years(60 months) and leave the 2 remaining years(24 months) to see how well the model is predicting....

So i did something like:

cv_results = cross_validation( model = prophet, initial='1825 days', period='30 days', horizon = '60 days')

Does this make sense?

I did not get the concept of cut off dates and forecast periods

Upvotes: 17

Views: 17069

Answers (2)

mohammad mamun
mohammad mamun

Reputation: 101

Here is the setup:

  • The total number of data points is 700 days
  • Initial is 365 days
  • The period is 10 days
  • The horizon is 20 days

On the 1st iteration, it will train on days 1-365 and will forecast on days 366 to 385. On the 2nd iteration, it will train on days 11-375 and will forecast on days 376 to 395, etc.

Upvotes: 10

jtzupan
jtzupan

Reputation: 596

I struggled with this for a while as well. But here is how it works. The initial model will be trained on the first 1,825 days of data. It will forecast the next 60 days of data (because horizon is set to 60). The model will then train on the initial period + the period (1,825 + 30 days in this case) and forecast the next 60 days. It will continued like this, adding another 30 days to the training data and then forecasting for the next 60 until there is no longer enough data to do this.

In summary, period is how much data to add to the training data set in every iteration of cross-validation, and horizon is how far out it will forecast.

Upvotes: 52

Related Questions