Traffic Flow Prediction Method Based on Deep Learning

Accurate traffic flow forecasts provide an important data basis for traffic management departments. This paper proposes a traffic flow prediction model based on deep learning, which combines Convolutional Neural Network (CNN), Long Short-term Memory (LSTM) and Support Vector Regression (SVR) features: use CNN neural network to mine the spatial characteristics of traffic flow, and then input the time series features captured by LSTM neural network into the SVR model for traffic prediction. The actual traffic flow data of intersections in Mianyang City are selected to verify the CNN-LSTM-SVR hybrid model, and compare it with the CNN model, LSTM model, and SVR model. The results show that the proposed prediction model has higher prediction accuracy.


CNN Model
The CNN is a type of Feedforward Neural Networks that includes convolution calculations and has a deep structure. It is one of the representative algorithms of deep learning. The study of convolutional neural networks began in the 1980s and 1990s. Time delay networks and LeNet-5 were the first convolutional neural networks; after the 21st century, with the introduction of deep learning theory and With the improvement of numerical computing equipment, convolutional neural networks have been developed rapidly, and have been used in image classification, speech recognition, natural language processing and other fields.
CNN generally consist of three parts, which are convolutional layer, pooling layer, and fully connected layer. The main function of the convolutional layer is feature extraction. The convolution kernel structure in the convolutional layer mimics the characteristics of the animal visual system observing things and first focuses on the local information of the image. It can automatically extract the local spatial characteristics of the data in the receptive field. Slide the core to obtain the complete feature map matrix of the input data; the pooling layer is used for further feature extraction and the dimensionality reduction of the feature maps output by the convolutional layer; the fully connected layer is automatically extracted by the convolutional layer and the pooling layer The multidimensional abstract feature of is expressed as input and vectorized into vector form to complete the final classification or regression goal. Therefore, this paper uses the characteristics of CNN weight sharing to effectively obtain the spatial characteristics of traffic flow while reducing model complexity and computational complexity.

LSTM Model
The LSTM neural network is an improved model based on recurrent neural network proposed by Hochreiter et al. In the training process of the original RNN, as time increases and the number of network layers increases, the problem of gradient explosion or gradient disappearance is prone to occur, so that it is impossible to obtain information about earlier long-distance data. Compared with RNN, the basic unit of the hidden layer of LSTM is a memory module instead of a traditional neuron node, including a self-connected memory cell and three gate units that control the flow of information: input gate, output gate, forget door. The input gate and output gate respectively control the flow of information into and out of neurons. The forget gate can regulate memory cells and control the state of memory cells forgetting or remembering before. This can solve the problem of gradient disappearance, which is also its ability to remember history for a long time. The state of the data and the key to automatically determine the optimal time interval. The cell structure of LSTM is shown in Figure 1.
Since LSTM can learn long-term and short-term dependence information of time series, and the neural network contains time memory units, it is suitable for processing and predicting interval and delay events in time series. So this paper uses LSTM to obtain the time series characteristics of traffic flow.

SVR Model
Support vector machine is a commonly used method in machine learning. It can achieve better function fitting through the mapping relationship between data, using the kernel function and the measurement of the optimal hyperplane, so it is applied to the function fitting regression Forecasting. The short-term traffic flow is a random, non-linear time series. Aiming at the characteristics of support vector regression that can handle non-linear series, the SVR model that selects the radial basis function as the kernel function is used instead of the last layer of neural network as the output of the model.

CLSTMs Model
Combining the weight sharing feature of CNN and the memory feature of LSTM to mine the temporal and spatial characteristics of traffic flow, but because the mined feature has a low dimensionality and a large nonlinearity, the SVR model can map low-dimensional data to a high-dimensional feature space. And it can better fit the nonlinear data, so the SVR model is designed as the top-level prediction model to better realize the traffic flow prediction.
The process of CLSTMs traffic prediction model can be described as:  Preprocess and standardize raw data.  Input the processed data into CNN neural network to extract the spatial characteristics of traffic flow.  Input the CNN processed data into the LSTM layer to extract the time series characteristics of traffic flow.  Input the data processed by LSTM into SVR to predict traffic flow.  De-standardized processing to get the final predicted value. The flow of the model is shown in Figure 2.

Experimental Data
The experimental data in this paper comes from the traffic management department of Mianyang City, and the road section is the east section of Linyuan Road. The traffic flow of three monitoring points with the relationship of "upstream and downstream" on this road is selected for research, as shown in Figure 3.

Data Preprocessing
Taking into account that the original exchange flow data has a large difference in the magnitude of each time period, if the original traffic flow data is directly used for analysis, it will highlight the role of higher traffic flow values and relatively weaken the role of lower traffic flow values . Therefore, in order to ensure the reliability of the prediction results, it is necessary to standardize the original traffic flow data. This paper selects the classic Z-score standardization method: Where is the real traffic flow data, is the mean value of the traffic flow, is the standard deviation of the traffic flow, is the standardized value, and N is the number of samples. After normalization, the mean of all attributes is 0, and the standard deviation is 1.

Evaluation Index
In order to verify the effectiveness of the traffic prediction model, certain evaluation indicators are needed to express the accuracy of the prediction. In this paper, the general evaluation regression model accuracy index is used as the measurement index, and the model parameter adjustment and performance analysis are carried out. Two commonly used indicators are mean absolute error (MAE) and Root Mean Square Error (RMSE) Among them, is the true value; is the predicted value; is the mean value of the true value; N is the number of samples.

Model Training
When studying traffic problems, there is often a certain correlation between the traffic flow at the upstream and downstream intersections. Figure 4 shows the traffic flow information of three adjacent intersections on this road section. It can be seen that the traffic flow at adjacent intersections on this road section has strong similarity and periodicity. Therefore, the traffic flow of these three intersections is used as input, and the spatial and temporal feature information extracted by CNN and LSTM are input into the SVR regression layer to predict the traffic flow of Road2. This project is to complete the model building and training in the IDE JupyterLab in the python development environment.

Experimental Results and Analysis
In order to verify the superiority of the model, this paper selects a single CNN neural network model, LSTM neural network model, and performance comparison between SVR and CLSTMs. The parameter values of SVR, CNN, and LSTM are consistent with those in CLSTMs. The prediction results are shown in Figures 5.  It can be seen that the predicted value of SVR is relatively stable, and the prediction is more accurate when the fluctuation is not large, but the performance is poor in the large fluctuation and peak period; CNN fits better in the peak period and large fluctuation, but The performance is not stable in the case of small fluctuations; the LSTM model performs better in the prediction of stable time series and peak hours, but it performs poorly under abnormal conditions; while the CLSTMs model is in stable periods, peak periods or abnormal conditions , can better fit the real time series of traffic flow and maintain high prediction accuracy.
In order to effectively compare the performance of the models, the experimental value is the average of 10 calculation results. The prediction error results of the four models are shown in Table 1. It can be seen that compared with the other three models, the CLSTMs model has better prediction accuracy in traffic flow prediction.

Conclusion
This paper proposes a CLSTMs traffic flow prediction model. The model uses CNN to extract the spatial information of adjacent intersections. LSTM extracts the time series information of the traffic flow, and then combines the extracted space information and time series information into the SVR model for prediction. It can be seen from the results that the CLSTMs model has higher prediction accuracy than the prediction model that only considers time or space features, and can more truly reflect the changing laws of traffic flow.