Traffic flow prediction method based on space-time synchronization GraphSAGE

By constructing a spatiotemporally synchronized GraphSAGE model and combining Spearman correlation coefficient and attention mechanism, the problems of insufficient spatiotemporal dependency capture and high computational resource requirements in existing traffic flow prediction methods are solved, and prediction of missing nodes and optimization of computational resources are achieved.

CN119028151AInactive Publication Date: 2024-11-26NANTONG UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411135783.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-19
Publication Date
2024-11-26
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Most existing traffic flow prediction methods learn temporal and spatial relationships separately, which cannot effectively capture spatiotemporal dependencies. They also have high computational resource requirements and cannot predict nodes that did not appear during the training phase.

Method used

We adopt the GraphSAGE-based approach, which constructs an inclusive spatiotemporal synchronous graph and combines Spearman correlation coefficient and attention mechanism to achieve inductive learning, aggregate the temporal and spatial features of traffic flow data, and reduce the storage requirements of computing devices.

Benefits of technology

It can simultaneously capture the temporal and spatial dependencies of traffic flow data, predict nodes that did not appear during the training phase, reduce the storage requirements of computing devices, and improve the predictive performance of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119028151A_ABST
    Figure CN119028151A_ABST
Patent Text Reader

Abstract

The invention discloses a traffic flow prediction method based on time-space synchronization GraphSAGE. The method comprises the following steps: generating traffic flow data of a time sequence; according to the spatial adjacency matrix and the Spearman correlation coefficient matrix, firstly constructing an inclusive spatial adjacency matrix, and then designing an inclusive space-time synchronization diagram; according to the method, a space-time synchronization GraphSAGE model is constructed, traffic characteristics of space-time neighbors from 1 order to K order are aggregated through an attention mechanism for each traffic node according to a GraphSAGE thought, and the traffic characteristics are spliced with the characteristics of the traffic node, so that space-time dependence of traffic flow data is synchronously learned in an inductive manner. According to the method, space-time synchronous modeling of the traffic flow data is realized by designing the inclusive space-time synchronous graph, so that the model achieves accurate prediction precision, and meanwhile, the limitation of full-graph training and direct-push learning in the conventional traffic flow prediction method is solved based on the space-time characteristics of the GraphSAGE inductive aggregation traffic nodes.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of traffic prediction and relates to a traffic flow prediction method based on spatiotemporal synchronous GraphSAGE. Background Art

[0002] With the acceleration of urbanization and the surge in the number of motor vehicles, traffic problems are becoming increasingly serious. Traffic congestion, traffic accidents and other problems continue to plague urban residents. Intelligent Transportation System (ITS) is one of the most effective scientific methods to solve traffic problems. Traffic flow prediction is an important part of the intelligent transportation system. It can grasp the changing rules of traffic flow in advance by analyzing and predicting historical traffic data. Scientifically dispatching vehicles in the road network through the intelligent transportation system and inducing smooth traffic flow are of great practical significance to solving traffic problems. Accurate traffic flow prediction is an important function of the intelligent transportation system, which helps to plan the transportation network, optimize the allocation of transportation resources, improve traffic operation efficiency, and reduce traffic congestion and accidents. Therefore, how to design a more effective traffic flow prediction model and improve the performance of traffic flow prediction is particularly important.

[0003] The following points must be considered when modeling traffic flow data: (1) Temporal correlation and spatial correlation exist simultaneously and influence each other. Traffic flow at a certain moment is affected by traffic flow at an earlier moment. At the same moment, traffic flow at each traffic node is also affected by traffic flow at other traffic nodes. Temporal dependence and spatial dependence exist simultaneously and influence each other. (2) The need to implement inductive learning. Traffic flow prediction models not only need to make predictions for traffic nodes used in the training phase, but also, in many cases, need to make predictions for traffic nodes that are not visible in the training phase. Therefore, when designing traffic flow prediction models, inductive learning has a wider range of applications than direct learning. (3) Reduce the performance requirements for computing devices. Currently, mainstream traffic flow prediction models all use deep learning, which has high requirements for computing devices such as memory and GPU. Especially when the number of traffic nodes is huge, all nodes are combined into a large-scale traffic flow time series, which will occupy a large amount of device resources in both training and prediction. Therefore, reducing the model's demand for computing devices is also an issue that needs to be considered in reality. If the temporal and spatial dependencies can be captured simultaneously in the traffic flow prediction model, and inductive learning can be implemented to reduce the performance requirements of computing devices, the performance of the model will be better.

[0004] With the development of deep learning technology, graph convolutional networks (GCNs) have been widely used in the field of traffic flow prediction due to their excellent feature extraction capabilities. At the same time, recurrent neural networks (RNNs) and their variants, long short-term memory networks (LSTMs) and gated recurrent units (GRUs), have also been widely used to extract the temporal correlation of traffic time series. However, most of the previous traffic flow prediction methods learned temporal associations and spatial associations separately. Although a small number of studies have achieved spatiotemporal synchronous modeling, they all use graph convolutional networks to extract relevant features. Therefore, they belong to direct learning and can only predict the traffic flow of traffic nodes that are already visible in the training stage, and are powerless for traffic nodes that did not appear in the training stage. In addition, the prediction model based on graph convolutional networks requires the entire graph to be stored during training and prediction, and cannot implement small batch training in the dimension of the number of traffic nodes. When the number of traffic nodes is huge, the memory requirements of the computing device are very high. Summary of the invention

[0005] Purpose of the invention: To address the above problems, the present invention introduces a traffic flow prediction method based on spatiotemporal synchronized GraphSAGE. This method can simultaneously capture the temporal dependency and spatial dependency of traffic flow data, and the process of aggregating spatiotemporal features is inductive learning. It can also predict nodes that did not appear in the training phase. In addition, the modeling process does not depend on the entire graph structure, which reduces the storage requirements for computing devices and can effectively improve the prediction performance of the model.

[0006] Technical solution: A traffic flow prediction method based on spatiotemporal synchronous GraphSAGE, comprising the following steps:

[0007] Step 1) Collect traffic data in the road network through data collection equipment, remotely transmit and store it to the traffic data server, and generate time series traffic flow data according to the data collection time;

[0008] Step 2) Generate a traffic node graph and a spatial adjacency matrix according to the location of the data acquisition equipment in the road network, and standardize the time series traffic flow data according to the Z-score method, and then divide it into a training set, a validation set, and a test set;

[0009] Step 3) According to the time series traffic flow data, the Spearman correlation coefficient matrix between each traffic node is calculated, and based on the spatial adjacency matrix and the Spearman correlation coefficient matrix, an inclusive spatial adjacency matrix is ​​constructed, and combined with the temporal adjacency matrix, an inclusive spatiotemporal synchronization graph is designed;

[0010] Step 4) Construct a spatiotemporal synchronous GraphSAGE model. This model follows the GraphSAGE concept and aggregates the traffic features of its 1st to Kth order spatiotemporal neighbors for each traffic node through an attention mechanism, and concatenates them with the features of the traffic node itself, thereby inductively and synchronously learning the spatiotemporal dependencies of traffic flow data.

[0011] Step 5) Use the training set to train the spatiotemporal synchronized GraphSAGE model, use the validation set to verify the training effect, and use the test set to test the prediction accuracy of the model.

[0012] Furthermore, in step 1), the specific steps of collecting traffic data in the road network through data collection equipment, and remotely transmitting and storing it in the traffic data server are as follows: deploying N data collection equipment in the road network; taking five minutes as a time step, each data collection equipment collects traffic flow data once in each time step, including C traffic flow features, including the traffic flow, average vehicle speed, lane occupancy rate, etc. passing through the time step; the time span of the collection process is T, that is, it includes T time steps; the time series traffic data set finally transmitted remotely and stored in the traffic data server is

[0013] Furthermore, in step 2), a traffic node graph and a spatial adjacency matrix are generated according to the location of the data acquisition device in the road network, and the time series traffic flow data is standardized according to the Z-score method, and then divided into a training set, a validation set, and a test set. The specific steps include:

[0014] Step 2-1: Generate a traffic node graph G = (V, E, A) according to the location of the data acquisition equipment in the road network SG ), where V is the set of traffic nodes, representing N collection devices deployed in the road network; E is the edge in the traffic node graph, representing the relationship between each traffic node; A SG Represents the spatial adjacency matrix in the graph structure; the adjacency matrix is ​​generated according to the positional relationship between the data acquisition devices, and its structure is The value of each element in the adjacency matrix is ​​defined as:

[0015]

[0016] Step 2-2: Use the Z-score method to analyze the time series traffic data X h After standardization, the calculation method is as follows: Where mean(X h ) indicates X h The mean, std(X h ) represents X h The standard deviation of

[0017] Step 2-3: Transform the standardized traffic data X z Divide into training set, validation set and data set in proportion.

[0018] Furthermore, in step 3), the Spearman correlation coefficient matrix between each traffic node is calculated based on the time series traffic flow data, and an inclusive spatial adjacency matrix is ​​constructed based on the spatial adjacency matrix and the Spearman correlation coefficient matrix. In combination with the time adjacency matrix, an inclusive spatiotemporal synchronization graph is designed. The specific process is as follows:

[0019] Step 3-1: Relying solely on the spatial adjacency matrix to represent the graph structure has certain limitations and may cause the omission of important information. For example, two nodes are not neighbors in space, but their traffic flows show the same trend of change and have a strong correlation. Simply modeling through the spatial adjacency matrix cannot effectively capture this spatiotemporal correlation. In order to better learn the spatiotemporal dependence between traffic nodes, the Spearman correlation coefficient is introduced to characterize the similarity of traffic flows between nodes. According to the time series traffic flow data, the Spearman correlation coefficient matrix between each traffic node is The calculation method is:

[0020]

[0021] where r i ,r i Respectively represent the time node v i and node v j The rank of the time series, T represents the length of the time series, Respectively represent the node v i and node v j The mean of the ranks;

[0022] Step 3-2: Fusion spatial adjacency matrix A SG and the Spearman correlation coefficient matrix A SP , construct the inclusive space adjacency matrix The calculation method is:

[0023]

[0024] Step 3-3: In addition to influencing each other in the spatial dimension, traffic flows between nodes are also related in the temporal dimension. Therefore, it is also necessary to design a time graph to model the dependencies in the temporal dimension. For a certain node, the current state is affected by the historical time step earlier than the current state. In order to reduce the complexity of the model, we assume that the correlation between all nodes at each time step is consistent. Then, a time adjacency matrix shared by different nodes can be constructed. To describe the connection relationship between time steps; for any two time steps 0≤t in the traffic flow time series of length T i ,t j ≤T, the connection relationship between the two can be defined as:

[0025]

[0026] Step 3-4: According to the inclusion space adjacency matrix A IN and the time adjacency matrix A TG , construct an inclusive spatiotemporal synchronization graph A total of F time steps are included to simultaneously model the temporal and spatial correlations of traffic flow sequences; A ST The main diagonal of IN ,…,A IN ], represents the spatial adjacency relationship between nodes in each time step, A ST The area to the lower right of the main diagonal line is A IN Filling indicates the temporal connection relationship between each time step; taking F = 3 as an example, A ST The structure is:

[0027]

[0028] Furthermore, in step 4), a spatiotemporal synchronization GraphSAGE model is constructed. According to the GraphSAGE concept, for each traffic node, the traffic characteristics of its 1 to K-order spatiotemporal neighbors are aggregated through the attention mechanism, and the traffic characteristics are spliced ​​with the characteristics of the traffic node itself, so as to inductively and synchronously learn the spatiotemporal dependency of traffic flow data. The specific steps are as follows:

[0029] Step 4-1: For each traffic node and its 1st to Kth order neighbors, the weight between them is calculated through the attention mechanism to reflect the degree of association between the nodes. The attention weight matrix is ​​recorded as E = (E 1 ,E 2 ,…,E K );

[0030] Step 4-1-1: Define a fully connected layer as f(x) = LeakyReLU(xW+b), where W and b are trainable parameters;

[0031] Step 4-1-2: Calculate node v using the scaled dot product method i and its k-th neighbor The similarity coefficient between:

[0032]

[0033] Step 4-1-3: Normalize the similarity coefficient through the softmax function to get node v i and its neighbors The attention coefficient between:

[0034]

[0035] Step 4-1-4: To further improve the accuracy of the attention coefficient, the multi-head attention mechanism is used to calculate P attention coefficients and take the average to obtain the node v i and its neighbors The weight matrix E between k , whose elements are calculated as:

[0036]

[0037] Step 4-2: Input data through the fully connected layer Perform dimensional transformation to obtain a high-dimensional representation of the input data To improve the expressive power, we then add spatiotemporal embedding to the input data to improve the model’s ability to capture spatiotemporal dependencies:

[0038]

[0039] in For spatial embedding, Embedded for time;

[0040] Step 4-3: Construct K parallel spatiotemporal synchronous GraphSAGE layers, where the kth layer is responsible for aggregating the k-order spatiotemporal neighbor features of traffic nodes; in each spatiotemporal synchronous GraphSAGE layer, construct a corresponding number of inclusive spatiotemporal synchronous graphs A according to the length of the input traffic flow sequence ST ; Assume that the length of the input history time series of each layer is X = (X1, X2, ..., X T ), then the time segments used to construct the inclusive spatiotemporal synchronization graph in each layer are (X1,…,X F ),(X2,…,X F+1 ),...,(X T-F+1 ,X T ), so the shape of the traffic flow sequence fragments that make up each spatiotemporal synchronization graph is The number of spatiotemporal synchronization graphs in each layer is T-F+1;

[0041] Step 4-4: In each spatiotemporal synchronous GraphSAGE layer, design a spatiotemporal synchronous GraphSAGE operation, extract the spatiotemporal dependencies of the traffic flow sequence through the inclusive spatiotemporal synchronous graph and the attention weight matrix, and concatenate the outputs of the K spatiotemporal synchronous GraphSAGE layers with the input X to obtain the output

[0042] Step 4-4-1: For any node v i , the operation of aggregating the features of its k-th order spatiotemporal neighbors in the k-th spatiotemporal synchronized GraphSAGE layer is defined as:

[0043]

[0044] Step 4-4-2: Crop each spatiotemporal synchronization aggregation result to reduce its dimension from FN to N:

[0045]

[0046] Step 4-4-3: In each spatiotemporal synchronous GraphSAGE layer, there are T-F+1 inclusive spatiotemporal synchronous graphs. The aggregation results of each graph are spliced ​​to obtain the output of the current spatiotemporal synchronous GraphSAGE layer:

[0047]

[0048] Step 4-4-4: Set node v i The results of the 1st to kth order spatiotemporal aggregation are concatenated with the characteristics of the node itself:

[0049]

[0050] Step 4-5: Generate predictions using a two-layer fully connected layer to get the output of the spatiotemporal synchronized GraphSAGE model:

[0051]

[0052] in

[0053] Further, in step 5), the spatiotemporal synchronous GraphSAGE model is trained with the training set, the training effect is verified with the validation set, and the prediction accuracy of the model is tested with the test set. The specific steps are as follows:

[0054] Step 5-1: Determine the hyperparameters of the spatiotemporal synchronization GraphSAGE model, including the dimension of the input fully connected layer, the size of the neighbor order K, the number of time steps F for constructing the spatiotemporal synchronization graph, and the dimension of the fully connected layer in the output layer; set the hyperparameters in the training process, including batch size, variable learning rate, step size, etc., and initialize various weight parameters;

[0055] Step 5-2: Use the training set to train the model, select the mean absolute error function as the loss function, iteratively update the weights in the model through model forward propagation, error back propagation, and stochastic gradient descent method, and use the validation set to verify the training effect of the model during the training process;

[0056] Step 5-3: When the number of iterations or the loss function reaches the preset value, the training is terminated and the test set is input into the trained model to test the prediction accuracy of the model.

[0057] Beneficial effects: The present invention aims at the previous traffic flow prediction methods, most of which learn time association and space association separately. Although a small number of studies have achieved spatiotemporal synchronous modeling, they all use graph convolutional networks to extract relevant features. Therefore, they belong to direct learning and can only predict the traffic flow of traffic nodes that are already visible in the training stage, and are powerless for traffic nodes that did not appear in the training stage. In addition, the prediction model based on graph convolutional networks requires the entire graph to be stored during training and prediction, and it is impossible to implement small batch training in the dimension of the number of traffic nodes. When the number of traffic nodes is huge, the memory requirements of the computing device are very high, so the performance of the model still has a lot of room for improvement. To this end, the present invention introduces a traffic flow prediction method based on spatiotemporal synchronous GraphSAGE. This method can simultaneously capture the time dependency and spatial dependency of traffic flow data, and the process of aggregating spatiotemporal features is inductive learning. It can also predict nodes that did not appear in the training stage. In addition, the modeling process does not depend on the entire graph structure, which reduces the storage requirements for the computing device and can effectively improve the prediction performance of the model. BRIEF DESCRIPTION OF THE DRAWINGS

[0058] Figure 1 A schematic diagram of the steps of the traffic flow prediction method based on spatiotemporal synchronous GraphSAGE of the present invention;

[0059] Figure 2 This is a structural diagram of the GraphSAGE model based on spatiotemporal synchronization of the present invention;

[0060] Figure 3 This is a fitting graph of the test set data based on the spatiotemporal synchronization GraphSAGE model of the present invention. DETAILED DESCRIPTION

[0061] The technical solution of the present invention is further described in detail below in conjunction with the accompanying drawings.

[0062] like Figure 2 As shown, a traffic flow prediction method based on spatiotemporal synchronous GraphSAGE includes the following steps:

[0063] Step 1) Collect traffic data in the road network through data collection equipment, remotely transmit and store it to the traffic data server, and generate time series traffic flow data according to the data collection time;

[0064] In the step 1), the specific steps of collecting traffic data in the road network through data collection equipment, remotely transmitting and storing it in the traffic data server are as follows: deploying N data collection equipment in the road network; taking five minutes as a time step, each data collection equipment collects traffic flow data once in each time step, including C traffic flow features, including the traffic flow, average vehicle speed, lane occupancy rate, etc. passing through the time step; the time span of the collection process is T, that is, it includes T time steps; the time series traffic data set finally transmitted remotely and stored in the traffic data server is

[0065] Step 2) Generate a traffic node graph and a spatial adjacency matrix according to the location of the data acquisition equipment in the road network, and standardize the time series traffic flow data according to the Z-score method, and then divide it into a training set, a validation set, and a test set;

[0066] In the step 2), a traffic node graph and a spatial adjacency matrix are generated according to the location of the data acquisition device in the road network, and the time series traffic flow data is standardized according to the Z-score method, and then divided into a training set, a validation set, and a test set. The specific steps include:

[0067] Step 2-1: Generate a traffic node graph G = (V, E, A) according to the location of the data acquisition equipment in the road network SG ), where V is the set of traffic nodes, representing N collection devices deployed in the road network; E is the edge in the traffic node graph, representing the relationship between each traffic node; A SG Represents the spatial adjacency matrix in the graph structure; the adjacency matrix is ​​generated according to the positional relationship between the data acquisition devices, and its structure is The value of each element in the adjacency matrix is ​​defined as:

[0068]

[0069] Step 2-2: Use the Z-score method to analyze the time series traffic data X h After standardization, the calculation method is as follows: Where mean(X h ) indicates X h The mean, std(X h ) represents X h The standard deviation of

[0070] Step 2-3: Transform the standardized traffic data X z The dataset is divided into training set, validation set and data set in a ratio of 6:2:2.

[0071] Step 3) According to the time series traffic flow data, the Spearman correlation coefficient matrix between each traffic node is calculated, and based on the spatial adjacency matrix and the Spearman correlation coefficient matrix, an inclusive spatial adjacency matrix is ​​constructed, and combined with the temporal adjacency matrix, an inclusive spatiotemporal synchronization graph is designed;

[0072] In the step 3), the Spearman correlation coefficient matrix between each traffic node is calculated based on the time series traffic flow data, and an inclusive spatial adjacency matrix is ​​constructed based on the spatial adjacency matrix and the Spearman correlation coefficient matrix. In combination with the time adjacency matrix, an inclusive spatiotemporal synchronization graph is designed. The specific process is as follows:

[0073] Step 3-1: Relying solely on the spatial adjacency matrix to represent the graph structure has certain limitations and may cause the omission of important information. For example, two nodes are not neighbors in space, but their traffic flows show the same trend of change and have a strong correlation. Simply modeling through the spatial adjacency matrix cannot effectively capture this spatiotemporal correlation. In order to better learn the spatiotemporal dependence between traffic nodes, the Spearman correlation coefficient is introduced to characterize the similarity of traffic flows between nodes. According to the time series traffic flow data, the Spearman correlation coefficient matrix between each traffic node is The calculation method is:

[0074]

[0075] where r i ,r i Respectively represent the time node v i and node v j The rank of the time series, T represents the length of the time series, Respectively represent the node v i and node v j The mean of the ranks;

[0076] Step 3-2: Fusion spatial adjacency matrix A SG and the Spearman correlation coefficient matrix A SP , construct the inclusive space adjacency matrix The calculation method is:

[0077]

[0078] Step 3-3: In addition to influencing each other in the spatial dimension, traffic flows between nodes are also related in the temporal dimension. Therefore, it is also necessary to design a time graph to model the dependencies in the temporal dimension. For a certain node, the current state is affected by the historical time step earlier than the current state. In order to reduce the complexity of the model, we assume that the correlation between all nodes at each time step is consistent. Then, a time adjacency matrix shared by different nodes can be constructed. To describe the connection relationship between time steps; for any two time steps 0≤t in the traffic flow time series of length T i ,t j ≤T, the connection relationship between the two can be defined as:

[0079]

[0080] Step 3-4: According to the inclusion space adjacency matrix A IN and the time adjacency matrix A TG , construct an inclusive spatiotemporal synchronization graph A total of F time steps are included to simultaneously model the temporal and spatial correlations of traffic flow sequences; A ST The main diagonal of IN ,…,A IN ], represents the spatial adjacency relationship between nodes in each time step, A ST The area to the lower right of the main diagonal line is A IN Filling indicates the temporal connection relationship between each time step; taking F = 3 as an example, A ST The structure is:

[0081]

[0082] Step 4) Construct a spatiotemporal synchronous GraphSAGE model. This model follows the GraphSAGE concept and aggregates the traffic features of its 1st to Kth order spatiotemporal neighbors for each traffic node through an attention mechanism, and concatenates them with the features of the traffic node itself, thereby inductively and synchronously learning the spatiotemporal dependencies of traffic flow data.

[0083] In step 4), a spatiotemporal synchronization GraphSAGE model is constructed. According to the GraphSAGE concept, for each traffic node, the traffic characteristics of its 1 to K order spatiotemporal neighbors are aggregated through the attention mechanism, and the traffic characteristics are spliced ​​with the characteristics of the traffic node itself, so as to inductively and synchronously learn the spatiotemporal dependency of traffic flow data. The specific steps are as follows:

[0084] Step 4-1: For each traffic node and its 1st to Kth order neighbors, the weight between them is calculated through the attention mechanism to reflect the degree of association between the nodes. The attention weight matrix is ​​recorded as E = (E 1 ,E 2 ,…,E K );

[0085] Step 4-1-1: Define a fully connected layer as f(x) = LeakyReLU(xW+b), where W and b are trainable parameters;

[0086] Step 4-1-2: Calculate node v using the scaled dot product method i and its k-th neighbor The similarity coefficient between:

[0087]

[0088] Step 4-1-3: Normalize the similarity coefficient through the softmax function to get node v i and its neighbors The attention coefficient between:

[0089]

[0090] Step 4-1-4: To further improve the accuracy of the attention coefficient, the multi-head attention mechanism is used to calculate P attention coefficients and take the average to obtain the node v i and its neighbors The weight matrix E between k , whose elements are calculated as:

[0091]

[0092] Step 4-2: Input data through the fully connected layer Perform dimensional transformation to obtain a high-dimensional representation of the input data To improve the expressive power, we then add spatiotemporal embedding to the input data to improve the model’s ability to capture spatiotemporal dependencies:

[0093]

[0094] in For spatial embedding, Embedded for time;

[0095] Step 4-3: Construct K parallel spatiotemporal synchronous GraphSAGE layers, where the kth layer is responsible for aggregating the k-order spatiotemporal neighbor features of traffic nodes; in each spatiotemporal synchronous GraphSAGE layer, construct a corresponding number of inclusive spatiotemporal synchronous graphs A according to the length of the input traffic flow sequence ST ; Assume that the length of the input history time series of each layer is X = (X1, X2, ..., X T ), then the time segments used to construct the inclusive spatiotemporal synchronization graph in each layer are (X1,…,X F ),(X2,…,X F+1 ),...,(X T-F+1 ,X T ), so the shape of the traffic flow sequence fragments that make up each spatiotemporal synchronization graph is The number of spatiotemporal synchronization graphs in each layer is T-F+1;

[0096] Step 4-4: In each spatiotemporal synchronous GraphSAGE layer, design a spatiotemporal synchronous GraphSAGE operation, extract the spatiotemporal dependencies of the traffic flow sequence through the inclusive spatiotemporal synchronous graph and the attention weight matrix, and concatenate the outputs of the K spatiotemporal synchronous GraphSAGE layers with the input X to obtain the output

[0097] Step 4-4-1: For any node v i , the operation of aggregating the features of its k-th order spatiotemporal neighbors in the k-th spatiotemporal synchronized GraphSAGE layer is defined as:

[0098]

[0099] Step 4-4-2: Crop each spatiotemporal synchronization aggregation result to reduce its dimension from FN to N:

[0100]

[0101] Step 4-4-3: In each spatiotemporal synchronous GraphSAGE layer, there are T-F+1 inclusive spatiotemporal synchronous graphs. The aggregation results of each graph are spliced ​​to obtain the output of the current spatiotemporal synchronous GraphSAGE layer:

[0102]

[0103] Step 4-4-4: Set node v i The results of the 1st to kth order spatiotemporal aggregation are concatenated with the characteristics of the node itself:

[0104]

[0105] Step 4-5: Generate predictions using a two-layer fully connected layer to get the output of the spatiotemporal synchronized GraphSAGE model:

[0106]

[0107] in

[0108] Step 5) Use the training set to train the spatiotemporal synchronized GraphSAGE model, use the validation set to verify the training effect, and use the test set to test the prediction accuracy of the model.

[0109] In step 5), the spatiotemporal synchronous GraphSAGE model is trained with the training set, the training effect is verified with the validation set, and the prediction accuracy of the model is tested with the test set. The specific steps are as follows:

[0110] Step 5-1: Determine the hyperparameters of the spatiotemporal synchronization GraphSAGE model, including the dimension of the input fully connected layer, the size of the neighbor order K, the number of time steps F for constructing the spatiotemporal synchronization graph, and the dimension of the fully connected layer in the output layer; set the hyperparameters in the training process, including batch size, variable learning rate, step size, etc., and initialize various weight parameters;

[0111] Step 5-2: Use the training set to train the model, select the mean absolute error function as the loss function, iteratively update the weights in the model through model forward propagation, error back propagation, and stochastic gradient descent method, and use the validation set to verify the training effect of the model during the training process;

[0112] Step 5-3: When the number of iterations or the loss function reaches the preset value, the training is terminated and the test set is input into the trained model to test the prediction accuracy of the model.

[0113] like Figure 3 As shown in the figure, a traffic flow prediction method based on spatiotemporal synchronized GraphSAGE can achieve excellent prediction results on the test set, and has good accuracy for traffic flow predictions for the next 15 minutes and the next 60 minutes.

[0114] The present invention is aimed at the previous traffic flow prediction methods, most of which learn time association and space association separately. Although a small number of studies have achieved spatiotemporal synchronous modeling, they all use graph convolutional networks to extract relevant features. Therefore, they belong to direct learning and can only predict the traffic flow of traffic nodes that are already visible in the training stage, and are powerless for traffic nodes that do not appear in the training stage. In addition, the prediction model based on graph convolutional networks requires the entire graph to be stored during training and prediction, and it is impossible to implement small batch training in the number dimension of traffic nodes. When the number of traffic nodes is huge, the memory requirements of the computing device are very high, so the performance of the model still has a large room for improvement. To this end, the present invention introduces a traffic flow prediction method based on spatiotemporal synchronous GraphSAGE. This method can simultaneously capture the time dependency and spatial dependency of traffic flow data, and the process of aggregating spatiotemporal features is inductive learning. Nodes that do not appear in the training stage can also be predicted. In addition, the modeling process does not depend on the entire graph structure, which reduces the storage requirements for the computing device and can effectively improve the prediction performance of the model.

[0115] The above description is only a preferred implementation of the present invention in a traffic artery or highway data set. The protection scope of the present invention is not limited to the above implementation. Any equivalent modifications and changes made by ordinary technicians in this field based on the contents disclosed by the present invention should be included in the protection scope recorded in the claims.

Claims

1. A traffic flow prediction method based on spatiotemporal synchronous GraphSAGE, characterized by: The method comprises the following steps: Step 1) Collect traffic data in the road network through data collection equipment, remotely transmit and store it to the traffic data server, and generate time series traffic flow data according to the data collection time; Step 2) Generate a traffic node graph and a spatial adjacency matrix according to the location of the data acquisition equipment in the road network, and standardize the time series traffic flow data according to the Z-score method, and then divide it into a training set, a validation set, and a test set; Step 3) According to the time series traffic flow data, the Spearman correlation coefficient matrix between each traffic node is calculated, and based on the spatial adjacency matrix and the Spearman correlation coefficient matrix, an inclusive spatial adjacency matrix is ​​constructed, and combined with the temporal adjacency matrix, an inclusive spatiotemporal synchronization graph is designed; Step 4) Construct a spatiotemporal synchronous GraphSAGE model. This model follows the GraphSAGE concept and aggregates the traffic features of its 1st to Kth order spatiotemporal neighbors for each traffic node through an attention mechanism, and concatenates them with the features of the traffic node itself, thereby inductively and synchronously learning the spatiotemporal dependencies of traffic flow data. Step 5) Use the training set to train the spatiotemporal synchronized GraphSAGE model, use the validation set to verify the training effect, and use the test set to test the prediction accuracy of the model.

2. The traffic flow prediction method based on spatiotemporal synchronous GraphSAGE according to claim 1 is characterized in that: The specific steps of collecting traffic data in the road network through data collection equipment in step 1), and remotely transmitting and storing it in the traffic data server are as follows: deploying N data collection equipment in the road network; taking five minutes as a time step, each data collection equipment collects traffic flow data once in each time step, including C traffic flow features, including the traffic flow, average vehicle speed, lane occupancy rate, etc. passing through the time step; the time span of the collection process is T, that is, it includes T time steps; the time series traffic data set finally transmitted remotely and stored in the traffic data server is 3. The traffic flow prediction method based on spatiotemporal synchronous GraphSAGE according to claim 1 is characterized in that: The specific process in step 2) includes: Step 1-1: Generate a traffic node graph G = (V, E, A) according to the location of the data acquisition equipment in the road network SG ), where V is the set of traffic nodes, representing N collection devices deployed in the road network; E is the edge in the traffic node graph, representing the relationship between each traffic node; A SG Represents the spatial adjacency matrix in the graph structure; the adjacency matrix is ​​generated according to the positional relationship between the data acquisition devices, and its structure is The value of each element in the adjacency matrix is ​​defined as: Step 1-2: Use the Z-score method to analyze the time series traffic data X h After standardization, the calculation method is as follows: Where mean(X h ) indicates X h The mean, std(X h ) represents X h The standard deviation of Step 1-3: Standardize the traffic data X z Divide into training set, validation set and data set in proportion.

4. The traffic flow prediction method based on spatiotemporal synchronous GraphSAGE according to claim 1 is characterized in that: The detailed steps of step 3) are: Step 2-1: Introduce the Spearman correlation coefficient to characterize the similarity of traffic flow between nodes. According to the time series traffic flow data, the Spearman correlation coefficient matrix between each traffic node is The calculation method is: where r i ,r j Respectively represent the time node v i and node v j The rank of the time series, T represents the length of the time series, Respectively represent the node v i and node v j The mean of the ranks; Step 2-2: Fusion spatial adjacency matrix A SG and the Spearman correlation coefficient matrix A SP , construct the inclusive space adjacency matrix The calculation method is: Step 2-3: Assume that the associations between all nodes at each time step are consistent to construct a time adjacency matrix shared between different nodes To describe the connection relationship between time steps; for any two time steps 0≤t in the traffic flow time series of length T i ,t j ≤T, the connection relationship between the two is defined as: Step 2-4: According to the inclusion space adjacency matrix A IN and the time adjacency matrix A TG , construct an inclusive spatiotemporal synchronization graph A total of F time steps are included to simultaneously model the temporal and spatial correlations of traffic flow sequences; A ST The main diagonal of IN ,…,A IN ], represents the spatial adjacency relationship between nodes in each time step, A ST The area to the lower right of the main diagonal line is A IN Filling indicates the temporal connection relationship between time steps.

5. The traffic flow prediction method based on spatiotemporal synchronous GraphSAGE according to claim 1 is characterized in that: The specific steps of step 4) to construct the spatiotemporal synchronous GraphSAGE model are as follows: Step 3-1: For each traffic node and its 1st to Kth order neighbors, the weight between them is calculated through the attention mechanism to reflect the degree of association between the nodes. The attention weight matrix is ​​recorded as E = (E 1 ,E 2 ,…,E K ); Step 3-2: Input data through the fully connected layer Perform dimensional transformation to obtain a high-dimensional representation of the input data To improve the expressive power, we then add spatiotemporal embedding to the input data to improve the model’s ability to capture spatiotemporal dependencies: in For spatial embedding, Embedded for time; Step 3-3: Construct K parallel spatiotemporal synchronous GraphSAGE layers, where the kth layer is responsible for aggregating the k-order spatiotemporal neighbor features of traffic nodes; in each spatiotemporal synchronous GraphSAGE layer, construct a corresponding number of inclusive spatiotemporal synchronous graphs A according to the length of the input traffic flow sequence ST ; Assume that the length of the input history time series of each layer is X = (X1, X2, ..., X T ), then the time segments used to construct the inclusive spatiotemporal synchronization graph in each layer are (X1,…,X F ),(X2,…,X F+1 ),...,(X T-F+1 ,X T ), so the shape of the traffic flow sequence fragments that make up each spatiotemporal synchronization graph is The number of spatiotemporal synchronization graphs in each layer is T-F+1; Step 3-4: In each spatiotemporal synchronous GraphSAGE layer, design a spatiotemporal synchronous GraphSAGE operation, extract the spatiotemporal dependencies of the traffic flow sequence through the inclusive spatiotemporal synchronous graph and the attention weight matrix, and concatenate the output of K spatiotemporal synchronous GraphSAGE layers with the input X to obtain the output Step 3-5: Generate predictions using a two-layer fully connected layer to get the output of the spatiotemporal synchronized GraphSAGE model: in 6. The traffic flow prediction method based on spatiotemporal synchronous GraphSAGE according to claim 5 is characterized by: The detailed process of step 3-1 is as follows: Step 4-1: Define a fully connected layer as f(x) = LeakyReLU(xW+b), where W and b are trainable parameters; Step 4-2: Calculate node v using scaled dot product method i and its k-th neighbor The similarity coefficient between: Step 4-3: Normalize the similarity coefficient through the softmax function to get node v i and its neighbors The attention coefficient between: Step 4-4: To further improve the accuracy of the attention coefficient, the multi-head attention mechanism is used to calculate P attention coefficients and take the average to obtain the node v i and its neighbors The weight matrix E between k , whose elements are calculated as:

7. The traffic flow prediction method based on spatiotemporal synchronous GraphSAGE according to claim 5 is characterized by: The detailed process of steps 3-4 is as follows: Step 5-1: For any node v i , the operation of aggregating the features of its k-th order spatiotemporal neighbors in the k-th spatiotemporal synchronized GraphSAGE layer is defined as: Step 5-2: Crop each spatiotemporal synchronization aggregation result to reduce its dimension from FN to N: Step 5-3: In each spatiotemporal synchronous GraphSAGE layer, there are T-F+1 inclusive spatiotemporal synchronous graphs. The aggregation results of each graph are spliced ​​to obtain the output of the current spatiotemporal synchronous GraphSAGE layer: Step 5-4: Set node v i The results of the 1st to kth order spatiotemporal aggregation are concatenated with the characteristics of the node itself:

8. The traffic flow prediction method based on spatiotemporal synchronous GraphSAGE according to claim 1 is characterized by: The specific steps of step 5) are as follows: Step 6-1: Determine the hyperparameters of the spatiotemporal synchronization GraphSAGE model, including the dimension of the input fully connected layer, the size of the neighbor order K, the number of time steps F for constructing the spatiotemporal synchronization graph, and the dimension of the fully connected layer in the output layer; Set hyperparameters during training, including batch size, variable learning rate, step size, and initialize various weight parameters; Step 6-2: Use the training set to train the model, select the mean absolute error function as the loss function, iteratively update the weights in the model through model forward propagation, error back propagation, and stochastic gradient descent method, and use the validation set to verify the training effect of the model during the training process; Step 6-3: After the number of iterations or the loss function reaches the preset value, the training is terminated and the test set is input into the trained model to test the prediction accuracy of the model.