Time Series2019intermediate10 min read
N-BEATS: Neural Basis Expansion Analysis for Interpretable Time Series Forecasting
N-BEATS: تحليل التوسّع بدوال الأساس العصبية للتنبؤ التفسيري بالسلاسل الزمنية
Oreshkin, B. N. · Carpov, D. · Chapados, N. · Bengio, Y. — ICLR
The problem
By 2019 had revolutionized computer vision and NLP, yet in it lagged embarrassingly behind. In the M4 competition — the Olympics of forecasting — the six "pure ML" entries ranked 23rd, 37th, 38th, 48th, 54th, and 57th out of 60. The winner was a hand-crafted hybrid that glued an LSTM to a classical Holt-Winters statistical model. The prevailing wisdom was that deep learning alone could not compete with domain-tuned statistical methods for .
The contribution
N-BEATS proved that pure deep learning — using nothing but fully connected layers with activations — can beat both statistical benchmarks and hand-crafted hybrids on M3, M4, and TOURISM datasets. It improved over the statistical benchmark by 11% and over the M4 competition winner by 3%. The key innovation is "doubly stacking": each block produces a (what it explains about the past) and a (its prediction), then subtracts the backcast from the input so the next block works on the unexplained remainder. An interpretable variant constrains blocks to use polynomial () and Fourier (seasonality) basis functions, producing human-readable decompositions with minimal accuracy loss.
The impact
N-BEATS shattered the myth that deep learning cannot work for time series forecasting. It inspired a wave of pure-DL forecasting architectures including N-HiTS, and demonstrated that interpretable deep learning is achievable without sacrificing accuracy. The doubly residual stacking pattern influenced subsequent models like DLinear and Informer. Its success on the M4 benchmark motivated the entire field to take neural forecasting seriously, leading to the DL-dominated leaderboards we see today.
Imagine a team of musicians learning a song by ear. The first musician listens to the full recording and plays back the bass line — then subtracts it from the recording. The second musician hears only what's left and picks out the melody. The third catches the percussion. Each one explains a layer, removes it, and passes the remainder to the next.
When they finally perform together, the full song emerges as the sum of all their parts. No single musician needs to understand the entire piece — each only needs to capture what the others missed.
N-BEATS works exactly like this of musicians: a chain of simple neural blocks, each explaining one layer of the time series signal, subtracting its explanation, and forwarding the unexplained residual.
The gap: why deep learning struggled with time series
Before N-BEATS, statistical methods like ARIMA, Exponential Smoothing (ETS), and the Theta method dominated forecasting competitions. These methods explicitly model trend, seasonality, and noise — components that practitioners understand and can inspect.
Deep learning models attempted to replace this with end-to-end learning, but they consistently underperformed. The reasons were threefold: (1) forecasting datasets are often small — thousands of short series, not millions of images; (2) standard architectures like RNNs and LSTMs added complexity without sufficient inductive for the task; (3) practitioners distrusted black-box models whose outputs could not be decomposed into interpretable components.
The M4 competition in 2018 made this gap painfully visible. Its 100,000 time series spanned yearly, quarterly, monthly, weekly, daily, and hourly frequencies from domains including finance, demographics, and industry. Pure ML methods were comprehensively outperformed.
The basic block: predict forward, explain backward
The atomic unit of N-BEATS is the basic block. Think of it as a worker on an assembly line who receives a piece of the time series signal (the lookback window), does two things simultaneously, and passes the remainder downstream.
The block takes an input (a window of past observations) and passes it through a of fully connected layers with ReLU activations. This produces a hidden representation that captures patterns in the input. From this representation, the block produces two sets of expansion coefficients and via separate linear layers.
These coefficients are then multiplied by basis functions and to produce two outputs: a backcast which is the block's best reconstruction of its input, and a forecast which is the block's prediction of future values.
The mental model is simple: the backcast says "here is what I understood about the past", the forecast says "here is what I predict for the future based on what I understood."
Doubly residual stacking: subtract what you explained
The backcast is not just a diagnostic — it is the mechanism that makes the whole architecture work. After block produces its backcast , the input to the next block is the residual: the original input minus what block explained.
This is the backward residual: each block peels away the signal component it captured, so the next block works on a cleaner, simpler remainder. Imagine stripping layers of paint from a canvas — each layer reveals what is underneath.
Simultaneously, each block's forecast is accumulated into the final prediction. This is the forward residual: the overall forecast is the sum of partial forecasts from all blocks. No single block needs to predict the entire future — each contributes its piece.
Together, these two residual paths give the architecture its name: doubly residual stacking. The backward path ensures progressive signal , while the forward path ensures all components contribute to the final prediction.
Stacks: organizing blocks into functional groups
Blocks are grouped into stacks. Within each stack, blocks share the same type of basis functions and , and in the interpretable configuration they even share weights across blocks in the same stack.
In the generic (N-BEATS-G) configuration, each block uses learnable linear layers as basis functions — no constraints, maximum expressiveness. The model typically uses 30 stacks with 1 block each.
In the interpretable (N-BEATS-I) configuration, only two stacks are used: a trend stack followed by a seasonality stack, each containing 3 blocks. The trend stack uses polynomial basis functions, the seasonality stack uses Fourier basis functions. The doubly residual stacking ensures that the trend is removed before the seasonality stack sees the signal — exactly mirroring classical decomposition.
Interpretable basis: trend as polynomials, seasonality as harmonics
The interpretable configuration constrains the basis functions to known mathematical forms. The key idea is that if we force the network to express its outputs using specific shapes, those shapes become human-readable.
Trend basis: a polynomial of small degree . Given a time vector , the trend output is . A degree-2 polynomial captures constant, linear, and quadratic trends — the same shapes a human analyst would sketch. The network does not learn the polynomial structure — it only learns the coefficients .
Seasonality basis: a truncated Fourier series. The basis functions are and for harmonics . This constrains the output to periodic patterns — exactly the shapes needed to capture weekly, monthly, or yearly cycles.
Ensembling: the final accuracy boost
N-BEATS uses model ensembling as its primary regularization strategy — not or L2 penalties. The authors found that multiple models with different random seeds and averaging their forecasts was far more effective than standard regularization.
The final N-BEATS ensemble averages 180 models: 3 lookback window lengths × 3 loss functions (MAPE, MASE, sMAPE) × 20 random seeds. This ensemble width is what closes the gap from strong to state-of-the-art. The diversity in lookback windows means some models focus on short-term patterns while others capture longer dependencies. The diversity in loss functions ensures the ensemble is robust to different error metrics.
Results: pure DL beats hand-crafted hybrids
On the M4 dataset (100K series), N-BEATS-G achieved an OWA of 0.821 — beating the M4 competition winner (ES-RNN with OWA 0.838) by 3% and the statistical benchmark by 11%. The interpretable variant N-BEATS-I achieved OWA 0.847, which still outperformed the M4 winner.
On M3 (3,003 series) and TOURISM (1,311 series), N-BEATS similarly achieved state-of-the-art results. These datasets span vastly different domains and frequencies, demonstrating that the architecture generalizes without any domain-specific modifications.
The confirmed that doubly residual stacking (vs parallel or last-forward alternatives) was essential. Removing the backward residual degraded performance significantly, validating the core architectural innovation.
Simplified to show the idea — not the real implementation.
import torch
import torch.nn as nn
class NBeatsBlock(nn.Module):
def __init__(self, lookback, horizon, hidden=256, n_layers=4):
super().__init__()
# Stack of FC + ReLU layers
layers = [nn.Linear(lookback, hidden), nn.ReLU()]
for _ in range(n_layers - 1):
layers += [nn.Linear(hidden, hidden), nn.ReLU()]
self.fc_stack = nn.Sequential(*layers)
# Expansion coefficient projections
self.theta_b = nn.Linear(hidden, lookback) # backcast coeffs
self.theta_f = nn.Linear(hidden, horizon) # forecast coeffs
def forward(self, x):
h = self.fc_stack(x) # latent representation
backcast = self.theta_b(h) # "what I explained"
forecast = self.theta_f(h) # "what I predict"
return backcast, forecast
Legacy: the neural forecasting revolution
2018
M4 Competition — statistical methods still dominate
Pure ML entries ranked near the bottom. The winner ES-RNN was a hand-crafted hybrid of LSTM and Holt-Winters. The field concluded that DL alone was not ready.
2019
N-BEATS (this paper)
Proved pure DL can beat both statistical and hybrid methods. Introduced doubly residual stacking and interpretable basis expansion. Changed the narrative entirely.
2021
N-HiTS — hierarchical interpolation
Extended N-BEATS with multi-rate signal sampling, allowing blocks to focus on different temporal scales. Achieved better long-horizon forecasts.
2023
DLinear and PatchTST challenge Transformer forecasters
Simple linear models (inspired by N-BEATS' pure-DL philosophy) showed that complex Transformer architectures were often unnecessary for forecasting — echoing N-BEATS' original lesson.
N-BEATS fundamentally changed how the forecasting community views deep learning. Before it, the question was whether DL could work at all for time series. After it, the question became how to build on its success. Its core ideas — progressive residual decomposition, for , and heavy ensembling — have become foundational patterns in neural forecasting.
CitationOreshkin, Carpov, Chapados, Bengio. N-BEATS: Neural basis expansion analysis for interpretable time series forecasting. ICLR, 2020.
Terms in this paper
- Forecastالتنبؤ
- Backpropagationالتحديث التراجعي
- Residual Connectionالوصلة التجاوزية
- Fully Connected Layerالطبقة كاملة الاتصال
- ReLUدالة الوحدة الخطية المصححة
- Basis Functionدالة الأساس
- Ensembleالنماذج التجميعية الهجينة
- Interpretabilityالقابلية للتفسير
- Loss functionدالة الخسارة
- Deep Learningالتعلم العميق
- Neural Networkالشبكة العصبية
- Multi-Layer Perceptron (MLP)البيرسبترون متعدد الطبقات
- Decompositionالتفكيك
- Residualالبُعد المتبقّي
- weight sharingمشاركة الأوزان