N-BEATS › Visualizing N-BEATS

Michael BrenndoerferAugust 20, 20254 min read
Machine Learning from ScratchAll chapters
Part 8 of 9Time Series
Chapter 60N-BEATS › Visualizing N-BEATS
Reading section 3 of 8 · Visualizing N-BEATS · 4 minSection 3 of 8 · 4 min

Book contents

Section 3 of 8 · 4 min read

N-BEATS › Visualizing N-BEATSOne section · Sections in this chapter3 / 8 ↓
Reading tools Definitions & inline links

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

Let's create visualizations that show how N-BEATS decomposes time series into interpretable components. These plots will help you understand the model's internal workings and how it separates trend from seasonal patterns.

The first plot shows a synthetic time series with both trend and seasonal components, along with N-BEATS' decomposition. You'll see how the model identifies the dashed trend and seasonal components separately, then combines them into the emphasized final forecast. Here you can see the model's ability to separate different types of patterns in the data.

The second and third plots focus on the basis functions themselves, showing how the polynomial trend functions and trigonometric seasonal functions work. These plots help you understand the mathematical foundation of the decomposition and how different basis functions contribute to the overall forecast.

Out[3]:
Visualization
Time series chart with training data through time 79 and four test-period lines: actual observations, a gently rising dashed trend, an oscillating dashed seasonal component, and their combined N-BEATS forecast.
N-BEATS decomposition of a synthetic time series with trend and seasonal components. The chart preserves the training series and actual test values alongside the dashed trend and seasonal components and their combined N-BEATS forecast.
Out[4]:
Visualization
Multi-line plot showing polynomial basis functions (linear, quadratic, cubic) used for trend decomposition in N-BEATS.
Polynomial trend basis functions used in N-BEATS decomposition. The linear (k=1), quadratic (k=2), and cubic (k=3) functions capture different types of growth patterns, from steady linear growth to accelerating or decelerating trends with inflection points. These functions form the mathematical foundation for N-BEATS' interpretable trend decomposition.
Out[5]:
Visualization
Multi-line plot showing trigonometric basis functions (sine and cosine at different frequencies) used for seasonal decomposition in N-BEATS.
Trigonometric seasonal basis functions used in N-BEATS decomposition. The sine and cosine functions at different harmonic frequencies (k=1, 2, 3, 4) capture periodic patterns with varying complexity. These functions allow N-BEATS to represent seasonal patterns with different phases and multiple peaks and valleys within a single cycle, forming the mathematical foundation for interpretable seasonal decomposition.