Traffic prediction method based on dynamic causal analysis and space-time adaptive fusion graph learning
Through dynamic causal analysis and space-time adaptive fusion graph model, combined with Granger causal relationship and deep learning, the problem of ignoring dynamic features in the existing technology is solved, and more accurate traffic flow prediction is achieved, which enhances the explanatory and prediction capabilities of the model. .
Patent Information
- Application Number
- CN202411043207.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-31
- Publication Date
- 2024-11-29
AI Technical Summary
The existing traffic flow prediction methods rely too much on predefined adjacency matrix, ignore the dynamic characteristics in node data, and cannot effectively capture the causal relationship and spatiotemporal heterogeneity between traffic nodes, affecting the accuracy of long-term prediction.
Adoptional fusion graph model based on dynamic causal analysis, combined with Granger causal relationship and deep learning, the spatiotemporal characteristics of traffic data are captured through gated expansion time convolution module and hybrid graph learning module, and the path is processed through the spatiotemporal attention mechanism. The heterogeneity of nodes generates adaptive adjacency matrix and prediction information.
It improves the accuracy and interpretability of traffic flow prediction, can better capture the deep spatial and temporal characteristics between traffic nodes, and enhances the explanatory and predictive capabilities of the model.
Smart Images

Figure CN119047618A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of spatiotemporal modeling of traffic network and traffic flow prediction, and in particular to a traffic prediction method based on dynamic causal analysis and spatiotemporal adaptive fusion graph learning. Background Art
[0002] Urban transportation is an important part of urban activities and an important manifestation and symbol of urban modernization. With the rapid development of the national economy and the gradual acceleration of urbanization, urban transportation is not only a municipal engineering problem, but also a comprehensive social problem and a livelihood issue that needs to be solved urgently. At the same time, due to the increase in the number of cars, the carrying capacity of the urban road network is gradually approaching the upper limit. At the same time, with the further development of the city, the large-scale construction of high-rise and super-high-rise buildings has led to a very prominent concentration of people and vehicles during rush hours. These problems have gradually aggravated the congestion of urban road network traffic. Research on this issue also meets the important needs of the country.
[0003] There are many reasons for the emergence of these traffic problems, such as the continuous and significant growth in demand for transportation systems, the singleness of traffic management subjects, the imbalance between traffic supply and demand, imperfect transportation infrastructure, and insufficient public participation. With the co-development of urbanization and motorization, alleviating traffic congestion has become a top priority in the traffic management of various cities. Road traffic forecasting for this problem has important theoretical value and practical significance for urban traffic control systems and traffic management systems. In addition, accurate traffic forecasting can strengthen the relationship between vehicles, roads, management departments and travelers, thereby improving transportation efficiency.
[0004] With the rapid development of intelligent transportation systems, advanced data communication technology, information technology and control technology have been applied to ground traffic management systems, expanding the scope of traffic management systems and improving real-time, accuracy and efficiency. It enables people to analyze and study the large amount of data generated to improve urban traffic conditions. At present, vehicle-mounted GPS, road sensors and intelligent traffic cameras are becoming increasingly popular on urban roads. These intelligent devices can collect data and provide assistance to traffic management systems. In addition, many location service websites also provide relevant interfaces for researchers to obtain information in the field of transportation, such as geographic data, points of interest, road networks, traffic conditions and other information. In addition, information on factors closely related to traffic conditions, such as weather data, can also be obtained through crawlers or NLP (natural language processing) and other technologies.
[0005] Accurate traffic data analysis and prediction have far-reaching significance, which is mainly reflected in the following aspects. Traffic data prediction can assist in the analysis and support of the feasibility of highway construction: Traffic flow prediction is one of the core contents of highway feasibility study. By analyzing traffic survey data and development laws, the future traffic volume is estimated, which provides a basic basis for the highway technical level, construction scale, construction sequence, and national economic evaluation and financial evaluation of the project; Accurate traffic data prediction is conducive to optimizing traffic planning and design schemes: Traffic demand prediction is the basis of planning and design schemes. It not only puts forward high requirements for the prediction of total traffic volume, but also needs to consider the distributed traffic volume between each traffic node (small area). This information is crucial for determining network planning and cross-sectional structure, and has an important impact on the scientificity and rationality of planning and design schemes; Accurate traffic data analysis and prediction can improve the efficiency of intelligent transportation systems: Long-range and short-range traffic flow prediction is an important part of intelligent transportation system research. Real-time and accurate traffic flow prediction can be applied to advanced traffic management systems and traveler information systems, which is of great significance to improving the operating efficiency and response speed of transportation systems.
[0006] The current traffic system is highly complex, which places extremely high demands on traffic flow prediction. The research on traffic flow prediction is not only to solve the key problems of traffic information system, but also to meet the urgent needs of the unique challenges of urban traffic. At the same time, accurate traffic data prediction is of great significance to support infrastructure construction, optimize traffic planning, and improve the efficiency of intelligent transportation system.
[0007] The invention patent with application number CN202311424900.4 discloses a traffic flow prediction method that integrates spatiotemporal adaptive graph learning and dynamic graph convolution. The method consists of a gated temporal convolution network Gated TCN and an adaptive hybrid graph convolution module AHGCM. Among them, Gated TCN uses dilated causal convolution networks of different granularity levels to capture temporal dependencies, and AHGCM consists of a static adaptive graph learning module SAGL, a dynamic graph learning module DGL, and a spatial gate fusion mechanism, which can synchronously and fully capture the dynamic spatiotemporal features in the historical data of traffic flow. SAGL can adaptively capture the dynamic spatial features of traffic, and DGL contains a graph attention mechanism, which can reduce the time complexity through parallel computing while capturing hidden spatial correlations. STAHGCN combines multiple modules to construct a combined prediction model, and uses the prediction layer to predict the spatiotemporal features extracted by multiple modules to achieve future medium- and long-term predictions of traffic flow. The above invention captures the dynamic spatiotemporal features of historical data by integrating adaptive graph learning and dynamic graph learning modules, and constructs a combined prediction model to achieve accurate prediction. However, the above invention does not analyze the causal relationship in the historical time data. The dynamic graph learning module uses the distance decay matrix as the prior graph structure of GAT to learn, which cannot reflect the dynamic propagation process of traffic flow between different nodes. Moreover, the nodes are affected differently by time dependence or space dependence at different times. Therefore, analyzing the spatiotemporal heterogeneity of traffic nodes, that is, the influence weight of time features or space features, can provide more effective information in long-term prediction. Summary of the invention
[0008] In view of the technical problems that existing methods are too dependent on predefined adjacency matrices, or only consider the correlation of node positions and ignore the dynamic characteristics contained in node data, the present invention proposes a spatiotemporal adaptive causal fusion graph model based on dynamic causal analysis. The model integrates the statistical method Granger causality and deep learning to better capture the spatial correlation between nodes; a temporal convolution module is used to process nonlinear temporal dependencies, and a spatiotemporal attention mechanism is introduced to deal with the heterogeneity of road nodes.
[0009] In order to achieve the above object, the technical solution of the present invention is implemented as follows: a traffic prediction method based on dynamic causal analysis and spatiotemporal adaptive fusion graph learning, the steps comprising:
[0010] S1: Use sensors to characterize traffic data samples and preprocess the characteristics of traffic data samples to obtain traffic characteristic data sets;
[0011] S2: Topological structure of the traffic network and definition of the traffic prediction task;
[0012] S3: Based on the traffic prediction task definition, the gated dilated temporal convolution module is used to capture the long-range time-dependent features of historical traffic data;
[0013] S4: Traffic flow prediction using hybrid graph learning module based on traffic feature dataset;
[0014] S5: Based on the prediction information, the spatiotemporal adaptive module is used to capture the spatiotemporal adaptive trend at the node level and obtain the output of the STAM module;
[0015] S6: Connect the output of the STAM module to the output layer through a skip connection.
[0016] The method for preprocessing the characteristics of the traffic data sample in step S1 is:
[0017] At fixed time intervals, traffic data is collected and recorded through sensors in the traffic network. The traffic data is cleaned, denoised, and missing values are supplemented and processed. Traffic data sample characteristics are extracted through statistical methods, spatiotemporal analysis methods, and machine learning. The traffic data sample characteristics are organized into a traffic feature dataset for storage.
[0018] The method for defining the traffic prediction task in step S2 is:
[0019] The topological structure of the traffic network is represented as a graph G = (V, E), where V = {v1, v2, ..., v N} represents the set of all nodes in the graph G, N represents the number of all road nodes, and E represents the edge set;
[0020] Represents the adjacency matrix of graph G, where A ij represents the correlation between node i and node j; at each time step t, the graph G contains a dynamic feature matrix X (t) =∈R N×F , where F represents the feature dimension. Based on the above relationship, the traffic prediction task is essentially based on the graph G and its corresponding historical graph signal X at T steps. (t-T):t =∈R N×F To predict the traffic flow information of the next time step T, the mapping relationship is expressed as: Y′=f(G;(X t-T ,X t-(T-1) ,…,X t )).
[0021] The method of capturing the long-range time-dependent features of historical traffic data in step S3 is:
[0022] Using a dilated causal convolution with a kernel size of 2 and a dilation factor of k, every k steps from a one-dimensional input sequence X = ∈ R TSelect data from the dataset and apply a 1D convolution filter f∈R K , at step t, the dilated causal convolution is calculated to efficiently capture long-term dependencies, and its formula is as follows:
[0023]
[0024] Among them, d is the expansion factor that controls the jump step size; the gating mechanism can effectively control the information flow through each layer in the time convolution network, and the output of the l-1 layer As input, the gated temporal convolution is calculated as:
[0025]
[0026] Among them, * represents the convolution operator, W f,l , W g,l , b1 and b2 are all learnable parameters of the method, ⊙ is the element-by-element product, σ represents the sigmoid activation function, tanh represents the hyperbolic tangent activation function, and the final output of the l-th layer of GatedTCN is:
[0027] The method for predicting traffic flow using the hybrid graph learning module in step S4 is:
[0028] S41: Based on the traffic feature data set processed by S1, the K-means algorithm is used to perform cluster analysis on the data set containing n weeks, and the Granger causality test method based on sliding windows is used to test the causal relationship between data points to obtain the daily causal adjacency matrix;
[0029] S42: Taking the daily causal adjacency matrix as the prior graph structure, the graph attention mechanism is used to perform spatial feature aggregation, and weighted feature fusion is achieved by calculating the attention scores of the central node and the neighboring nodes to obtain the node spatial connection;
[0030] S43: Based on the adjacency matrix defined by the node spatial connection, the hidden association information between the road nodes is learned in a fine-grained manner based on the node adaptive learning mechanism to generate a corresponding adaptive adjacency matrix.
[0031] S44: Aggregate the features of causal graph and adaptive adjacency matrix through graph neural network based on attention mechanism and gating mechanism, and generate prediction information.
[0032] Step S41 uses the K-means algorithm to perform cluster analysis on the data set containing n weeks:
[0033] The data set is divided into continuous periodic data of one week in length. The K-means algorithm is used to perform cluster analysis on the data set containing n weeks to effectively divide these data points into k different clusters. During the clustering process, each data sample will be assigned to the cluster to which the cluster center closest to it belongs, thereby ensuring that the data points within each cluster have a high degree of similarity. After clustering, the model further identifies and selects the most representative one-week data, and uses this data as the benchmark for subsequent analysis. Then, the Granger causality test method based on sliding windows is used to learn the causal relationship between nodes.
[0034] Granger causality test first constructs two linear regression models (partial model Y p and the complete model Y f ) to predict x based on past observations j (t), where t=1,2,...,T; the partial model and the complete model formula are expressed as:
[0035]
[0036] Among them, x' j (t) represents the prediction for node j, β p and β f is the lag term parameter; by calculating the sum of squared errors (SSR) of the two models p ,SSR f ), calculated as Granger causality test hypothesis H0: variable x i Past information cannot help predict variable x j The future value of x can be tested by using the F-index. When the null hypothesis is rejected, the additional information can improve the prediction, that is, x i x j It has a causal effect, and the calculation formula is:
[0037]
[0038] Among them, d p and d f are the degrees of freedom of the two models, L lag , 2L lag ; T is the total number of samples in the time series. Then, we can Td f The probability of the null hypothesis is estimated by the F distribution of -1. The threshold sig of the F-index test is set to 0.05. If the probability is lower than the significant threshold sig, the null hypothesis is rejected and there is a Granger causality relationship from x i to x jConsidering the obvious periodicity of traffic flow, the historical traffic data is processed in a certain way. First, the historical traffic data is divided into one-week time steps, and then the K-means aggregation algorithm is used to aggregate and select the most representative one-week data from it. This data can reflect the characteristics of all node features that change dynamically over time within a week. Then, the sliding window {[s q :e q ]|0≤s q ≤e q ≤T}, extract the data, set the sliding window size to a time step of one day, and perform Granger causality test on the data to analyze the daily causal impact; finally generate the corresponding daily causal adjacency matrix W (d) , which is:
[0039]
[0040] Among them, p is the P value calculated in the Granger causality test, which is used to determine whether the hypothesis H0 in the hypothesis test will be rejected, and sig is the significance threshold.
[0041] The method for realizing weighted feature fusion by calculating the attention scores of the central node and the neighboring nodes in step S42 is:
[0042] The aggregation update process of the graph attention mechanism can be expressed as:
[0043]
[0044] in, Represents node v i and v j The attention coefficient between represents the neighbor set of a node in the graph, that is, LR(·) represents the LeakyReLU function; is a learnable parameter variable, D represents the dimension, is the weight matrix for linear transformation, Represents node v i Features at time step t; sum and aggregate the features generated by multi-head attention, K represents the number of heads, and W k is the attention coefficient and weight matrix of the kth attention head; is node v i The output at time step t, the final output of CGL is
[0045] The method for generating the corresponding adaptive adjacency matrix in step S43 is:
[0046] The adaptive adjacency matrix formula is:
[0047]
[0048] in, is the embedding dictionary encoding each traffic road node, N is the number of nodes, d is the embedding dimension, E1 is the source node embedding, is the target node embedding; Softmax is the normalization function, and ReLU is the nonlinear activation function;
[0049] GCN is used to achieve feature aggregation of adaptive graphs. The graph convolution operation in the spectral domain is approximated by the first Chebyshev polynomial expansion and extended to high-dimensional GCN. The corresponding graph convolution operation can be expressed as:
[0050]
[0051] in represents the output of AGL, Θ is the learnable graph convolution kernel, and l represents the number of layers;
[0052] The method for generating prediction information in step S44 is:
[0053] Apply spatial gate fusion to fuse two inputs and and They come from the output of AGL and CGL respectively. The gated fusion mechanism is as follows:
[0054]
[0055] in are all learnable parameters. Finally, the output of this hybrid graph learning block is
[0056] The method of using the spatiotemporal adaptive module to capture the spatiotemporal adaptive trend of the node level in step S5 is:
[0057] Perform a linear transformation on the nodes embedded in E1 to obtain the graph node query Q = E1W Q ,in and The output of GatedTCN Convert to To get the key of the node in the time dimension, Output of the hybrid graph learning module pass Perform a linear transformation to obtain the key of the node in the spatial dimension, where Calculate the attention vectors respectively, and in, and and are the temporal and spatial attention of the graph nodes respectively. The output of STAM is:
[0058]
[0059]
[0060] in, and are the attention scores of the nodes in the time and space dimensions, respectively. is the output of STAM and also the final output of the l-th layer model.
[0061] The method of connecting the output of the STAM module to the output layer through a skip connection in step S6 is:
[0062] By stacking multiple layers, the temporal receptive field of the spatiotemporal causal hybrid graph neural network STCHGNN is continuously increased; the bottom block pays more attention to the traffic characteristics of adjacent time, and the high-level block pays attention to the long-term traffic information; skip connections are used to solve the spatial dependency modeling at different time levels, and summation is used after the skip connection to fuse all the outputs. The result is expressed as Finally, two fully connected layers are used to implement the output layer to generate the final prediction results. The output layer can be expressed as follows:
[0063]
[0064] in, and is a learnable parameter, It is the final output of the entire model;
[0065] The mean absolute error between the predicted value and the true value is used as the loss function and minimized by back propagation. The formula is:
[0066]
[0067] Among them, θ represents all learnable parameters of the model, represents the model's prediction of all traffic nodes at time step i, Y i is the true value.
[0068] The beneficial effects of the present invention are as follows: the present invention is applicable to traffic flow prediction tasks in the field of urban transportation, and can play an important role in rationally dispatching urban transportation resources, supporting infrastructure construction, optimizing transportation planning, and improving the efficiency of intelligent transportation systems. The present invention proposes a traffic prediction method based on dynamic causal analysis and spatiotemporal adaptive fusion graph learning. The steps are as follows: preprocessing the collected traffic data, capturing the long-range time-dependent features of the traffic sequence through the gated dilated time convolution module (GatedTCN); inputting the processed data into the hybrid graph learning module, respectively performing causal graph learning, adaptive graph learning and spatial gated fusion; the causal graph learning module uses the K-means aggregation algorithm and the Granger causality test based on the sliding window to reveal the causal relationship between traffic nodes, and realizes weighted feature fusion through the graph neural network of the attention mechanism; the adaptive graph learning module uses the adaptive learning mechanism to learn the hidden association information between road nodes in a fine-grained manner, generate the corresponding adaptive adjacency matrix, and use the graph convolution network to aggregate node features; finally, the output results of the GatedTCN and fusion graph modules are input into the spatiotemporal adaptive module (STAM) to capture the spatiotemporal adaptive trend of the node level and generate the predicted speed; the traffic prediction model is trained according to the loss function, and the predicted traffic speed is obtained by testing. The present invention performs graph modeling according to the causal influence and spatiotemporal relationship between nodes, and introduces the attention control mechanism and the adaptive mechanism for graph learning and information aggregation, which better captures the deep spatiotemporal features between traffic nodes and improves the interpretability and accuracy of the model. BRIEF DESCRIPTION OF THE DRAWINGS
[0069] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0070] Figure 1 It is a flow chart of the method of the present invention.
[0071] Figure 2 It is a schematic diagram of the model structure of the present invention.
[0072] Figure 3 It is a schematic diagram of the structure of the spatiotemporal adaptive module of the present invention. DETAILED DESCRIPTION
[0073] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0074] like Figure 1 As shown in FIG, a traffic prediction method based on dynamic causal analysis and spatiotemporal adaptive fusion graph learning is shown, and the steps are as follows:
[0075] S1: Extract features of traffic data samples using sensors, and preprocess the features of traffic data samples to obtain the required feature acquisition data set.
[0076] The traffic data collected by sensors in a certain period of time are preprocessed to obtain the required feature acquisition data set. The data preprocessing process is: at intervals of 5 minutes, the traffic data is collected and recorded through sensors in the traffic network, and the features of the traffic data samples are extracted. Specifically, the original traffic data is first cleaned and processed, including data cleaning, denoising, and supplementing missing values; then, the average speed, vehicle flow and other features of the traffic data samples are extracted through statistical methods, spatiotemporal analysis methods or machine learning methods, and these features are organized into a data set for storage, so as to establish a traffic flow prediction model in the future and predict the traffic conditions in the future.
[0077] S2: Topologically structure the traffic network and define the traffic prediction task.
[0078] The topological structure of the traffic network is represented as a graph G = (V, E), where V = {v1, v2, ..., v N} represents the set of all nodes in the graph G, N represents the number of all road nodes, and E represents the edge set. Represents the adjacency matrix of graph G, where A ij represents the correlation between node i and node j. At each time step t, the graph G contains a dynamic feature matrix X (t) =∈R N×F , where F represents the feature dimension. Based on the above relationship, the traffic prediction task is essentially based on the graph G and its corresponding historical graph signal X at T steps. (t-T):t =∈R N×F To predict the traffic flow information of the next time step T, the mapping relationship is expressed as: Y′=f(G;(X t-T ,X t-(T-1) ,…,X t )).
[0079] S3: Capture the long-range temporal dependency features of historical traffic data through Gated Temporal Convolution Networks.
[0080] The gated dilated temporal convolution module (GatedTCN) has two parallel temporal convolution modules, filter and gate. GatedTCN captures the temporal dependency of traffic flow through dilated causal convolution networks at different levels of granularity. Dilated causal convolution obtains a larger receptive field by stacking convolutional layers, which means that the network can capture a wider range of temporal context information; in addition, dilated causal convolution uses a non-recursive parallel computing method to slide the input sequence with a specific step size (dilation factor k). This method not only improves the efficiency of processing long time series, but also effectively alleviates the gradient vanishing problem by reducing the network depth, thereby improving the speed and stability of learning.
[0081] Using a dilated causal convolution with a kernel size of 2 and a dilation factor of k, every k steps from a one-dimensional input sequence X = ∈ R T Select data from the dataset and apply a 1D convolution filter f∈R K , at step t, the dilated causal convolution is calculated to efficiently capture long-term dependencies, and its formula is as follows:
[0082]
[0083] Where d is the dilation factor that controls the jump step size. The dilated causal convolutional layers with the dilation factor are stacked in increasing order, which makes the receptive field of the temporal convolutional network layer grow exponentially. Therefore, it is possible to capture longer time series with fewer layers, saving computing time and improving the accuracy of long-term predictions. The gating mechanism can efficiently control the information flow through each layer in the temporal convolutional network, and the output of the l-1 layer is As input, the gated temporal convolution is calculated as:
[0084]
[0085] Where * represents the convolution operator, W f,l , W g,l , b1 and b2 are all learnable parameters, ⊙ is the element-wise product, σ represents the sigmoid activation function, and tanh represents the hyperbolic tangent activation function. The final output of the lth layer of GatedTCN is:
[0086] S4: Traffic flow prediction is performed using a hybrid graph learning module based on traffic feature datasets and time-dependent features.
[0087] The Hybrid Graph Learning Module includes three modules: adaptive graph learning, causal graph learning, and spatial gating fusion. First, the adaptive graph learning and causal graph learning modules are used to capture the spatial dependencies and causal relationships between nodes, and then the spatial gating mechanism is used to adaptively fuse the dynamic spatiotemporal features of traffic flow for traffic flow prediction.
[0088] S41: Based on the traffic feature dataset processed by S1, the K-means algorithm is used to perform cluster analysis on the dataset containing n weeks, and the causal relationship between data points is tested using the Granger causality test method based on sliding windows.
[0089] Since traffic characteristics have obvious periodicity, the data set is divided into continuous periodic data of one week in length. The K-means algorithm is used to perform cluster analysis on the data set containing n weeks to effectively divide these data points into k different clusters. In the clustering process, each data sample will be assigned to the cluster to which the cluster center closest to it belongs, thereby ensuring that the data points within each cluster have a high degree of similarity. After clustering, the model further identifies and selects the most representative one-week data, and this data will be used as the benchmark for subsequent analysis. Then, the Granger causality test method based on sliding windows is used to learn the causal relationship between nodes.
[0090] Specifically, the Granger causality test first constructs two linear regression models (partial model Y p and the complete model Y f ) to predict x based on past observations j (t), where t = 1, 2, ..., T. The partial model and the complete model formula are expressed as:
[0091]
[0092] Among them, x' j (t) represents the prediction for node j, β p and β f is the lag term parameter; by calculating the sum of squared errors (SSR) of the two models p ,SSR f ), calculated as Granger causality test hypothesis H0: variable x i Past information cannot help predict variable x j By using the F-index to test the null hypothesis, when the null hypothesis is rejected, it means that the additional information can improve the prediction, that is, x i x j It has a causal effect, and the calculation formula is:
[0093]
[0094] Among them, d p and d f are the degrees of freedom of the two models, L lag , 2L lag . T is the total number of samples in the time series. Then, we can Td f -1 F distribution estimates the probability of the null hypothesis, and sets the threshold sig of the F-index test to 0.05 (0.05 by default). If the probability is lower than the significant threshold sig, the null hypothesis is rejected, which means that there is a Granger causal relationship from x i to x j Considering that traffic flow has obvious periodicity, the present invention processes historical traffic data to some extent. First, the historical traffic data is divided into one-week time steps, and then the K-means aggregation algorithm is used to aggregate the data, and the most representative one-week data is selected from the data. The data can reflect the characteristics of all node features that change dynamically over time within a week. Then the sliding window {[s q :e q ]|0≤s q <e q ≤T}, extract the data, set the sliding window size to a time step of one day, and perform Granger causality test on the data to analyze the daily causal impact. Finally, generate the corresponding daily causal adjacency matrix W (d) , which is:
[0095]
[0096] Among them, p is the P value calculated in the Granger causality test, which is used to determine whether the hypothesis H0 in the hypothesis test will be rejected, and sig is the significance threshold.
[0097] The obtained traffic feature dataset is divided into a training set, a test set and a validation set, which are used to train the model, select the parameters corresponding to the best model for verification, and test the trained model.
[0098] The training set accounts for 70% of the total data in the dataset, the data in the test set accounts for 20% of the total data in the dataset, and the data in the validation set accounts for 10% of the total data in the dataset.
[0099] S42: The daily causal adjacency matrix is used as the prior graph structure, and the graph attention mechanism is adopted to perform spatial feature aggregation. Weighted feature fusion is achieved by calculating the attention scores of the central node and the neighbor nodes. That is, more important relationships obtained through causal relationship tests are given priority when performing feature fusion.
[0100] Take graph node v i As an example, the aggregation and update process of the graph attention mechanism can be expressed as:
[0101]
[0102] in, Represents node v i and v j The attention coefficient between represents the neighbor set of a node in the graph, that is, LR(·) represents the LeakyReLU function; is a learnable parameter variable, D represents the dimension, is the weight matrix for linear transformation, Represents node v i Features at time step t; sum and aggregate the features generated by multi-head attention, K represents the number of heads, and W k is the attention coefficient and weight matrix of the kth attention head; is node v i The output at time step t, the final output of CGL is
[0103] Through the above steps, the temporal causal relationship of nodes can be captured, the causal topological structure can be learned from historical traffic data, and the graph neural network method can be used to aggregate the attribute information of the nodes in the structure to capture the dynamic spatial correlation of the nodes. Compared with the traditional dynamic adjacency matrix, this method can analyze the mutual influence between nodes that are not connected in space.
[0104] S43: Based on the adjacency matrix defined by the node spatial connection, the hidden association information between the road nodes is learned in a fine-grained manner based on the node adaptive learning mechanism to generate the corresponding adaptive adjacency matrix.
[0105] The adjacency matrix defined according to the spatial connection of nodes takes into account that the traffic conditions of different road nodes are strongly dynamically connected in the spatial dimension. Although the predefined adjacency matrix can represent the spatial relationship between nodes, it cannot reflect the hidden spatial dependencies of node attributes. Therefore, an adaptive graph learning (AGL) module is added. Based on the node adaptive learning mechanism, the hidden association information between road nodes is learned in a fine-grained manner to generate the corresponding adaptive adjacency matrix. The adaptive adjacency matrix formula is:
[0106]
[0107] in, is the embedding dictionary encoding each traffic road node, N is the number of nodes, d is the embedding dimension, E1 is the source node embedding, is the target node embedding. Softmax is a normalization function and ReLU is a nonlinear activation function. GCN is used to implement feature aggregation of adaptive graphs. The graph convolution operation in the spectral domain is approximated by the first Chebyshev polynomial expansion and extended to high-dimensional GCN. The corresponding graph convolution operation can be expressed as:
[0108]
[0109] in represents the output of AGL, Θ is the learnable graph convolution kernel, and l represents the number of layers.
[0110] S44: The features of the causal graph and the adaptive adjacency matrix are aggregated through a graph neural network based on attention mechanism and gating mechanism, and the prediction information is generated by the output layer.
[0111] Apply spatial gate fusion to fuse two inputs and They come from the output of AGL and CGL respectively. The gated fusion mechanism is as follows:
[0112]
[0113] in are all learnable parameters, and the final output of this hybrid graph learning block (HGLM) is
[0114] S5: Based on the prediction information, the spatiotemporal adaptation module is used to capture the spatiotemporal adaptation trend at the node level.
[0115] Considering that different traffic road nodes are affected differently in time and space, and some road nodes may be more affected by their own traffic than their neighboring nodes, a spatiotemporal adaptive module (STAM) is used to capture the spatiotemporal adaptive trend at the node level. The same graph node embedding as the hybrid graph learning module is used in STAM to ensure a unified high-dimensional node representation of the nodes in the entire model, while also reducing the number of parameters.
[0116] The calculation method of the spatiotemporal adaptive module (STAM) is as follows: linearly transform the nodes embedded in E1 to obtain the graph node query Q = E1W Q ,in and The output of GatedTCN Convert to To get the key of the node in the time dimension, Output of the hybrid graph learning module pass Perform a linear transformation to obtain the key of the node in the spatial dimension, where Calculate the attention vectors respectively, and in, and and are the temporal and spatial attention of the graph nodes respectively. The output of STAM is:
[0117]
[0118] in and are the attention scores of the nodes in the time and space dimensions, respectively. It is the output of the STAM module and also the final output of the l-th layer model.
[0119] S6: For the output of each layer of the STAM module, the output of the STAM module is connected to the output layer through a skip connection.
[0120] By stacking multiple layers, the temporal receptive field of the spatio-temporal causal hybrid graphical neural networks (STCHGNN) is continuously increased. The bottom block focuses more on the temporally adjacent traffic features, while the high-level blocks focus on the long-term temporal traffic information. Skip connections are used to solve the spatial dependency modeling at different temporal levels. After the skip connection, summation is used to fuse all the outputs, and the result is expressed as Finally, two fully connected layers are used to implement the output layer to generate the final prediction results. The output layer can be expressed as follows:
[0121]
[0122] in, and is a learnable parameter. is the final output of the entire model. The present invention uses the mean absolute error (MAE) between the predicted value and the true value as the loss function and minimizes it through back propagation. The formula is:
[0123]
[0124] Here, θ represents all learnable parameters of the model. represents the model's prediction of all traffic nodes at time step i, Y i is the true value.
[0125] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A traffic prediction method based on dynamic causal analysis and spatiotemporal adaptive fusion graph learning, characterized in that the steps include: S1: Use sensors to characterize traffic data samples and preprocess the characteristics of traffic data samples to obtain traffic characteristic data sets; S2: Topological structure of the traffic network and definition of the traffic prediction task; S3: Based on the traffic prediction task definition, the gated dilated temporal convolution module is used to capture the long-range time-dependent features of historical traffic data; S4: Traffic flow prediction using hybrid graph learning module based on traffic feature dataset; S5: Based on the prediction information, the spatiotemporal adaptive module is used to capture the spatiotemporal adaptive trend at the node level and obtain the output of the STAM module; S6: Connect the output of the STAM module to the output layer through a skip connection.
2. The traffic prediction method based on dynamic causal analysis and spatiotemporal adaptive fusion graph learning according to claim 1 is characterized in that: The method for preprocessing the characteristics of the traffic data sample in step S1 is: At fixed time intervals, traffic data is collected and recorded through sensors in the traffic network. The traffic data is cleaned, denoised, and missing values are supplemented and processed. Traffic data sample characteristics are extracted through statistical methods, spatiotemporal analysis methods, and machine learning. The traffic data sample characteristics are organized into a traffic feature dataset for storage.
3. The traffic prediction method based on dynamic causal analysis and spatiotemporal adaptive fusion graph learning according to claim 2 is characterized in that: The method for defining the traffic prediction task in step S2 is: The topological structure of the traffic network is represented as a graph G = (V, E), where V = {v1, v2, ..., v N } represents the set of all nodes in the graph G, N represents the number of all road nodes, and E represents the edge set; Represents the adjacency matrix of graph G, where A ij Represents the correlation between node i and node j; At each time step t, the graph G contains a dynamic feature matrix X (t) =∈R N×F , where F represents the feature dimension; based on the above relationship, the traffic prediction task is essentially based on the graph G and its corresponding historical graph signal X at T steps. (t-T):t =∈R N×F To predict the traffic flow information of the next time step T, the mapping relationship is expressed as: Y′=f(G;(X t-T ,X t-(T-1) ,…,X t )).
4. The traffic prediction method based on dynamic causal analysis and spatiotemporal adaptive fusion graph learning according to claim 3 is characterized in that: The method of capturing the long-range time-dependent features of historical traffic data in step S3 is: Using a dilated causal convolution with a kernel size of 2 and a dilation factor of k, every k steps from a one-dimensional input sequence X = ∈ R T Select data from the dataset and apply a 1D convolution filter f∈R K , at step t, the dilated causal convolution is calculated to efficiently capture long-term dependencies, and its formula is as follows: Among them, d is the expansion factor that controls the jump step size; the gating mechanism can effectively control the information flow through each layer in the time convolution network, and the output of the l-1 layer As input, the gated temporal convolution is calculated as: Among them, * represents the convolution operator, W f,l , W g,l , b1 and b2 are all learnable parameters of the method, ⊙ is the element-by-element product, σ represents the sigmoid activation function, tanh represents the hyperbolic tangent activation function, and the final output of the l-th layer of GatedTCN is:
5. The traffic prediction method based on dynamic causal analysis and spatiotemporal adaptive fusion graph learning according to claim 4 is characterized in that: The method for predicting traffic flow using the hybrid graph learning module in step S4 is: S41: Based on the traffic feature data set processed by S1, the K-means algorithm is used to perform cluster analysis on the data set containing n weeks, and the Granger causality test method based on sliding windows is used to test the causal relationship between data points to obtain the daily causal adjacency matrix; S42: Taking the daily causal adjacency matrix as the prior graph structure, the graph attention mechanism is used to perform spatial feature aggregation, and weighted feature fusion is achieved by calculating the attention scores of the central node and the neighboring nodes to obtain the node spatial connection; S43: Based on the adjacency matrix defined by the node spatial connection, the hidden association information between the road nodes is learned in fine granularity based on the node adaptive learning mechanism, and the corresponding adaptive adjacency matrix is generated; S44: Aggregate the features of causal graph and adaptive adjacency matrix through graph neural network based on attention mechanism and gating mechanism, and generate prediction information.
6. The traffic prediction method based on dynamic causal analysis and spatiotemporal adaptive fusion graph learning according to claim 5 is characterized in that: Step S41 uses the K-means algorithm to perform cluster analysis on a data set containing n weeks. The method is as follows: the data set is divided into continuous periodic data of one week in length, and the K-means algorithm is used to perform cluster analysis on the data set containing n weeks, so as to effectively divide these data points into k different clusters. In the clustering process, each data sample will be assigned to the cluster to which the cluster center closest to it belongs, so as to ensure that the data points within each cluster have a high degree of similarity. After clustering, the model further identifies and selects the most representative one-week data, and uses the data as a benchmark for subsequent analysis. Then, the Granger causality test method based on a sliding window is used to learn the causal relationship between nodes on the data. Granger causality test first constructs two linear regression models (partial model Y p and the complete model Y f ) to predict x based on past observations j (t), where t=1,2,...,T; the partial model and the complete model formula are expressed as: Among them, x' j (t) represents the prediction for node j, β p and β f is the lag term parameter; by calculating the sum of squared errors (SSR) of the two models p ,SSR f ), calculated as Granger causality test hypothesis H0: variable x i Past information cannot help predict variable x j The future value of x can be tested by using the F-index. When the null hypothesis is rejected, the additional information can improve the prediction, that is, x i x j It has a causal effect, and the calculation formula is: Among them, d p and d f are the degrees of freedom of the two models, L lag , 2L lag ; T is the total number of samples in the time series; then, we can Td f The probability of the null hypothesis is estimated by the F distribution of -1. The threshold sig of the F-index test is set to 0.
05. If the probability is lower than the significant threshold sig, the null hypothesis is rejected and there is a Granger causality relationship from x i to x j Considering the obvious periodicity of traffic flow, the historical traffic data is processed in a certain way. First, the historical traffic data is divided into one-week time steps, and then the K-means aggregation algorithm is used to aggregate and select the most representative one-week data from it. This data can reflect the characteristics of all node features that change dynamically over time within a week. Then, the sliding window {[s q :e q ]|0≤s q <e q ≤T}, extract the data, set the sliding window size to a time step of one day, and perform Granger causality test on the data to analyze the daily causal impact; finally generate the corresponding daily causal adjacency matrix W (d) , which is: Among them, p is the P value calculated in the Granger causality test, which is used to determine whether the hypothesis H0 in the hypothesis test will be rejected, and sig is the significance threshold.
7. The traffic prediction method based on dynamic causal analysis and spatiotemporal adaptive fusion graph learning according to claim 5 or 6, characterized in that: The method for realizing weighted feature fusion by calculating the attention scores of the central node and the neighboring nodes in step S42 is: The aggregation update process of the graph attention mechanism can be expressed as: in, Represents node v i and v j The attention coefficient between represents the neighbor set of a node in the graph, that is, LR(·) represents the LeakyReLU function; is a learnable parameter variable, D represents the dimension, is the weight matrix for linear transformation, Represents node v i Features at time step t; sum and aggregate the features generated by multi-head attention, K represents the number of heads, and W k is the attention coefficient and weight matrix of the kth attention head; is node v i The output at time step t, the final output of CGL is 8. The traffic prediction method based on dynamic causal analysis and spatiotemporal adaptive fusion graph learning according to claim 7 is characterized in that: The method for generating the corresponding adaptive adjacency matrix in step S43 is: The adaptive adjacency matrix formula is: in, is the embedding dictionary encoding each traffic road node, N is the number of nodes, d is the embedding dimension, E1 is the source node embedding, is the target node embedding; Softmax is the normalization function, and ReLU is the nonlinear activation function; GCN is used to realize the feature aggregation of adaptive graphs; the graph convolution operation in the spectral domain is approximated by the first Chebyshev polynomial expansion and extended to high-dimensional GCN. The corresponding graph convolution operation can be expressed as: in represents the output of AGL, Θ is the learnable graph convolution kernel, and l represents the number of layers; The method for generating prediction information in step S44 is: Apply spatial gate fusion to fuse two inputs and and They come from the outputs of AGL and CGL respectively; the gated fusion mechanism is as follows: in are all learnable parameters. Finally, the output of this hybrid graph learning block is 9. The traffic prediction method based on dynamic causal analysis and spatiotemporal adaptive fusion graph learning according to claim 8 is characterized in that: The method of using the spatiotemporal adaptive module to capture the spatiotemporal adaptive trend at the node level in step S5 is: linearly transform the node embedded in E1 to obtain a graph node query Q = E1W Q ,in and The output of GatedTCN Convert to To get the key of the node in the time dimension, Output of the hybrid graph learning module pass Perform a linear transformation to obtain the key of the node in the spatial dimension, where Calculate the attention vectors respectively, and in, and and are the temporal and spatial attention of the graph nodes respectively. The output of STAM is: in, and They are the attention scores of the nodes in time and space dimensions respectively; is the output of STAM and also the final output of the l-th layer model.
10. The traffic prediction method based on dynamic causal analysis and spatiotemporal adaptive fusion graph learning according to claim 9 is characterized in that: The method of connecting the output of the STAM module to the output layer through a jump connection in step S6 is: by stacking multiple layers, the temporal receptive field of the spatiotemporal causal hybrid graph neural network STCHGNN is continuously increased; the bottom block pays more attention to the traffic characteristics of adjacent time, and the high-level block pays attention to the long-term temporal traffic information; the jump connection is used to solve the spatial dependency modeling at different time levels, and the summation is used to fuse all the outputs after the jump connection, and the result is expressed as Finally, two fully connected layers are used to implement the output layer to generate the final prediction results. The output layer can be expressed as follows: in, and is a learnable parameter, It is the final output of the entire model; The mean absolute error between the predicted value and the true value is used as the loss function and minimized by back propagation. The formula is: Among them, θ represents all learnable parameters of the model, represents the model's prediction of all traffic nodes at time step i, Y i is the true value.
Citation Information
Cited By
Traffic flow prediction model for realizing co-mining of traffic point semantics and network topology
CN119443156A
Traffic flow prediction method based on dynamic sparse graph convolution GRU
CN119694142A
A traffic flow prediction method based on dynamic sparse graph convolution GRU
CN119694142B
Teaching content display data determination method and device and computer equipment
CN119938955A
Task scene spatio-temporal data prediction method, system and device and medium
CN120180073A
