# Self-Attention ConvLSTM for Spatiotemporal Forecasting of Short-Term Online Car-Hailing Demand

^{1}

^{2}

^{3}

^{*}

## Abstract

**:**

## 1. Introduction

## 2. Related Work

## 3. Preliminaries

#### 3.1. Detailed Definitions

**Definition**

**1**

**(Geographic grid).**

**Definition**

**2**

**(Travel demand).**

**Definition**

**3**

**(Demand prediction task).**

#### 3.2. ConvLSTM Model

#### 3.3. Self-Attention Module

- (1).
- Feature Aggregation. The similarity scores of each pair of points are calculated by applying the matrix production as:

- (2).
- Memory Updating. A gating mechanism is used to update the memory $\mathcal{M}$ adaptively, so that the self-attention module can capture long-range dependencies in terms of spatial and temporal domains. The aggregated feature $Z$ and the original input ${\mathcal{H}}_{t}$ are used to produce values of the input gate ${{i}^{\prime}}_{t}$ and the fused feature ${{g}^{\prime}}_{t}$. Besides, the forget gate is replaced as $1-{{i}^{\prime}}_{t}$ to reduce parameters. The updating progress can be formulated as follows [36]:

- (3).
- Output. Finally, the output feature ${\widehat{\mathcal{H}}}_{t}$ is a dot product between the output gate ${{o}^{\prime}}_{t}$ and updated memory ${\mathcal{M}}_{t}$, which can be formulated as follows [36]:

#### 3.4. Self-Attention ConvLSTM Model

## 4. Experiments

#### 4.1. Dataset

^{2}in size, and the research area was divided into 53 × 67 grids. Figure 8 illustrates the process of trajectory data acquisition and image conversion. Second, with a time interval of 10 min, the online car-hailing demand in different regions was counted. Three cumulative demand images are shown in Figure 8, which are the time units 00:00, 11:00, and 23:00 on 1 November. These three images from the spatial dimension yield the observation that there are many grids with missing data. There are three main reasons for this incomplete data: first, the travel proportion of online car-hailing is not high, and the vehicle trajectories cannot cover all areas; second, a large amount of land in the city is non-urban roads such as vegetation or buildings, and the demand of online car-hailing is 0; and third, the grid size is too small. Similarly, in the time dimension, there are also a lot of vacancies in data, which is caused by fluctuations of the demand for online car-hailing in time. For example, at midnight, the demand for online car-hailing is far less than during the morning and evening rush hours.

#### 4.2. Evaluation Metrics

^{2}), which can be defined as follows:

#### 4.3. Training Configuration

#### 4.4. Analysis and Discussion of Prediction Performance

^{2}, mainly because our method accounts for both the local and global correlations between the online car-hailing demand in the research area. It fully explored the spatial and temporal characteristics. Although LSTM and GRU could extract the long-term dependence effectively, it was not good at spatial feature mining. Compared to LSTM and GRU, the bi-directional mechanism made Bi-LSTM and Bi-GRU more superior in extracting the temporal features of the periodicity of time-series pixels and the contextual relationship of pixels, but they were also insufficient in capturing spatial features. The CNN was not good at temporal feature mining. ConvLSTM was superior to them in spatiotemporal feature mining. Figure 11 shows the prediction results of the 1st, 40th, 80th, and 120th cropped image sub-images at 12:00 on 30 November, respectively. The self-attention module that considers additional memory units was effective.

## 5. Conclusions

## Author Contributions

## Funding

## Data Availability Statement

## Conflicts of Interest

## References

- Lu, M.; Lai, C.; Ye, T.; Liang, J.; Yuan, X. Visual Analysis of Multiple Route Choices Based on General GPS Trajectories. IEEE Trans. Big Data
**2017**, 3, 234–247. [Google Scholar] [CrossRef] - Vlahogianni, E.I.; Karlaftis, M.G.; Golias, J.C. Short-term traffic forecasting: Where we are and where we’re going. Transp. Res. Part C Emerg. Technol.
**2014**, 43, 3–19. [Google Scholar] [CrossRef] - Okutani, I.; Stephanedes, Y.J. Dynamic prediction of traffic volume through Kalman filtering theory. Transp. Res. Part B Methodol.
**1984**, 18, 1–11. [Google Scholar] [CrossRef] - Chen, H.; Grant-Muller, S. Use of sequential learning for short-term traffic flow forecasting. Transp. Res. Part C-Emerg. Technol.
**2001**, 9, 319–336. [Google Scholar] [CrossRef] - Cai, L.R.; Zhang, Z.C.; Yang, J.J.; Yu, Y.D.; Zhou, T.; Qin, J. A noise-immune Kalman filter for short-term traffic flow forecasting. Phys. A Stat. Mech. Appl.
**2019**, 536, 122601. [Google Scholar] [CrossRef] - Chien, S.I.J.; Kuchipudi, C.M. Dynamic travel time prediction with real-time and historic data. J. Transp. Eng.
**2003**, 129, 608–616. [Google Scholar] [CrossRef] - Ahmed, M.S.; Cook, A.R. Analysis of freeway traffic time-series data by using Box-Jenkins techniques. Transp. Res. Rec.
**1979**, 773, 1–9. [Google Scholar] - Nihan, N.L.; Holmesland, K.O. Use of the Box and Jenkins Time Series Technique in Traffic Forecasting. Transportation
**1980**, 9, 125–143. [Google Scholar] [CrossRef] - Xu, J.; Rahmatizadeh, R.; Boloni, L.; Turgut, D. Real-Time Prediction of Taxi Demand Using Recurrent Neural Networks. IEEE Trans. Intell. Transp. Syst.
**2018**, 19, 2572–2581. [Google Scholar] [CrossRef] - Jiang, X.M.; Adeli, H. Dynamic wavelet neural network model for traffic flow forecasting. J. Transp. Eng.
**2005**, 131, 771–779. [Google Scholar] [CrossRef] - Zhang, H.; Wang, X.M.; Cao, J.; Tang, M.N.; Guo, Y.R. A multivariate short-term traffic flow forecasting method based on wavelet analysis and seasonal time series. Appl. Intell.
**2018**, 48, 3827–3838. [Google Scholar] [CrossRef] - Disbro, J.E.; Frame, M. Traffic Flow Theory and Chaotic Behavior. Transp. Res. Rec. J. Transp. Res. Board
**1989**, 1225, 109–115. [Google Scholar] - Forbes, G.J.; Hall, F. The applicability of catastrophe theory in modelling freeway traffic operations. Transp. Res. Part A Gen.
**1990**, 24, 335–344. [Google Scholar] [CrossRef] - Smith, B.L.; Demetsky, M.J. Short-term traffic flow prediction: Neural network approach. Transp. Res. Rec.
**1994**, 1453, 98–104. [Google Scholar] - Cheng, T.; Haworth, J.; Wang, J. Spatio-temporal autocorrelation of road network data. J. Geogr. Syst.
**2012**, 14, 389–413. [Google Scholar] [CrossRef] - Dia, H. An object-oriented neural network approach to short-term traffic forecasting. Eur. J. Oper. Res.
**2001**, 131, 253–261. [Google Scholar] [CrossRef] [Green Version] - Yu, F.; Xu, X.Z. A short-term load forecasting model of natural gas based on optimized genetic algorithm and improved BP neural network. Appl. Energy
**2014**, 134, 102–113. [Google Scholar] [CrossRef] - Castro-Neto, M.; Jeong, Y.S.; Jeong, M.K.; Han, L.D. Online-SVR for short-term traffic flow prediction under typical and atypical traffic conditions. Expert Syst. Appl.
**2009**, 36, 6164–6173. [Google Scholar] [CrossRef] - An, J.Y.; Fu, L.; Hu, M.; Chen, W.H. A Novel Fuzzy-Based Convolutional Neural Network Method to Traffic Flow Prediction with Uncertain Traffic Accident Information. IEEE Access
**2019**, 7, 20708–20722. [Google Scholar] [CrossRef] - Sitorus, C.M.; Rizal, A.; Jajuli, M. Prediksi Risiko Perjalanan Transportasi Online Dari Data Telematik Menggunakan Algoritma Support Vector Machine. J. Tek. Inform. Sist. Inf.
**2020**, 6, 254–265. [Google Scholar] [CrossRef] - Stefano, C.; Ernesto, C.; Livia, M.; Marialisa, N. Dynamic demand estimation and prediction for traffic urban networks adopting new data sources. Transp. Res. Part C
**2017**, 81, 83–98. [Google Scholar] - Nie, Y.M. How can the taxi industry survive the tide of ridesourcing? Evidence from Shenzhen, China. Transp. Res. Part C Emerg. Technol.
**2017**, 79, 242–256. [Google Scholar] [CrossRef] - Yu, D.B.; Li, Z.P.; Zhong, Q.L.; Yi, A.; Chen, W. Demand Management of Station-Based Car Sharing System Based on Deep Learning Forecasting. J. Adv. Transp.
**2020**, 2020, 8935857. [Google Scholar] [CrossRef] - Jiang, S.; Chen, W.T.; Li, Z.H.; Yu, H.Y. Short-Term Demand Prediction Method for Online Car-Hailing Services Based on a Least Squares Support Vector Machine. IEEE Access
**2019**, 7, 11882–11891. [Google Scholar] [CrossRef] - Rahman, M.H.; Rifaat, S.M. Using spatio-temporal deep learning for forecasting demand and supply-demand gap in ride-hailing system with anonymized spatial adjacency information. IET Intell. Transp. Syst.
**2021**, 15, 941–957. [Google Scholar] [CrossRef] - Ke, J.T.; Zheng, H.Y.; Yang, H.; Chen, X.Q. Short-term forecasting of passenger demand under on-demand ride services: A spatio-temporal deep learning approach. Transp. Res. Part C Emerg. Technol.
**2017**, 85, 591–608. [Google Scholar] [CrossRef] [Green Version] - Chen, Z.; Zhao, B.; Wang, Y.H.; Duan, Z.T.; Zhao, X. Multitask Learning and GCN-Based Taxi Demand Prediction for a Traffic Road Network. Sensors
**2020**, 20, 3776. [Google Scholar] [CrossRef] [PubMed] - Geng, X.; Li, Y.G.; Wang, L.Y.; Zhang, L.Y.; Liu, Y. Spatiotemporal Multi-Graph Convolution Network for Ride-Hailing Demand Forecasting. Proc. AAAI Conf. Artif. Intell.
**2019**, 33, 3656–3663. [Google Scholar] [CrossRef] [Green Version] - Liu, Y.; Lyu, C.; Khadka, A.; Zhang, W.B. Spatio-Temporal Ensemble Method for Car-Hailing Demand Prediction. IEEE Trans. Intell. Transp. Syst.
**2020**, 21, 5328–5333. [Google Scholar] [CrossRef] - Wang, D.J.; Yang, Y.; Ning, S.M. DeepSTCL: A Deep Spatio-temporal ConvLSTM for Travel Demand Prediction. In Proceedings of the 2018 International Joint Conference on Neural Networks (IJCNN), Rio de Janeiro, Brazil, 8–13 July 2018; pp. 1–8. [Google Scholar]
- Tan, L.Y.; Zhang, Z.Y.; Jiang, W.W. Ride-Hailing Service Prediction Based on Deep Learning. Int. J. Mach. Learn. Comput.
**2022**, 12, 1. [Google Scholar] - Lu, X.J.; Ma, C.X.; Qiao, Y.H. Short-term demand forecasting for online car-hailing using ConvLSTM networks. Phys. A
**2010**, 570, 125838. [Google Scholar] [CrossRef] - Yao, H.X.; Wu, F.; Ke, J.T.; Tang, X.F.; Jia, Y.T.; Lu, S.Y.; Gong, P.H.; Ye, J.P.; Li, Z.H. Deep Multi-View Spatial-Temporal Network for Taxi Demand Prediction. Proc. AAAI Conf. Artif. Intell.
**2018**, 32, 2588–2595. [Google Scholar] - Savchuk, O. Large-Scale Dynamics of Hypoxia in the Baltic Sea. Chem. Struct. Pelagic Redox Interfaces
**2010**, 22, 137–160. [Google Scholar] - Shi, X.J.; Chen, Z.R.; Wang, H.; Yeung, D.Y.; Wong, W.K.; Woo, W.C. Convolutional LSTM Network: A Machine Learning Approach for Precipitation Nowcasting. Adv. Neural Inf. Processing Syst.
**2015**, 28, 802–810. Available online: https://proceedings.neurips.cc/paper/2015/file/07563a3fe3bbe7e3ba84431ad9d055af-Paper.pdf (accessed on 28 May 2022). - Lin, Z.H.; Li, M.M.; Zheng, Z.B.; Cheng, Y.Y.; Yuan, C. Self-Attention ConvLSTM for Spatiotemporal Prediction. Proc. AAAI Conf. Artif. Intell.
**2020**, 34, 11531–11538. [Google Scholar] [CrossRef] - Ioffe, S.; Szegedy, C. Batch Normalization: Accelerating Deep Network Training by Reducing Internal Covariate Shift. Int. Conf. Mach. Learn.
**2015**, 37, 448–456. Available online: http://proceedings.mlr.press/v37/ioffe15.pdf (accessed on 28 May 2022). - Didi Chuxing. Available online: https://outreach.didichuxing.com/app-vue/HaiKou? (accessed on 1 March 2021).
- Krizhevsky, A.; Sutskever, I.; Hinton, G. ImageNet classification with deep convolutional neural networks. Commun. ACM
**2017**, 60, 84–90. [Google Scholar] [CrossRef] - Schlaich, J. Analyzing route choice behavior with mobile phone trajectories. Transp. Res. Rec.
**2010**, 2157, 78–85. [Google Scholar] [CrossRef] - Gindele, T.; Brechtel, S.; Dillmann, R. A probabilistic model for estimating driver behaviors and vehicle trajectories in traffic environments. IEEE Trans. Intell. Transp. Syst.
**2010**, 17, 2751–2766. [Google Scholar] - Tinessa, F.; Marzano, V.; Papola, A.; Montanino, M.; Simonelli, F. CoNL route choice model: Numerical assessment on a real dataset of trajectories. In Proceedings of the 2019 6th International Conference on Models and Technologies for Intelligent Transportation Systems (MT-ITS), Cracow, Poland, 5–7 June 2019; pp. 1–10. [Google Scholar]

**Figure 3.**ConvLSTM cell diagram [35].

**Figure 4.**The illustration of the self-attention module [36].

**Figure 5.**The usage of self-attention module for the ConvLSTM (SA-ConvLSTM) [36].

**Figure 9.**The cumulative online car-hailing demand. These three images are the new cumulative demand images at 00:00, 11:00, and 23:00, respectively, on 1 November after the merged grid granularity.

**Figure 11.**The prediction results of four image subgraphs at 12:00 on 30 November. (

**a**–

**d**) represent the predicted values of each subgraph, respectively; (

**a’**–

**d’**) represent the ground truth values of each subgraph, respectively.

Driver ID | Order ID | Timestamp | Longitude | Latitude |
---|---|---|---|---|

XXXXXX | XXXXXX | 1477969147 | 104.0751 | 30.72724 |

Layer (Type) | Output Shape | Parameter |
---|---|---|

InputLayer | (None, None, 20, 20, 1) | 0 |

SaConvLSTM2D_1 | (None, None, 20, 20, 10) | 4800 |

BatchNormalization_1 | (None, None, 20, 20, 10) | 40 |

SaConvLSTM2D_2 | (None, None, 20, 20, 10) | 8040 |

BatchNormalization_2 | (None, None, 20, 20, 10) | 40 |

SaConvLSTM2D_3 | (None, None, 20, 20, 10) | 8040 |

BatchNormalization_3 | (None, None, 20, 20, 10) | 40 |

Conv3D | (None, None, 20, 20, 1) | 271 |

Model | Performance Indices | |||
---|---|---|---|---|

SSIM (%) | MAE | RMSE | R^{2} (%) | |

LSTM | 32.97 | 75.47 | 134.03 | 40.37 |

GRU | 34.25 | 73.85 | 133.36 | 41.89 |

Bi-GRU | 46.22 | 52.92 | 101.26 | 65.56 |

Bi-LSTM | 48.03 | 52.81 | 101.34 | 65.62 |

CNN | 93.00 | 27.11 | 51.78 | 91.23 |

ConvLSTM | 94.47 | 20.86 | 43.31 | 93.83 |

SA-ConvLSTM | 95.15 | 19.31 | 38.62 | 95.11 |

Publisher’s Note: MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations. |

© 2022 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).

## Share and Cite

**MDPI and ACS Style**

Ge, H.; Li, S.; Cheng, R.; Chen, Z.
Self-Attention ConvLSTM for Spatiotemporal Forecasting of Short-Term Online Car-Hailing Demand. *Sustainability* **2022**, *14*, 7371.
https://doi.org/10.3390/su14127371

**AMA Style**

Ge H, Li S, Cheng R, Chen Z.
Self-Attention ConvLSTM for Spatiotemporal Forecasting of Short-Term Online Car-Hailing Demand. *Sustainability*. 2022; 14(12):7371.
https://doi.org/10.3390/su14127371

**Chicago/Turabian Style**

Ge, Hongxia, Siteng Li, Rongjun Cheng, and Zhenlei Chen.
2022. "Self-Attention ConvLSTM for Spatiotemporal Forecasting of Short-Term Online Car-Hailing Demand" *Sustainability* 14, no. 12: 7371.
https://doi.org/10.3390/su14127371