From Pixels to Predictions: Spectrogram and Vision Transformer for Better Time Series Forecasting

Zhen Zeng, Rachneet Kaur, Suchetha Siddagangappa, Tucker Balch, Manuela Veloso

TL;DR

This paper introduces ViT-num-spec, a novel time series forecasting approach that converts raw numerical data into a multimodal image combining a time-frequency spectrogram with a raw intensity stripe. By feeding this visual representation into a Vision Transformer (ViT), the model simultaneously learns temporal and frequency dependencies, outperforming traditional statistical and deep learning baselines across synthetic, weather, and financial datasets.

What Problem Does This Paper Address?

Time series forecasting is notoriously difficult due to inherent noise and complex, non-linear temporal dependencies. Recently, researchers have tried converting time series data into images (like lineplots) to leverage powerful computer vision models.

However, simple lineplots throw away explicit frequency information—like cyclical patterns or transient signals—which are crucial for accurate forecasting. Conversely, pure frequency representations (like Fourier transforms) lose temporal context and the sign of the signal. The authors tackle this gap by creating a unified visual representation that captures both time-domain and frequency-domain features simultaneously.

Methods

The core framework, named ViT-num-spec, consists of three main steps:

  1. Time-Frequency Spectrogram Generation: Instead of Short-Time Fourier Transforms (STFT), which use a fixed window, the authors use the Morlet wavelet transform. This allows them to extract both local spectral and temporal information, making it ideal for non-periodic and transient signals like stock prices.
  2. Multimodal Image Augmentation: Standard spectrograms only show signal strength, losing the sign (positive/negative) of the data. To fix this, the authors add a grayscale "intensity stripe" at the top of the image representing the raw time-series values.
  3. Vision Transformer (ViT) Forecasting: The final $128 \times 128$ image is split into $16 \times 16$ patches and fed into a standard ViT encoder. A lightweight Multi-Layer Perceptron (MLP) head is appended to the encoder to directly predict future numerical values.
Overview of the ViT-num-spec approach

Datasets

The model was evaluated on three distinct datasets representing different levels of complexity and periodicity:

  • Synthetic Data: 150,000 artificially generated time series (length 100) combining short-term oscillations and long-term wave trains using a two-timescale harmonic function.
  • Temperature Data: Daily mean temperatures from 422 weather stations across Australia (7,320 time series of length 60).
  • Financial Data: Daily Adjusted Close prices of S&P 500 constituent stocks from 2000 to 2019 (~58,000 time series segments of length 100).
Visual inputs for the three datasets

Key Insights and Ideas

  • Lineplots are Suboptimal for CV-based Forecasting: The paper shows that ViT-lineplot performs significantly worse than spectrogram-based approaches, proving that standard line charts hide critical structural patterns from computer vision models.
  • The Power of the "Intensity Stripe": Pure spectrograms lose the sign of the signal. Combining the frequency heatmap with a raw intensity row creates a true multimodal input that bridges the gap between time and frequency domains.
  • Transformers as Cross-Modality Learners: Because the ViT processes the image as a sequence of patches across the horizontal time axis, it naturally learns the complex cross-modality relationships between how frequencies shift over time and how raw values behave.

Key Results

The authors compared ViT-num-spec against statistical baselines (Naive, EMA, ARIMA), a deep learning benchmark (DeepAR), and visual variants (ViT-num, ViT-lineplot).

  • Synthetic Data: ViT-num-spec achieved the lowest SMAPE (0.304) and MASE (0.757), drastically outperforming ARIMA (SMAPE 0.549) and DeepAR (SMAPE 1.073).
  • Temperature Data: It led in precision with a SMAPE of 0.125 and MASE of 1.413.
  • Financial Data: While SMAPE and MASE scores were highly competitive across all models due to the near-random nature of stock prices, ViT-num-spec excelled in Sign Accuracy (predicting the direction of movement). When applying a practical 20% standard deviation threshold for actionable trading decisions, its sign accuracy reached 58.4%, outperforming all baselines.
Quantitative evaluation metrics table

Limitations and Future Work

While the paper demonstrates strong results, a few limitations and areas for future exploration remain:

  • Financial Market Randomness: On financial data, absolute error metrics (SMAPE/MASE) showed minimal differentiation between advanced models and simple baselines, highlighting the extreme difficulty of forecasting noisy market data.
  • Computational Overhead: Converting every time series into a $128 \times 128$ image and processing it via a Vision Transformer is computationally heavier than traditional 1D sequence models (like LSTMs or 1D CNNs).
  • Future Directions: The authors suggest that this multimodal visual framework could be extended to harder forecasting tasks and more complex architectures, though specific next steps are not extensively detailed in the text.

Summary updated

BibTeX
@inproceedings{zeng2023from,
  author = {Zhen Zeng and Rachneet Kaur and Suchetha Siddagangappa and Tucker Balch and Manuela Veloso},
  title = {{From Pixels to Predictions: Spectrogram and Vision Transformer for Better Time Series Forecasting}},
  booktitle = {ICAIF},
  year = {2023},
  doi = {10.1145/3604237.3626905},
}
Figure