A Detailed Explanation of the Workflow of N-BEATS Architecture
Predicting the future has always been a great way to prepare humans for upcoming events. For doing this “Future Prediction” or “Forecasting” time series data are needed. In simple words, time series data are arranged along with a “date” column. There are a lot of algorithms for time series analysis. Years ago, statistical methods were considered to be the best-suited way to predict time series. Gradually, machine learning and deep learning algorithms hopped into the field of time series analysis. Nowadays, time series analysis is becoming so vast that a lot of dedicated algorithms have been invented to forecast the future, N-BEATS (NEURAL BASIS EXPANSION ANALYSIS FOR INTERPRETABLE TIME SERIES) is one of them which will be explained in this article.
This algorithm focuses on forecasting univariate time series data using deep learning. It is a deep neural architecture based on backward and forward residual links and a very deep stack of fully-connected layers.
Let’s get into the algorithm. “A series of past data with length T need to forecast a series of future data of length H”
The given problem will be solved with the N-BEATS algorithm.
In Figure 1, A lookback window enters Box 1. The lookback window is a slice of given past data. The size of the slice may vary due to the preference of the solution to the problem. The length of the lookback window is t. In other words, this lookback window can be called “Model Input”. This Model Input goes to the box called Stack.
Box 2 shows what happens in “Stack” in detail. In Figure 1, it can be seen, the stack input enters Block 1. Box 3 shows what happens in “Block” in detail.
In box 3, the Block input enters a 4-layered Fully Connected stack. The equations of the 4
layered FC stacks are given below.
This FC stack generates a forward predictor θₗᶠ and a backward predictor θₗᵇ. These are coefficients that will help to predict both backcast data and forecast data. These backcast and forecast predictors are generated through a linear function that takes the output of Layer 4 as input. The equations are given below.
FC Layer is a fully connected layer with RELU nonlinearity. For example:
For obvious reasons, the nonlinearity has been maintained to precisely get the output. From the FC layer, we get backward and forward coefficients, it goes to the second and last step of this block which generates brand-new backcast and forecast data. Let it be explained in detail.
With the help of the basis vector gₗᵇ, we get an estimate of xₗ (backcast data). This xl is generated by removing the features of the given input which are not helpful for the calculation of forecasting. In the meantime, yₗ is being produced following the same path with the help of the basis vector gₗᶠ.
gₗᵇ and gₗᶠ are the basic layers for mapping the expansion of backward and forward coefficients.
vᵇ and vᶠ are non-learnable vectors that are set to get better validation performance.
Now let’s get into box 2. In Box 2, the blocks (basically box 1) are stacked following the doubly residual stacking principle. In the doubly residual stacking principle, the difference between the newly generated backcast data (X̂ₗ) and given backcast data (xₗ) has been calculated to improve the trainability of the architecture. Moreover, the principle has also been applied to the forecast data (yₗ). Since from each block partial forecast (ŷₗ) has been generated, by the summation of all the partial forecasts, the final forecast can be found. The doubly residual formula has been given below and the steps are shown in Figure 2.
Box 3 does the summation of the Stacks and gives the global forecast. The whole process of Box 1,2 & 3 runs for a single forecast.
Reference
[1] Oreshkin, B. N., Carpov, D., Chapados, N., & Bengio, Y. (2020, February 20). N-beats: Neural basis expansion analysis for interpretable time series forecasting. arXiv.org. Retrieved November 28, 2022, from https://arxiv.org/abs/1905.10437