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 xℓ\mathbf{x}_\ell (a window of past observations) and passes it through a of fully connected layers with ReLU activations. This produces a hidden representation hℓ\mathbf{h}_\ell that captures patterns in the input. From this representation, the block produces two sets of expansion coefficients θℓb\theta^b_\ell and θℓf\theta^f_\ell via separate linear layers.

These coefficients are then multiplied by basis functions gbg^b and gfg^f to produce two outputs: a backcast x^ℓ=gb(θℓb)\hat{\mathbf{x}}_\ell = g^b(\theta^b_\ell) which is the block's best reconstruction of its input, and a forecast y^ℓ=gf(θℓf)\hat{\mathbf{y}}_\ell = g^f(\theta^f_\ell) 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."

Open in Lab
The basic block: input flows through FC+ReLU layers, splits into backcast and forecast coefficients, which are multiplied by basis functions to produce outputs.
The demo wakes as you arrive…
hℓ=FCstack(xℓ),x^ℓ=gb(θℓb),y^ℓ=gf(θℓf)\mathbf{h}_\ell = \text{FC}_{\text{stack}}(\mathbf{x}_\ell), \quad \hat{\mathbf{x}}_\ell = g^b(\theta^b_\ell), \quad \hat{\mathbf{y}}_\ell = g^f(\theta^f_\ell)
Basic block operations — from input to backcast and forecast — The input xℓ\mathbf{x}_\ell passes through a stack of FC+ReLU layers to produce a latent vector hℓ\mathbf{h}_\ell. Two linear projections extract expansion coefficients θℓb\theta^b_\ell and θℓf\theta^f_\ell, which are mapped through basis functions gbg^b and gfg^f to yield the backcast and forecast respectively.

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 ℓ\ell produces its backcast x^ℓ\hat{\mathbf{x}}_\ell, the input to the next block is the residual: the original input minus what block ℓ\ell 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 y^ℓ\hat{\mathbf{y}}_\ell 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.

xℓ+1=xℓ−x^ℓ,y^=∑ℓy^ℓ\mathbf{x}_{\ell+1} = \mathbf{x}_\ell - \hat{\mathbf{x}}_\ell, \qquad \hat{\mathbf{y}} = \sum_\ell \hat{\mathbf{y}}_\ell
Doubly residual stacking — backward subtraction and forward aggregation — The backward residual subtracts the backcast from the input: block ℓ+1\ell+1 receives only the unexplained portion. The forward residual accumulates partial forecasts: the final prediction is the sum of all blocks' forecasts. This dual mechanism enables progressive signal decomposition.
Open in Lab
Watch how each block removes its backcast from the signal. The remaining input gets simpler with each block. Toggle blocks to see how partial forecasts accumulate.
The demo wakes as you arrive…

Stacks: organizing blocks into functional groups

Blocks are grouped into stacks. Within each stack, blocks share the same type of basis functions gbg^b and gfg^f, 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 pp. Given a time vector t=[0,1,…,H−1]/H\mathbf{t} = [0, 1, \ldots, H-1]/H, the trend output is gtf(θ)=∑i=0pθi⋅tig^f_t(\theta) = \sum_{i=0}^{p} \theta_i \cdot \mathbf{t}^i. 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 θ\theta.

Seasonality basis: a truncated Fourier series. The basis functions are cos⁡(2πkt)\cos(2\pi k \mathbf{t}) and sin⁡(2πkt)\sin(2\pi k \mathbf{t}) for harmonics k=1,…,Kk = 1, \ldots, K. This constrains the output to periodic patterns — exactly the shapes needed to capture weekly, monthly, or yearly cycles.

gtrendf(θ)=∑i=0pθi t i,gseasonf(θ)=∑k=1K[θ2k−1cos⁡(2πkt)+θ2ksin⁡(2πkt)]g^f_{\text{trend}}(\theta) = \sum_{i=0}^{p} \theta_i \, \mathbf{t}^{\,i}, \qquad g^f_{\text{season}}(\theta) = \sum_{k=1}^{K} \bigl[\theta_{2k-1}\cos(2\pi k\mathbf{t}) + \theta_{2k}\sin(2\pi k\mathbf{t})\bigr]
Interpretable basis functions — polynomial trend and Fourier seasonality — The trend basis generates smooth, slowly varying curves controlled by polynomial degree pp (typically 2–3). The seasonality basis generates periodic patterns controlled by the number of harmonics KK. Together they decompose the signal into human-interpretable components without the network learning the basis shapes — only the coefficients.
Open in Lab
Adjust polynomial degree and number of harmonics to see how trend and seasonality basis functions shape the output.
The demo wakes as you arrive…

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.

Open in Lab
M4 competition results: compare N-BEATS variants against statistical methods and the hybrid competition winner.
The demo wakes as you arrive…
Simplified N-BEATS block in PyTorchpython

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

  1. 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.

  2. 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.

  3. 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.

  4. 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