In recent years, we assist the raise of various time series forecasting frameworks. The most famous is Prophet, an algorithm released by Facebook for forecasting time series with multiple, and complex, seasonalities based on an additive approach. With its release, a new era for time series forecasting begins. For its usability and adaptability to various situations, Prophet recently becomes a valuable alternative to the more classical SARIMA to provide long-term forecasts.
Following the success of Prophet in the Data Science community, big-tech companies start releasing open-source tools for time series forecasting. All these kinds of frameworks declare to provide accurate forecasts in a fast and efficient way (including also automatic tuning) using scalable and intuitive APIs. Given these premises, nowadays carrying out a time series forecasting task seems to be easiest than ever.
We know the power of all these open-source libraries. However, we are conscious that their effectiveness varies according to the case of study. Testing a more standard forecasting pipeline may be beneficial in a lot of situations, to evaluate the best instruments that provide the most accurate forecasts.
In this post, we carry out a simple time series forecasting task. We aim to produce long-term hourly predictions of a series with multiple seasonality patterns. We try to compare Prophet against a standard pipeline made by simple feature engineering and a gradient boosting model. We repeat the experiments introducing also a trend component on the original series to evaluate the procedure when forecasting not stationary series.
THE DATA
We collect a dataset from Kaggle. The Hourly Energy Consumption, as the name suggests, stores the hourly power consumption in megawatts from different parts of the United States across various years.
For our analysis, we select the consumptions of a singular region on which we develop our forecasting models. All the KPIs are stationary and show multiple seasonal patterns according to daily and seasonal behaviors.

MODELING MULTIPLE SEASONALITIES
As the first stage, we model the original time series as is with Prophet and gradient boosting. We use the last year of available data to test the performances and 3 consecutive years from the remaining data for training.

Fitting Prophet is straightforward. No preprocessing is needed since it declares to be robust to outliers, missing data, and change points. It doesn’t require any manual effort because the seasonality patterns are automatically detected by default. Given these premises, providing the forecasts one year in advance for our time series seems an easy task for Prophet.

The predictions show a strong daily and weekly seasonality. Prophet can also detect a long-term seasonality characterized by the increase of energy consumption in the summer and winter periods. The forecasts obtained with Prophet seem reasonable. They outline the basic behavior of energy consumptions and for sure are of great impact.
The next model we want to test is gradient boosting from the sklearn library. We are used to thinking about gradient boosting as an algorithm for tabular data. Apply it in time series forecasting is very easy. We only have to provide adequate features. Our predictors must be accessible anytime in the future since we are producing long-term forecasts and we care to not create leakages.
For this purpose, we create some basic features operating cyclical encoding on temporal variables. This approach is extremely flexible, allowing us to incorporate multiple temporal regressors in numerical format simply applying Fourier transformations. Furthermore, we are aware that the same features are easily retrievable in any future context. In our case, we cyclical encode hours, days of the week, months, weeks of the year, and seasons. The tuning of the parameters is achievable as always with the standard techniques.
As Prophet, gradient boosting reproduces adequately the seasonal patterns. The great difference lies in forecasting error. Gradient boosting reaches a very low error (computed as root mean squared error) on test data compared to Prophet.

MODELING MULTIPLE SEASONALITIES WITH TREND
The gradient boosting makes a good job with this kind of data simply using sinusoidal features. To make things spicer, we introduce an increasing trend on the original time series and try to forecast again.

Dealing with not stationary time series it’s a common practice in real-world applications. By default, Prophet declares to handle trending behaviors in the input series. As before, all we need to do is to provide a time series to fit in a proper format.

Predictions on the test data are very similar to the case without trend but the error on test data drastically increases.
In the case of gradient boosting, the not stationary nature of the target may cause difficulties. So as a preliminary step, we build a simple linear regression (always on the training data) that can model the trend pattern. The predicted trend is subtracted from the training data (to make them stationary) and then added again at prediction time.

After subtracting the predicted trend from the training, modeling with gradient boosting is done as before. The final predictions follow the trend reproducing the seasonality patterns. The test error is again very low compared to Prophet.

SUMMARY
In this post, we carried out a time series forecasting task for long-term predictions. We tested the predictive ability of Prophet against a more classical pipeline made by cyclical encodings of time variables and gradient boosting modeling. We discovered that, for our use case, gradient boosting outperformed Prophet overwhelmingly in terms of test errors. Due to the adaptability of the proposed pipeline, it may be considered a good baseline. Every standard Machine Learning algorithm can be used instead of gradient boosting and every other predictor can be integrated. At the same time, we know that Prophet it’s a good framework which effectiveness depends according to the case of study.
Keep in touch: Linkedin