How To Make STGNNsCapable of Forecasting Long-term Multivariate Time Series Data?
Last Updated on July 28, 2022 by Editorial Team
Author(s): Reza Yazdanfar
Originally published on Towards AI the World’s Leading AI and Technology News and Media Company. If you are building an AI-related product or service, we invite you to consider becoming an AI sponsor. At Towards AI, we help scale AI and technology startups. Let us help you unleash your technology to the masses.
Time Series Forecasting (TSF) data is vital in all industries, from Energy to Healthcare. Researchers have achieved some significant advances through the development of TFS models. By thoroughly considering patterns and their relationships for time series, analysis based on long-dependencies in the dataset is a must. This article is about designing a new model based on another model to perform on long-dependencies and produced segment-level representations. This model stands on STEP, an abbreviation of STGNN (Spatial-Temporal Graph Neural Networks) + Enhanced + Pre-training model.
STEP:
First of all, Do Not Be Confused:
- Spatial-temporal graph data = multivariate timeΒ series
Here, the data (traffic flow) used is recorded time series data on the road byΒ sensors.
Did you see those two patterns in Figure 1Β above??
Answer: there are two repeating patterns: 1. daily 2. weekly periodicities
First, STGNNs is the abbreviation of βSpatial-Temporal Graph Neural Networksβ for those who donβt know/ know meager. (not difficult, it just needed to be googled; mentioned for those who donβt want to lose time or be distracted)
STGGNNs = Sequential Networks + Graph Neural NetworksΒ (GNNs)
We use GNNs for dealing with relationships between time series and Sequential models for instructing time series patterns. By the combination of these two terms, we can grasp outstanding results. By the way, there is no free lunchβββas researchers said. It means powerful models demand complicated architectures; consequently (in most cases), the computational cost rises (linearly or quadratically) with the input length. Also, donβt forget the size of our time series, which is usually considerable. STGNNs, like other models, can predict small windows to make forecasting. This ability to rely on small windows makes the model unreliable.
Problem: 1. STGNNs canβt capture long-dependencies.
2. The dependency graph isΒ missing.
Solution: STEP (STGNN is Enhanced by a scalable time-series Pre-training)
Β· a modified version ofΒ STGNNs
Illustration:
Two initiatives:
1. proposing TSFormer, a transformer-based block with an autoencoder (encoder-decoder) structure as an unsupervised model. This TSFormer able to capture long dependencies.
2. Proposing a graph architecture learner to learn dependency graphs.
After proposing these two, we just need to weld them for a joint model, that is the final solution. Thatβs it!! Sounds easy?! Letβs make them as simple as possible. π
Letβs see the proposed architecture:
As you can see from figure 2, the model includes twoΒ phases:
phase 1) pre-training
The scheme is a masked autoencoding model which is trained for time series data relying on Transformer blocks (TSFormer). This model is able to capture long-dependencies and turn out segment-level representation which includes some valuable information.
phase 2) forecasting
In this phase, the pre-trained model from the previous phase (which captured long-dependencies) is used to modify the downstream STGNN. Additionally, a discrete and sparse graph learner is designed just in case the pre-defined graph isΒ missing.
Thatβs all I have done in general. Thus, letβs dive more into the details of these twoΒ phases:
1. The Pre-Training Phase
This attempt, I mean using a pre-trained model, is due to an increase of interest (and, of course, results) in applying them in NLP projects. Though pre-trained models are adopted widely in NLP (which is sequential data), there are some differences with time series. You can read its full description in my previous article: βHow to Design a Pre-training Model (TSFormer) For TimeΒ Series?β
2. The Forecasting Phase
The input here is divided into P non-overlapping patches of length L. Our TSFormer produces indications for each input (Si) of the forecasting phase. One of the STGNNsβ features is that they take the newest. Therefore, based on those produced indications by TSFormer, we will modifyΒ STGNNs.
STEP From ZERO | TheΒ Process
- The encoder section in this phase is the same as it is in TSFormer; its description is not provided here to prevent making this article too long. If you want to know the details, you can read another article I have demonstrated completely(How to Design a Pre-training Model (TSFormer) For Time Series?).
The structure of learning inΒ graphs
Problem) most graphs depend on a pre-defined graph that is unavailable or not good enough in most casesβalso, mixing the way of learning (seeking the relationship between nodes (for ex. i and j) of the time series and STGNNs leads to great complexity.
Solution) pre-trained TSFormer
Interpretation) Proposing a discrete sparse graph. How? 1. graph regularization to fit supervised information. 2. a KNN graph to rein the sparsity. Its formulations are summarized below:
Downstream spatial-temporal graph neuralΒ network
problem) usual STGNNsβ input: last patch+dependency graph
solution) STEP (which adds the input patchβs representation to theΒ input)
interpretation) As we discussed in my previous article, βHow to Design a Pre-training Model (TSFormer) For Time Series?β, TSFormer captures long-dependencies; consequently, it makes H rich in aspects of information. Also, WaveNet is selected as our backend, which assists in capturing multivariate time series properly. But how?? It blends graph convolution with dilated convolution. Consequently, our forecasts are supported by WaveNetβs output latent, hidden representations. How?? By usingΒ MLP.
Q) If you look at the Forecasting phase architecture, youβd see two streams into Spatial-Temporal Graph NN Block. So, how can we manageΒ that?
A) by usingΒ Eq7:
In the end, the forecasts are made byΒ MLP:
The output of the downstream STGNN:
Thatβs the end of this STGNN modification. Hope you enjoyed. The rest is the results on the real-world dataset.
Results:
data:
The model is trained on three traffic speed datasets in three regions in theΒ USA:
- METR-LA
- PEMS-BAY
- PEMS04
Metrics:
- MAE (Mean AbsoluteΒ Error)
- RMSE (Root Mean AbsoluteΒ Error)
- MAPE (Mean Absolute Percentage Error)
The End
The source isΒ this.
You can contact me on Twitter here or LinkedIn here. Finally, if you have found this article interesting and useful, you can follow me on medium to reach more articles fromΒ me.
How To Make STGNNsCapable of Forecasting Long-term Multivariate Time Series Data? was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.
Join thousands of data leaders on the AI newsletter. Itβs free, we donβt spam, and we never share your email address. Keep up to date with the latest work in AI. From research to projects and ideas. If you are building an AI startup, an AI-related product, or a service, we invite you to consider becoming aΒ sponsor.
Published via Towards AI