Short-term traffic flow prediction method based on deep learning and multi-layer spatiotemporal feature map
Technical Field
The invention belongs to the technical field of machine learning, and particularly relates to a short-term traffic flow prediction method based on deep learning and a multi-layer spatiotemporal feature map.
Background
Traffic flow prediction plays an important role in an Intelligent Transportation (ITS) system, and is a precondition for realizing traffic guidance. The accurate real-time short-term traffic flow prediction is helpful for better analyzing the traffic condition of a road network and is widely applied to the aspects of signal lamp control, urban road system planning, path navigation, vehicle-road coordination and the like. The travel time of people can be reduced, the accident rate is reduced, and great social value and economic value are created. Conventional traffic prediction methods include an autoregressive moving average (ARIMA) model, a Support Vector Machine (SVM) model, a bayesian model, and the like. The emerging artificial neural network can process large-scale multidimensional data, has the characteristics of high model flexibility, strong learning capability, generalization capability, strong prediction capability and the like, and is widely applied to the traffic field.
In order to realize good short-time traffic flow prediction effect, some published patents and papers in the prior art propose respective theoretical solutions. The patent name: a short-time traffic flow prediction method (patent number: CN201910089338.1) based on space-time correlation and convolution neural network discloses a short-time traffic flow prediction method based on space-time correlation and convolution neural network, which mainly adopts Pearson correlation coefficient to analyze the space-time correlation of two traffic flow sequences, makes part of the data obtained by analysis into a single traffic flow matrix, and trains neural network to predict short-time traffic flow according to the single traffic flow matrix.
The prediction method is novel, but still has many problems:
1) firstly, the Pearson correlation coefficient is used for analyzing the space-time correlation in the patent, and the optimal value of the correlation coefficient depends on manual experience, so that the determined time lag and the vehicle detection point can not enable the prediction to achieve the optimal effect. Meanwhile, when the traffic flow sequence data volume is small, it is not appropriate to judge that there is a close relationship between two sequence variables only by the correlation coefficient being large.
2) Secondly, when a space-time traffic matrix data set is prepared in the patent, each sample needs to be subjected to space-time correlation analysis, and if the data volume is overlarge, a large amount of manpower and material resources are consumed to prepare the data set; if the data amount is too small, the trained neural network is easy to be under-fitted.
3) Finally, historical traffic flow data is only used as a sample in the patent, the beneficial effects of time nodes and other traffic data on traffic flow prediction are ignored, and the prediction accuracy and the generalization of a depth model cannot be guaranteed.
Disclosure of Invention
The invention aims to provide a short-term traffic flow prediction method based on deep learning and a multi-layer spatiotemporal feature map.
The technical scheme for realizing the purpose of the invention is as follows: a short-term traffic flow prediction method based on deep learning and multi-layer spatiotemporal feature maps comprises the following specific steps:
step 1, acquiring historical traffic data of a road section needing traffic flow prediction;
step 2, constructing the traffic data into a plurality of multilayer spatiotemporal feature maps according to the spatial position relationship, the time sequence and the data category;
step 3, training a deep convolutional neural network by taking the multilayer spatiotemporal feature map as a sample to obtain a short-term traffic flow prediction model;
and 4, inputting the traffic data of the road section needing traffic flow prediction into the short-time traffic flow prediction model to obtain a prediction result.
Preferably, the historical traffic data in step 1 includes traffic flow, speed, density, saturation, and traffic index.
Preferably, the sampling time interval of all the historical traffic data in step 2 is 10 minutes, and is data recorded within 2 years.
Preferably, the specific method for constructing the multi-layer spatiotemporal feature map in the step 3 is as follows:
and filling the road segment number, the sampling time point, the historical flow, the speed, the density, the saturation and the traffic index of the road segment into each pixel of C different MxN-dimensional digital images according to categories, wherein the longitudinal axis of the digital images is arranged according to the spatial relationship of the road segment, the transverse axis is arranged according to the time sequence of historical traffic data, M is the number of the selected sampling road segments, N is the number of the selected sampling time points, and C is the category number of the filling data, and the C digital images are superposed to form a multilayer space-time characteristic diagram containing the space-time characteristic and the traffic characteristic of the road segment.
Preferably, the deep convolutional neural network comprises an input layer, a hidden layer and an output layer which are connected in sequence; the convolution-pooling system comprises an input layer, a hidden layer structure and an output layer, wherein the input layer is a single convolution layer, the hidden layer structure is formed by sequentially connecting X convolution-pooling modules, each convolution-pooling module comprises Y convolution layers which are sequentially connected and b pooling layers which are sequentially connected and connected with the convolution layers, and the output layer comprises K full-connection layers which are sequentially connected.
Preferably, X ranges from 2 to 5, Y ranges from 2 to 5, and b ranges from 0 or 1.
Preferably, step 3, training the deep convolutional neural network by using the multi-layer spatiotemporal feature map as a sample, and the specific method for obtaining the short-time traffic flow prediction model comprises the following steps:
the method comprises the following steps of taking a plurality of multilayer space-time characteristic graphs as input of a deep convolutional neural network, taking traffic flow data after 10 minutes of the latest sampling time point in each multilayer space-time characteristic graph as a true value, taking a mean square error as a loss function, continuously comparing the true value with a predicted value output by the deep convolutional neural network, continuously optimizing neural network parameters by using a back propagation algorithm, and obtaining the optimal solution of the network parameters when the iteration times reach a set value or a loss function value is smaller than a set threshold value, wherein the loss function is specifically as follows:
in the formula, MSE is mean square error, n is the total number of samples of the space-time feature map, predict is a predicted value, and truth is a true value.
Compared with the prior art, the invention has the following remarkable advantages:
1. based on the machine learning technology, the potential correlation among historical traffic data is independently learned, so that the traffic flow prediction is more objective and accurate;
2. the multi-layer space-time characteristic graph adopted by the invention forms an efficient data form by using a convenient mode, the data is analyzed by simulating an image processing mode, the advantages of a neural network can be exerted, the information of the data from local to global is mined, and the potential correlation and the space-time correlation of historical traffic data are fully analyzed;
3. the invention adopts various historical traffic data, and simultaneously takes time and space information as data input, and can better improve the accuracy and reliability of short-time traffic flow prediction by utilizing the redundancy of the data.
The present invention is described in further detail below with reference to the attached drawings.
Drawings
FIG. 1 is a flow chart of the present invention.
FIG. 2 is a diagram showing a multi-level spatiotemporal feature map according to the present invention.
Fig. 3 is a diagram illustrating an exemplary VGGNet network structure according to the present invention.
FIG. 4 is a schematic diagram of the convolutional neural network structure of the present invention.
Detailed Description
A short-term traffic flow prediction method based on deep learning and multi-layer spatiotemporal feature maps comprises the following specific steps:
step 1, acquiring road sections needing traffic flow prediction and historical traffic data thereof;
in a further embodiment, the historical traffic data includes various historical data such as flow, speed, density, saturation, traffic index, etc., and it should be noted that the sampling time interval of all the historical traffic data is 10 minutes, and should be data recorded in the last 2 years.
Step 2, constructing a plurality of multi-layer space-time characteristic graphs with dimension of M multiplied by N multiplied by C according to the spatial position relation, the time sequence and the data category of the traffic data;
in a further embodiment, a specific method for constructing a plurality of multi-layer spatio-temporal feature maps with dimensions of M × N × C is as follows: and filling the road segment number, the sampling time point, the historical flow, the speed, the density, the saturation and the traffic index of the road segment into each pixel of C different MxN-dimensional digital images according to categories, wherein the longitudinal axis of the digital images is arranged according to the spatial relationship of the road segment, the transverse axis is arranged according to the time sequence of historical traffic data, M is the number of the selected sampling road segments, N is the number of the selected sampling time points, C is the category number of the filled data, and finally, the C digital images are superposed to form a multilayer space-time characteristic diagram containing the space-time characteristic and the traffic characteristic of the road segment.
Step 3, constructing a convolutional neural network, and taking the multilayer spatiotemporal feature map as a sample training network to obtain a short-term traffic flow prediction model;
in a further embodiment, the deep convolutional neural network is a deep neural network with a convolutional structure. The input layer of the deep convolutional neural network can directly process multidimensional data. The deep convolutional neural network comprises an input layer, a hidden layer and an output layer which are sequentially connected; the convolution-pooling module is formed by sequentially connecting Y convolution layers and then b pooling layers, and the output layer at the tail end of the network is formed by sequentially connecting K full-connection layers, so that a complete convolution neural network is formed. The value range of X is 2 to 5, the value range of Y is 2 to 5, and the value of b is 0 or 1.
In a further embodiment, a plurality of multi-layer space-time characteristic graphs are used as input of a neural network, traffic flow data after 10 minutes of the latest sampling time point in each multi-layer space-time characteristic graph is used as a true value, a mean square error is used as a loss function, the true value and a predicted value output by a model are continuously compared, a back propagation algorithm is used for continuously optimizing neural network parameters, and when the iteration number reaches a set value or the loss function value is smaller than a set threshold value, the optimal solution of the network parameters is obtained, wherein the loss function is specifically as follows:
wherein MSE is mean square error, n is the total number of samples of the space-time feature map, predict is a predicted value, and truth is a true value.
And 4, forming a multilayer space-time characteristic diagram by using traffic data of the road section needing traffic flow prediction, and inputting the multilayer space-time characteristic diagram into a short-time traffic flow prediction model to obtain a prediction result.
In a further embodiment, the process of forming the multi-layer spatiotemporal feature map by the traffic data of the road section needing traffic flow prediction specifically comprises the following steps: if the traffic flow 10 minutes later is to be predicted at the time t, respectively filling the C-type sampling data of M sampling road sections under N sampling time points before the time t into the multilayer space-time characteristic diagram according to the method for forming the multilayer space-time characteristic diagram in the step 2, and inputting the C-type sampling data into a short-time traffic flow prediction model, wherein the prediction result output by the model is the traffic flow at the time t + 10.
Example 1
As shown in fig. 1, a short-term traffic flow prediction method based on deep learning and multi-layer spatiotemporal feature maps specifically comprises the following steps:
1) and selecting the road section needing traffic flow prediction. And selecting 36 road segments in total, wherein the road segment number set RS is {1,2, …,36}, each road segment has a sensor, and traffic data of each road segment can be recorded.
And acquiring all historical traffic data of the road section relevant to traffic flow prediction. The historical traffic data includes 7 types of data, i.e., flow V, speed S, density D, saturation S, and traffic index TI, and it is noted that the sampling time interval of all the historical traffic data is 10 minutes, and the historical traffic data should be recorded within 2 years.
2) And constructing a plurality of multi-layer space-time characteristic graphs with dimension of M multiplied by N multiplied by C according to the historical traffic data, the spatial position relationship, the time sequence and the data type. Wherein, let M be 36, N be 10, and C be 7, select the traffic data of the last 2 years recorded by the 36 road segments in step 1), as shown in fig. 2, each 10 sampling time points are a group, and the road segment number rs of the 36 road segments is setmSampling time point tnFlow rate vm,nSpeed sm,nDensity dm,nSaturation sm,nTraffic index tim,nFill in each pixel of 7 different 36 x 10 dimensional digital images by category, respectively, where m ∈ [1,36 ∈ [ ]]Denotes the sampling link number, n ∈ [1,10 ]]Indicating the sample time sequence number. Finally, a plurality of digital images are overlaid to form a multi-layer space-time feature map containing the space-time characteristics and the traffic characteristics of the road section, 10368 multi-layer space-time feature maps can be constructed as a sample set in 2 years of data, and are recorded as Samples ═ f1,f2,…,f10368}。
3) And training the VGGNet deep convolution neural network by taking the multilayer space-time characteristic graph as a sample to obtain a short-time traffic flow prediction model. The network structure of VGGNet is shown in fig. 3, and the data is constructed into 10368 multi-layer spatiotemporal feature maps as the input of the neural network according to the method described in step 3), wherein 80% of samples are used as a training set, 10% of samples are used as a test set, and 10% of samples are used as a verification set. Meanwhile, if the latest sampling time point in each multi-layer space-time characteristic diagram is marked as tl, the traffic flow data V10 minutes later is recordedtl+10And as a true value output, adopting a mean square error as a loss function, continuously comparing the true value with a predicted value output by the model, and continuously optimizing the neural network parameters by using a back propagation algorithm so as to minimize the loss function and obtain the optimal solution of the network parameters, wherein the loss function specifically comprises the following steps:
and stopping network training after the specified iteration times are reached to obtain the optimal solution of the model parameters.
4) After the short-time traffic flow prediction model is obtained, if traffic flow prediction needs to be carried out at the current time tc, 7 types of data including road segment numbers, sampling time points, flow, speed, density, saturation and traffic indexes of 36 road segments in 10 time sampling points in total are extracted from the current time tc to form a multilayer space-time characteristic diagram, and the multilayer space-time characteristic diagram is input into the short-time traffic flow prediction model, so that the predicted traffic flow V of the future time tc +10 can be obtainedtc+10。
In order to analyze the prediction effect of the method provided by the invention, the multilayer spatiotemporal feature map constructed by the embodiment is used as a sample set, and two typical prediction methods, namely a support vector machine (SVR), an Artificial Neural Network (ANN) and a Convolutional Neural Network (CNN), are selected for comparison. The SVR is an algorithm adopting a structure risk minimization criterion as one of statistical regression models, and is widely applied to the traffic field. The ANN is taken as a typical representative of a neural network model, and the aim of prediction is achieved by learning hidden layer neurons and mapping the characteristics of input data. The average percent error (MAPE) and the average absolute error (MAE) are selected for error evaluation of the prediction effect, and the traffic flow prediction performance of 10min is shown in Table 1.
TABLE 110 minute traffic flow prediction comparison
The analysis shows that the short-term traffic flow prediction method based on deep learning and the multilayer spatiotemporal feature map provided by the invention can obtain lower error precision than the existing method, well improves the prediction accuracy of the short-term traffic flow, and has certain reference value and practical economic benefit.
The above are preferred embodiments of the present invention, and all changes made according to the technical scheme of the present invention that produce functional effects do not exceed the scope of the technical scheme of the present invention belong to the protection scope of the present invention.