Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 385
marceloasr Avatar asked Sep 07 '20 15:09

marceloasr


People also ask

How does cross validation work in Prophet?

Prophet includes functionality for time series cross validation to measure forecast error using historical data. This is done by selecting cutoff points in the history, and for each of them fitting the model using data only up to that cutoff point. We can then compare the forecasted values to the actual values.

What is cutoff in Fbprophet?

Cut off points are used to cut the historical data and for each cross-validation fit the model using data only up to cutoff point. You can treat this as the shift size of training period. horizon – forecasting period length.

How does a prophet model work?

At its core, the Prophet procedure is an additive regression model with four main components: A piecewise linear or logistic growth curve trend. Prophet automatically detects changes in trends by selecting changepoints from the data. A yearly seasonal component modeled using Fourier series.

How do I add holidays to my prophet on Facebook?

Specifying Custom Seasonalities You can add other seasonalities (monthly, quarterly, hourly) using the add_seasonality method (Python) or function (R). The inputs to this function are a name, the period of the seasonality in days, and the Fourier order for the seasonality.


1 Answers

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.

like image 64
jtzupan Avatar answered Sep 28 '22 02:09

jtzupan