A method for constructing urban traffic flow prediction model based on heterogeneous data fusion
Through technologies such as heterogeneous data fusion and graph convolution networks, external information is integrated to solve the problem of existing models ignoring the influence of external factors, and significantly improve the accuracy of traffic flow prediction.
Patent Information
- Application Number
- CN202211730853.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-30
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2042-12-30
AI Technical Summary
Existing traffic flow prediction models rarely consider the impact of external factors on traffic information and ignore the relationship between traffic information and external factors, resulting in poor prediction results.
Adopting an urban traffic flow prediction model based on heterogeneous data fusion, external information is integrated to improve prediction accuracy by building adjacency matrices, data preprocessing, spatial and temporal embedding, data fusion, graph convolution networks and gated recurrent units. sex.
The effective integration of static and dynamic external information improves the accuracy and effect of traffic flow prediction, and the importance of external information in prediction is verified through indicator comparison.
Smart Images

Figure CN116434538B
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of intelligent transportation technology and relates to a method for constructing an urban traffic flow prediction model based on heterogeneous data fusion. Background Art
[0002] Traffic flow prediction is one of the core technologies in the development of intelligent transportation systems (ITS). Using traffic flow prediction for traffic guidance can achieve the effect of traffic diversion and alleviate traffic congestion. Therefore, how to obtain accurate prediction information has become a key step in the intelligent transportation system.
[0003] Traffic forecasting is to predict the state of traffic flow in the future based on historical traffic information. The state of traffic flow has significant spatial and temporal correlations. It is not only affected by the current status of traffic flow upstream and downstream of the current monitoring point, but also by the historical traffic conditions. With the development of deep learning, most scholars now focus on artificial intelligence models for traffic flow prediction. In addition, traffic information may be affected by a variety of external factors, such as weather conditions, the presence of transport stations, emergencies, holidays, and the distribution of nearby POIs. These external factors have a direct or indirect relationship with traffic information that affects urban traffic conditions. However, existing studies rarely consider external factors and ignore the impact of the relationship between traffic information and external factors on traffic. For example, weather changes over time, and traffic flow under different weather conditions may have different states. In addition, not all road sections are affected by weather, and we should consider other attributes of road sections; for example, less popular sections with fewer surrounding facilities have smaller road loads and are therefore less affected by heavy rain than popular sections in the city center. How to integrate the semantic relevance of multi-source data is the key to improving traffic flow prediction capabilities. Summary of the invention
[0004] The purpose of the present invention is to provide a method for constructing an urban traffic flow prediction model based on heterogeneous data fusion, which solves the problem that existing models rarely consider external factors related to traffic and ignore the impact of the relationship between traffic information and external factors on traffic.
[0005] The technical solution adopted by the present invention is a method for constructing an urban traffic flow prediction model based on heterogeneous data fusion, which is specifically implemented in the following steps:
[0006] Step 1, construct an adjacency matrix;
[0007] Step 2, preprocessing the original data;
[0008] Step 3, dividing the preprocessed data;
[0009] Step 4: perform spatial domain embedding on non-directly related data;
[0010] Step 5, embedding the non-directly related data in the time domain;
[0011] Step 6, fusing the spatial domain embedding and the temporal domain embedding data;
[0012] Step 7, concatenate the data fused in step 6 with the data in step 3 to form new data;
[0013] Step 8, inputting the data obtained in step 7 into the prediction model;
[0014] Step 9: Train the prediction model.
[0015] The present invention is also characterized in that:
[0016] Step 1 is as follows:
[0017] Construct the adjacency matrix A. The element A[i][j] in the adjacency matrix stores the information of the relationship between vertex i and vertex j, as shown in formula (1):
[0018]
[0019] The data preprocessing in step 2 specifically includes: performing the minimum-maximum normalization method on the data before modeling, and adjusting the value through linear change, as shown in formula (2):
[0020]
[0021] In the formula, x max and x min are the maximum and minimum values of the traffic data of all road sections, respectively; x is the traffic flow of a road section in a time period, and x′ is the standardized traffic flow;
[0022] The data division in step 3 specifically includes: dividing the standardized overall traffic flow data into M*n*k spatiotemporal candidate nodes, where n is the number of historical time series, k=N-n+1 is the number of data, N is the overall time slice sequence, and M is the number of detection points;
[0023] The specific process of spatial feature embedding in step 4 is as follows: first, the external information is encoded, and then the encoding matrix corresponding to each node is transformed into a dense, real-valued matrix through network embedding; therefore, after the spatial feature embedding, the length of the feature representation of all nodes is consistent, and the process is as follows: a i =[e i,1 ,e i,2 ,…,e i,m ], where e i,m Represents the mth embedding vector of node i, where m is the length of the field; therefore, the embedding vector of each node is represented as a k*m tensor;
[0024] The time domain feature embedding in step 5 is as follows: In order to capture the changing characteristics of factors not directly related to traffic in the time domain, we divide a day into |T| time periods according to the time step of traffic flow. For all time periods of each day, we use |T|×k×k tensor Wt to represent the temporal changes of non-directly related factors. Wt is represented as a time domain feature embedding vector, where Wt can be self-learned as a network parameter. The input in the calculation is the time factor t, which is converted into a code with a length equal to |T| through one-hot encoding. Then, combined with Wt, the time domain embedding vector corresponding to time t is extracted through the embedding process to obtain the time domain feature representation, that is, a t =lookup(Wt,t)=Wt[t,:,:], where lookup represents a function with a search function;
[0025] The spatiotemporal feature fusion in step 6 is specifically as follows: the temporal feature representation is applied to each field of the spatial feature representation by using a convolution operation. The spatiotemporal feature representation of the node V in the time period t is calculated by the following formula: For other nodes, we use the same calculation method to obtain the spatiotemporal feature representation of all nodes;
[0026] Specifically, in step 7, the model uses the data fused after spatial feature embedding and temporal feature embedding as an attribute enhancement unit, and concatenates it with the original data to form an attribute enhancement matrix;
[0027] The prediction model in step 8 is composed of a graph convolutional network GCN and a gated recurrent unit GRU. The specific implementation steps are as follows:
[0028] Assume that the predicted target distribution of the input traffic flow sequence is represented as X = {x t-i ,x t-i+1 ,...,x t-1}, the traffic space-time prediction is regarded as the mapping function between the learning topology graph G and the feature matrix X, and the traffic information at the next time T is calculated:
[0029] [X t+1 , ..., X t+T ]=f(G;X t-n , ..., X t ) (3)
[0030] The two-layer GCN model can be expressed as:
[0031]
[0032] In the formula, represents the preprocessing step, W0∈R P*HThe matrix represents the weight from input to hidden layer, P is the length of feature matrix, H is the number of hidden units; W1∈R H*T The matrix H*T represents the weight from the hidden layer to the output layer, f(X,A)∈R N*T Represents the predicted output of length T, ReLU() is used as a rectified linear unit and as an activation layer; the specific calculation process is:
[0033]
[0034] Specifically, step 9 is as follows: 80% of all data is used as the training set, and the rest of the data is used as the test set. The model uses L2 regularization to prevent overfitting. The optimization algorithm uses the gradient descent algorithm Adam algorithm. Finally, the RMSE, ACC, and MAE indicators are used to evaluate the model prediction effect.
[0035] The beneficial effects of the present invention are
[0036] The method for constructing an urban traffic flow prediction model based on heterogeneous data fusion proposed in this paper mainly aims at the problem that the traditional urban traffic prediction model cannot comprehensively consider the external factors affecting the traffic status and the simple integration of external information does not improve the prediction effect well. A traffic flow prediction model based on heterogeneous data fusion is proposed; this model can integrate not only static external information but also dynamic external data by embedding the external information in the time domain and space domain. By comparing with the baseline method, the results verify the importance of considering external information in traffic prediction tasks. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1 It is a flow chart of a method for constructing an urban traffic flow prediction model based on heterogeneous data fusion according to the present invention;
[0038] Figure 2 It is a model overall architecture diagram of the method for constructing an urban traffic flow prediction model based on heterogeneous data fusion of the present invention;
[0039] Figure 3 This is a 45-minute prediction comparison chart of the urban traffic flow prediction model construction method based on heterogeneous data fusion of the present invention. DETAILED DESCRIPTION
[0040] The present invention is described in detail below with reference to the accompanying drawings and specific embodiments.
[0041] The present invention provides a method for constructing an urban traffic flow prediction model based on heterogeneous data fusion. Figure 1 and Figure 2 As shown, the specific implementation steps are as follows:
[0042] Step 1: Construct the adjacency matrix A. The element A[i][j] in the adjacency matrix stores the information of the relationship between vertex i and vertex j, as shown in formula (1):
[0043]
[0044] A value of 1 in the adjacency matrix indicates that the two nodes are connected, and a value of 0 indicates that the nodes are not connected;
[0045] Step 2: Before modeling, the data is normalized using the minimum-maximum method and the values are adjusted through linear changes, as shown in formula (2):
[0046]
[0047] In the formula, x max and x min are the maximum and minimum values of the traffic data of all road sections, respectively; x is the traffic flow of a road section in a time period, and x′ is the standardized traffic flow;
[0048] Step 3: Divide the overall traffic flow data. Since the data set is a two-dimensional data style (overall time slice sequence N, number of detection points M), the present invention needs to use the traffic data of the first few historical time slices to predict the traffic data of the next few time slices, so the overall traffic flow data after standardization is divided into M*n*k spatiotemporal candidate nodes, where n is the number of historical time series, and k=N-n+1 is the number of data;
[0049] Step 4: Spatial feature embedding is used to extract the feature representation of external factors. It takes the external factor data of all nodes as input and embeds the features of each field. First, the external information is encoded, and then the encoding matrix corresponding to each node is transformed into a dense, real-valued matrix through network embedding. Therefore, after spatial feature embedding, the length of the feature representation of all nodes is consistent. The process can be written as: i =[e i,1 ,e i,2 ,…,e i,m ], where e i,m Represents the mth embedding vector of node i, where m is the length of the field; therefore, the embedding vector of each node is represented as a k*m tensor;
[0050] Step 5: Time domain feature embedding. In the process of processing traffic-related data, we divide a day into |T| time periods. Similarly, we also divide the changes of traffic-related data in the time domain in the same way. For all time periods, a |T|×k×k tensor Wt is used to represent the change of spatial feature representation in the time domain, which is called the time domain feature embedding vector. Through the embedding process, the time domain embedding vector corresponding to time t is extracted to obtain the time domain feature representation, that is: a t =lookup(Wt,t)=Wt[t,:,:], where lookup represents a function with a search function;
[0051] Step 6: Spatial feature fusion is to fuse the spatial feature representation and the temporal feature representation into the spatiotemporal feature representation. To achieve this goal, we use the convolution operation to apply the temporal feature representation to each field of the spatial feature representation. For the node V, the spatiotemporal feature representation in the time period t is calculated by the following formula: For other nodes, we use the same calculation method to obtain the spatiotemporal feature representation of all nodes;
[0052] Step 7: The model uses the data fused after spatial feature embedding and temporal feature embedding as an attribute enhancement unit to form an attribute enhancement matrix with the original data.
[0053] Step 8: The prediction model is composed of graph convolutional network GCN and gated recurrent unit GRU;
[0054] Wherein step 8 is specifically implemented according to the following steps:
[0055] Assume that the predicted target distribution of the input traffic flow sequence is represented as X = {x t-i ,x t-i+1 ,...,x t-1}, the traffic space-time prediction is regarded as the mapping function between the learning topology graph G and the feature matrix X, and the traffic information at the next time T is calculated:
[0056] [X t+1 , ..., X t+T ]=f(G;X t-n , ..., X t ) (3)
[0057] The two-layer GCN model can be expressed as:
[0058]
[0059] In the formula, represents the preprocessing step, W0∈R P*HThe matrix represents the weight from input to hidden layer, P is the length of feature matrix, H is the number of hidden units; W1∈R H*T The matrix H*T represents the weight from the hidden layer to the output layer, f(X,A)∈R N*T Represents the predicted output of length T, ReLU() is used as a rectified linear unit and as an activation layer; the specific calculation process is:
[0060]
[0061] Step 9, train the prediction model: use 80% of all data as the training set, and the rest of the data as the test set. The model uses L2 regularization to prevent overfitting. The optimization algorithm uses the gradient descent algorithm Adam algorithm. Finally, the RMSE, ACC, and MAE indicators are used to evaluate the model prediction effect.
[0062] like Figure 1 As shown, it is a schematic diagram of the method flow of the present invention. Python 3.7.0, Tensorflow 1.15.0, Pycharm, and Windows 10 are used to simulate the proposed prediction method, and finally the simulation results are analyzed; the parameter settings are shown in Table 1:
[0063] Table 1 Model parameter settings
[0064] index parameter Learning Rate 0.001 Batch size 64 Epoch 1000 Regularization L2 Optimization Algorithm Adam optimization algorithm Number of hidden layer neurons 128
[0065] Based on the above simulation conditions, the following simulation scenarios are performed:
[0066] Example 1
[0067] RMSE MAE ACC <![CDATA[R 2 ]]> SVR 7.122 4.654 0.701 0.820 ARIMA 6.713 5.345 0.357 * GCN 5.372 4.163 0.644 0.685 T-GCN 4.191 2.890 0.707 0.839 DCRNN 4.610 3.910 0.311 0.837 DFGCN 4.110 2.821 0.713 0.845
[0068] In order to compare the performance of the model, four indicators, namely root mean square error (RMSE), determination coefficient (R2), mean absolute error (MAE), and accuracy, were used for comparison. In the single-step prediction of the next 45 minutes, the model prediction results of the data set are shown in Table 2. The DFGCN model incorporates external information and can better handle non-relevant data in traffic. It can be seen that the various evaluation indicators of the DFGCN model are improved compared with other models.
[0069] Example 2
[0070] The present invention uses the data of the first 12 time periods of the Shenzhen taxi data set to predict the last 3 time periods (one time period is 15 minutes). The prediction comparison chart is as follows: Figure 3As shown in the figure, it can be seen that the overall predicted value of the model is close to the actual value, and the fluctuation trend and peak and valley values are roughly the same, indicating that the model can better capture traffic characteristics and predict correct traffic results.
Claims
1. A method for constructing an urban traffic flow prediction model based on heterogeneous data fusion, characterized in that: Please follow the steps below to implement: Step 1, construct an adjacency matrix; Step 2, preprocessing the original data; Step 3, dividing the preprocessed data; Step 4: embed the spatial features of the non-directly related data. The specific steps of spatial feature embedding are as follows: first, encode the external information, and then transform the encoding matrix corresponding to each node into a dense, real-valued matrix through network embedding. Therefore, after the spatial feature embedding, the length of the feature representation of all nodes is consistent. The process is as follows: a i =[e i,1 ,e i,2 ,…,e i,m ], where e i,m Represents the mth embedding vector of node i, where m is the length of the field; therefore, the embedding vector of each node is represented as a k*m tensor; Step 5: embed the time domain features of the indirect related data. The specific steps of time domain feature embedding are as follows: In order to capture the time domain change characteristics of the data indirect related to traffic, a day is divided into |T| time periods according to the time step of the traffic flow. For all time periods of each day, a |T|×k×k tensor Wt is used to represent the time changes of the indirect related data. k is the encoding length, and Wt is represented as a time domain feature embedding vector, where Wt can be self-learned as a network parameter. The input in the calculation is the time factor t, which is converted into a code with a length equal to |T| through one-hot encoding; then combined with Wt, the time domain feature embedding vector corresponding to time t is extracted through the embedding process to obtain the time domain feature representation, that is, a t =lookup(Wt,t)=Wt[t,:,:], where lookup represents a function with a search function; Step 6: Fuse the spatial feature embedding data with the temporal feature embedding data. The spatiotemporal feature fusion is as follows: use the convolution operation to apply the temporal feature representation to each field of the spatial feature representation. For the node V, the spatiotemporal feature representation in the time period t is calculated by the following formula: For other nodes, we use the same calculation method to obtain the spatiotemporal feature representation of all nodes; Step 7, concatenate the data fused in step 6 with the data in step 3 to form new data; Step 8: Input the data obtained in step 7 into the prediction model, which is composed of a graph convolutional network GCN and a gated recurrent unit GRU. The specific implementation steps are as follows: Assume that the predicted target distribution of the input traffic flow sequence is represented as X = {x t-i ,x t-ii+1 ,...,x t-1 }, the traffic space-time prediction is regarded as the mapping function of the learning topology graph G and the feature matrix X, and the traffic information at the future time T is calculated: [X t+1 ,...,X t+T ]=f(G;X t-n ,...,X t ) (3) The two-layer GCN model is represented as: In the formula, f(X, A) represents the predicted output, X is the input feature, and A is the adjacency matrix. represents the preprocessing step, W0∈R P*H The matrix represents the weight from input to hidden layer, P is the length of feature matrix, H is the number of hidden units; W1∈R H*T The matrix H*T represents the weight from the hidden layer to the output layer, f(X,A)∈R N*T Represents the predicted output of length T, ReLU() is used as a rectified linear unit and as an activation layer. The specific calculation process is: Step 9: Train the prediction model.
2. The method for constructing an urban traffic flow prediction model based on heterogeneous data fusion according to claim 1 is characterized in that: The step 1 is specifically as follows: Construct the adjacency matrix A. The element A[i][j] in the adjacency matrix stores the information of the relationship between vertex i and vertex j, as shown in formula (1): In the formula, v i 、v j represents the vertex, and E refers to the edge set.
3. The method for constructing an urban traffic flow prediction model based on heterogeneous data fusion according to claim 1 is characterized in that: The data preprocessing in step 2 specifically includes: performing a minimum-maximum normalization method on the data before modeling, and adjusting the value through linear changes, as shown in formula (2): In the formula, x max and x min are the maximum and minimum values of the traffic data of all road sections, respectively; x is the traffic flow of a road section in a time period; and x′ is the standardized traffic flow.
4. The method for constructing an urban traffic flow prediction model based on heterogeneous data fusion according to claim 1 is characterized in that: The data division in step 3 specifically includes: dividing the standardized overall traffic flow data into M*n*k spatiotemporal candidate nodes, where n is the number of historical time series, k=N-n+1 is the number of data, N is the overall time slice sequence, and M is the number of detection points.
5. The method for constructing an urban traffic flow prediction model based on heterogeneous data fusion according to claim 1 is characterized in that: Specifically, in step 7, the model uses the data fused after spatial feature embedding and temporal feature embedding as an attribute enhancement unit, and concatenates it with the original data to form an attribute enhancement matrix.
6. The method for constructing an urban traffic flow prediction model based on heterogeneous data fusion according to claim 1 is characterized in that: Specifically, step 9 is as follows: 80% of all data are used as training sets, and the rest of the data are used as test sets. The model uses L2 regularization to prevent overfitting. The optimization algorithm uses the gradient descent algorithm Adam algorithm. Finally, the RMSE, ACC, and MAE indicators are used to evaluate the model prediction effect.
