Deep Transformer Models for Time Series Forecasting: The Influenza Prevalence Case

Neo Wu, Bradley Green, Xue Ben, Shawn O'BanionarXiv 2020

Abstract

Time series forecasting is a critical task across numerous scientific and engineering disciplines. This paper presents a novel approach that adapts Transformer-based machine learning models to forecast time series data by leveraging self-attention mechanisms to learn complex patterns and dynamics. We demonstrate this generic framework using influenza-like illness (ILI) forecasting as a case study. Our results show that the Transformer architecture effectively models both univariate and multivariate time series data, producing forecasting results that are favorably comparable to current state-of-the-art methods.

Introduction

Forecasting time series data is essential for decision-making in fields ranging from finance to public health. In epidemiology, predicting the spread of seasonal influenza is vital for resource allocation and pandemic preparedness. Historically, this task has relied on statistical models like ARIMA or compartmental models like SIR. However, statistical models often struggle with complex non-linear dynamics, while compartmental models require strict prior knowledge of infection parameters.

While deep learning sequence models like Recurrent Neural Networks (RNNs) and Long Short-Term Memory (LSTM) networks have improved upon these methods, they often suffer from vanishing gradients and difficulty maintaining long-term memory. This work explores whether the self-attention mechanisms of Transformer models—which revolutionized natural language processing (NLP) by processing entire sequences simultaneously—can be successfully adapted to solve complex time series forecasting problems.

Methodology

We formulate time series forecasting as a supervised machine learning task using a fixed-length sliding window over historical data to predict future data points. The model architecture closely follows the original Transformer design, consisting of an encoder and a decoder.

The Transformer architecture adapted for time series forecasting, featuring encoder and decoder layers with multi-head self-attention.

Architecture Components

  • Encoder: Maps historical time series data into a high-dimensional vector. Since Transformers lack inherent sequential processing, we add a positional encoding (using sine and cosine functions) to the input to retain temporal order. The data then passes through multi-head self-attention and feed-forward layers.
  • Decoder: Employs "look-ahead masking" to ensure that predictions for a specific time step depend only on past data points, preventing data leakage. It applies self-attention over the encoder's output to generate multi-step future predictions.

A unique aspect of this application is the use of Time Delay Embeddings (TDEs) to model the underlying "phase space" of the dynamical system. This allows the model to capture the geometrical and topological information of the biological system driving influenza spread.

Experimental Setup

The model was evaluated using historical ILI data provided by the Centers for Disease Control and Prevention (CDC). The dataset includes weekly ILI ratios at both the national and state levels from 2010 to 2018. Data was preprocessed using min-max scaling and structured into training and testing sets using a sliding window approach (e.g., using 10 weeks of history to predict 4 weeks into the future).

Key Results and Discussion

The Transformer model demonstrated significant improvements over traditional baselines and parity with specialized state-of-the-art models.

  • Performance vs. Baselines: In 1-step ahead prediction tasks, the Transformer achieved a Pearson correlation of 0.928 and an RMSE of 0.588. This represents a 42.4% reduction in RMSE compared to the ARIMA baseline, and it outperformed standard LSTMs and Seq2Seq models.
  • Comparison with State-of-the-Art: The Transformer performed on par with ARGONet, a complex ensemble model specifically designed for ILI forecasting. As shown in the state-by-state comparison, the Transformer maintains competitive RMSE values across various geographical regions.
Comparison of RMSE between ARGONet and the Transformer model across different US states, showing comparable performance.
  • Implicit Feature Engineering: Interestingly, adding explicit features like "week number" or temporal derivatives did not significantly improve performance. This suggests that the self-attention mechanism is inherently capable of learning seasonal trends and dynamics directly from raw time series data.

Conclusion

This work demonstrates that Transformer models are highly effective for time series forecasting, particularly in the complex domain of epidemiological modeling. By replacing recurrence with self-attention, the model captures long-range dependencies and complex dynamics more efficiently than previous deep learning architectures. Future work will focus on extending this framework to handle spatio-temporal data, allowing the model to learn geographical relationships and the spatial spread of disease over time.

Summary updated

BibTeX
@misc{wu2020deep,
  author = {Neo Wu and Bradley Green and Xue Ben and Shawn O'Banion},
  title = {{Deep Transformer Models for Time Series Forecasting: The Influenza Prevalence Case}},
  year = {2020},
  eprint = {2001.08317},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2001.08317},
}
Figure