Search code examples
pandastime-seriesfacebook-prophet

How to set up the cross_validation() function from Prophet?


I'm using Prophet (Python) to predict and analysis time series in bulk. that means that my time series share the same properties, but they are not exactly the same. They all run from 2016-01-01 to 2020-Jul-01.

I would like to cross validate my results using the first 3 years of data, and my forecast goal is 15 days only.

What is the best configuration to test my fit using the first 3 years, aiming for a 15 days forecast?

My naive try is the one below:

df_cv = cross_validation(mts, initial="1095 days", period='31 days', horizon = '15 days')

I'm not sure what to add in the 'period' and in the 'horizon' parameters.


Solution

  • As mentioned in Prophet's documentation:

    We specify the forecast horizon (horizon), and then optionally the size of the initial training period (initial) and the spacing between cutoff dates (period).

    Thus, a forecast is made for every observed point between cutoff and cutoff + horizon.

    So, you can specify any combination of the 'period' and in the 'horizon' parameters as long as their sum is equal to the period for which you want to forecast (15 days).