I am facing some issues to understand how cross_validation function works in fbprophet packages.

I have a time series of 68 days (only business days) grouped by 15min and a certain metric :

00:00 5 00:15 2 00:30 10 etc 23:45 26

And I really don’t know how to set up my cross_validation function.

I have understand that initial parameter is the training data, but what are period and horizon ?

I have 6528 rows, I want to forecast the next day so my period is 96 ? Because one day = 96 step of 15 min.

Please can you explain me how I have to fill period and horizon parameters. The official documentation of Facebook Prophet is not very understandable.

Thanks a lot.


1 Answer 1


Think about how you would verify the model on your own. You could train it on data in the past, stopping before the present, and then ask the model to predict for a period that you already had data for. That way you can check how accurate it is (either by eye or with error metrics such as MAE, MAPE, RMSE, etc), and adjust accordingly.

cross_validation just automates this process. The first parameter you give is your trained model m (not the data). You then also give the prediction horizon - how frequently you want to predict (in your case '15min', assuming Python). You may then give an initial (how long to train before starting the tests) and a period (how frequently to stop and do a prediction). If you don't give them, Prophet will assign defaults of initial = 3 * horizon, and cutoffs every half a horizon. You then have a long running series of validations, each time predicting forward and calculating the error (you can use the other fbprophet.diagnostics tool, performance_metrics for this). This is somewhat akin to k-fold cross-validation in non-time-series machine learning.

The documentation on this is actually pretty good. See also this blog post for an example in Python.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.