Traffic flow prediction method based on multi-scale lead-lag relation modeling
By constructing a multi-scale leading lag graph, combining predefined rules and learnable graph structures, the problem that existing traffic flow prediction methods ignore the multi-scale leading lag relationship is solved, and the accuracy and reliability of prediction are improved.
Patent Information
- Application Number
- CN202411537183.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-31
- Publication Date
- 2025-02-07
- Estimated Expiration
- 2044-10-31
AI Technical Summary
Existing traffic flow prediction methods usually ignore the leading lag relationship between the traffic flows of each sensor between different time steps, and only focus on the relationships under a single spatial scale, and fail to fully consider the multi-scale leading lag relationship.
By constructing a multi-scale leading lag graph, combining predefined rules and learnable graph structures, the leading lag effect of dynamic attenuation is introduced to effectively model and utilize the multi-scale leading lag relationship between features.
It improves the accuracy and reliability of traffic flow forecasting and can better serve the construction of intelligent transportation systems and smart cities.
Smart Images

Figure CN119399954A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of intelligent transportation systems, and in particular relates to a traffic flow prediction method based on multi-scale lead-lag relationship modeling. Background Art
[0002] Traffic flow prediction plays an important role in intelligent transportation systems and is also one of the core technologies for smart city construction. Accurate traffic flow prediction results can effectively dispatch traffic resources, alleviate traffic congestion, and provide reliable advice for citizens' daily travel. Therefore, traffic flow prediction has become a research hotspot in academia and industry.
[0003] Due to the complex temporal and spatial relationships in traffic flow sequences, accurately predicting traffic flow faces great challenges. In the past few decades, traffic flow prediction methods have evolved from statistical-based methods to deep learning-based methods. Due to the powerful representation ability of deep learning methods, they have become the mainstream method for current traffic flow prediction. These methods can be divided into two categories based on whether the traffic of other sensors is considered when predicting the traffic flow of each vehicle flow sensor. The first type of method usually uses models such as Recurrent Neural Network (RNN), Convolutional Neural Network (CNN), Attention Network (Attention Network), Multi-layer Perceptrons (MLP) to predict traffic flow by modeling the temporal relationship between each sensor itself at different time steps. The second type of method is usually based on models such as Attention Network, Multi-layer Perceptron, Graph Neural Network (GNN) to predict traffic flow by modeling the spatial relationship between traffic flows of each sensor. However, most existing methods tend to only focus on the relationship between sensor traffic flows themselves at different time steps, or the relationship between traffic flows of each sensor in the same time step, while ignoring the leading and lagging relationship between traffic flows of each sensor at different time steps.
[0004] In traffic flow prediction, the lead-lag relationship is reflected in many aspects. For example, when a traffic accident occurs in a certain area, the traffic sensors at the scene of the accident will quickly record the drop in traffic flow, while sensors farther away from the accident site may only begin to reflect the change in traffic flow after a few minutes. Therefore, modeling the lead-lag relationship is crucial for analyzing and understanding the dynamic changes in traffic flow in the overall road network. At present, there are a few methods that specifically model the lead-lag relationship. For example, the dynamic time warping (DTW) algorithm or the cross-correlation function is used to calculate the similarity of two different sequences at different time delays. If the similarity is high at a certain time delay, it can be considered that there is a lead-lag relationship between the two sequences. However, these methods only focus on the lead-lag relationship at a single spatial scale, ignoring the lead-lag relationship at different spatial scales.
[0005] Therefore, it is necessary to provide a traffic flow prediction method that can comprehensively consider the lead-lag relationship at different spatial scales, so as to improve the accuracy and reliability of traffic flow prediction, and thus better serve the construction of intelligent transportation systems and smart cities. Summary of the invention
[0006] In view of the above, the purpose of the present invention is to provide a traffic flow prediction method based on multi-scale lead-lag relationship modeling, which uses the temporal similarity between traffic flow sequences to construct different spatial scales, and introduces a multi-scale lead-lag graph at each scale by combining predefined rules and learnable graph structures, and considers the lead-lag effect of dynamic attenuation, effectively models and utilizes the lead-lag relationship between features, thereby further improving the prediction accuracy of traffic flow. In the context of smart cities, the present invention has broad application prospects in the fields of traffic resource scheduling, road network planning, travel route recommendation, etc.
[0007] In order to achieve the above-mentioned invention object, the technical solution provided by the present invention is as follows:
[0008] The embodiment of the present invention provides a traffic flow prediction method based on multi-scale lead-lag relationship modeling, comprising the following steps:
[0009] The similarity between the original traffic flow sequences and the similarity between the standardized traffic flow sequences are calculated to construct the original spatial graph, and the spatial graphs at different spatial scales and the allocation matrices at different spatial scales are constructed based on the original spatial graph;
[0010] A traffic flow prediction model is constructed, which includes a multi-scale feature extraction module, a multi-scale lead-lag mask construction module, a multi-scale lead-lag graph learning module, a multi-scale lead-lag graph convolution module and a prediction module. In the multi-scale feature extraction module, multi-scale features are extracted from the selected standardized traffic flow sequence.
[0011] In the multi-scale lead-lag mask construction module, the multi-scale lead-lag mask is constructed based on the distribution matrix and spatial graph at different spatial scales based on the mutual correlation coefficient and Granger causality detection;
[0012] In the multi-scale lead-lag map learning module, the multi-scale lead-lag mask learning is combined to obtain the multi-scale lead-lag map;
[0013] In the multi-scale lead-lag graph convolution module, an attenuated multi-scale lead-lag graph is constructed according to the multi-scale features and graph convolution is performed on it to obtain multi-scale lead-lag features. Graph convolution is performed on spatial graphs at different spatial scales to obtain multi-scale spatial features. The multi-scale lead-lag features and multi-scale spatial features are fused to obtain updated multi-scale features.
[0014] In the prediction module, predictions are made at each scale based on the updated multi-scale features, and the multi-scale prediction results are integrated to obtain the final traffic flow prediction result;
[0015] All standardized traffic flow sequences are used to train the traffic flow prediction model, and the trained traffic flow prediction model is used to predict traffic flow.
[0016] Preferably, the calculating the similarity between the original traffic flow sequences and the similarity between the normalized traffic flow sequences to construct the original spatial graph comprises:
[0017] Using the dynamic time warping algorithm, calculate all the original traffic flow sequences X raw The similarity between the two and the traffic flow sequence after standard processing The similarity between them is calculated based on the first threshold ∈ 1 and the second threshold ∈ 2 The first spatial graph D is constructed respectively 1 and the second spatial graph D 2 , the calculation formula is as follows:
[0018]
[0019] Among them, DTW(·) is the dynamic time warping algorithm;
[0020] D 1 and D 2 Take the intersection and get the original space graph D.
[0021] Preferably, constructing the spatial graphs at different spatial scales and the allocation matrices at different spatial scales based on the original spatial graph includes:
[0022] Using the spectral clustering algorithm, the original spatial graph D is hierarchically grouped, and the calculation formula is as follows:
[0023] S s = SpectralClustering(N s ,D s-1 )
[0024] Among them, SpectralClustering(·) is the spectral clustering algorithm, N s is the number of groups corresponding to scale s, D s-1 is the spatial graph corresponding to scale s-1, is the distribution matrix corresponding to scale s, indicating the distribution of sequences of scale s-1 to groups of scale s, and finally obtaining the distribution matrix S at different spatial scales 1 ,S 2 ,…,S S , where S is the total number of spatial scales;
[0025] Spatial graph D at scale s s It is calculated based on the spatial graph of scale s-1 and the allocation matrix corresponding to scale s. The calculation formula is as follows:
[0026] D s =(S s ) T D s-1 S s
[0027] in, The edges in D represent the spatial relationship between groups at scale s. When s = 0, D 0 =D, which is the original spatial map, and finally the spatial maps D, D at different spatial scales are obtained. 1 ,…,D S .
[0028] Preferably, extracting multi-scale features from the selected standardized traffic flow sequence in the multi-scale feature extraction module includes:
[0029] For scale s, the corresponding traffic flow sequence X s , the calculation formula is as follows:
[0030]
[0031] in, Is of shape 1×N s-1 The one-hot vector of X, when s = 0, 0 That is, the original normalized traffic flow sequence is finally extracted into a multi-scale traffic flow sequence;
[0032] The obtained multi-scale traffic flow sequence is feature encoded, where for scale s, the segment length is p s , each sequence is divided into P s Duan, P s =T / p s , T is the time window size. For each small sequence, the features extracted by the linear layer are calculated as follows:
[0033]
[0034] Among them, MLP(·) is a multi-layer perceptron, is the segmented sequence under scale s, is the extracted feature, d is the feature dimension, and finally multi-scale features at all spatial scales are obtained.
[0035] Preferably, in the multi-scale lead-lag mask construction module, constructing a multi-scale lead-lag mask based on the distribution matrix and the spatial graph at different spatial scales based on the mutual correlation coefficient and Granger causality detection includes:
[0036] For any sequence at scale s+1, according to the allocation matrix S at scale s s , filter out subsequences under scale s that belong to any sequence under scale s+1, and for these subsequences, according to the spatial graph D under scale s s , filter out adjacent subsequence pairs, calculate their mutual correlation coefficients, and if their mutual correlation coefficients are greater than the threshold, perform Granger causality test on the subsequence pairs and calculate the F-test coefficients of the subsequence pairs. If the F-test coefficient is greater than the threshold, it is considered that there is a lead-lag relationship between the subsequence pairs, which is used to construct a multi-scale lead-lag mask and record the corresponding lag time steps.
[0037] Preferably, the multi-scale lead-lag map learning module is combined with the multi-scale lead-lag mask learning to obtain the multi-scale lead-lag map, comprising:
[0038] For scale s, first, the learnable sequence embedding representation is randomly initialized and time embedding representation Where N s is the number of sequences under scale s, P s is the number of segments of each sequence, d e is the number of dimensions of the embedding representation; secondly, the degree of the spatial graph at the corresponding scale, the out-degree and in-degree of the leading-lag mask are calculated, and the central embedding representation is learned based on these three The calculation formula is as follows:
[0039]
[0040] in, Represents the sequence n in the spatial graph D under scale s s The degree of and It represents the sequence n under the leading and lagging mask M under the scale s s The out-degree and in-degree of is the central embedding representation of sequence n;
[0041] Use the sequence embedding representation of all sequences at scale s Temporal Embedding Representation and the center embedding representation For graph learning, the calculation formula is as follows:
[0042]
[0043] G s =softmax(relu(E s (E s ) T ))
[0044] in, represents addition with propagation mechanism, relu(·) is ReLU activation function, softmax(·) is Softmax function, is the node embedding representation of fusion at scale s, the superscript T is transposed, is the fully connected graph learned at scale s;
[0045] Three sparse rules are used to s The sparse processing is performed sequentially, and only the leading and lagging relationships with spatial relationships between sequences are retained, and G s Set it to upper triangular form, and then retain the K edges with the largest edge weights in the graph to obtain the sparse graph
[0046] According to the leading lag mask M s , construct a connection graph G s′ With C s Combined, we get the final lead-lag diagram, and the calculation formula is as follows:
[0047] A s =G s′ +wC s
[0048] in, is the lead-lag map at scale s, w is the learnable weight, and finally the multi-scale lead-lag maps at different spatial scales are learned.
[0049] Preferably, the step of constructing an attenuated multiscale lead-lag graph according to the multiscale features in the multiscale lead-lag graph convolution module and performing graph convolution on the graph to obtain the multiscale lead-lag features includes:
[0050] According to the calculated multi-scale features, the attention mechanism is used to dynamically adjust the weights of the edges in the lead-lag graph. For scale s, the calculation formula is as follows:
[0051] Q s =Linear1(H s ), K s =Linear2(H s )
[0052]
[0053] Among them, Q s is the query in the attention mechanism, and Linear1(·) is the query for Q s The corresponding linear layer, K s is the key value in the attention mechanism, Linear2(·) is to find K s The corresponding linear layer, d is the dimension of the feature vector, the superscript T is the transpose, A s′ A dynamic lead-lag diagram considering multi-scale features;
[0054] According to the lag time interval, the dynamic lead-lag diagram is further adjusted using the decay function, and the calculation formula is as follows:
[0055] Λ s =1-β s exp(γ s Δt)
[0056] α s =A s′ ⊙Λ s
[0057] Among them, Δt is the time interval between the historical time step and the current time step, β s and γ s is the parameter of the decay function, is the attenuation coefficient calculated based on the attenuation function and time interval, α s This is the dynamic lead-lag diagram after considering the attenuation effect;
[0058] In α s Graph convolution is performed on the graph, and the calculation formula is as follows:
[0059]
[0060] in, is the updated lead-lag feature at scale s, is the identity matrix, It is a multi-layer perceptron, and finally performs graph convolution on the multi-scale lead-lag graph to obtain the multi-scale lead-lag features.
[0061] Preferably, performing graph convolution on spatial graphs at different spatial scales to obtain multi-scale spatial features includes:
[0062] At scale s, in the spatial graph D s Graph convolution is performed on the graph, and the calculation formula is as follows:
[0063]
[0064] in, is the updated spatial feature at scale s, is the identity matrix, It is a multi-layer perceptron, and finally multi-scale spatial features are obtained by performing graph convolution on spatial graphs at different spatial scales.
[0065] Preferably, the step of fusing the multi-scale lead-lag feature and the multi-scale spatial feature to obtain an updated multi-scale feature includes:
[0066] The multi-scale leading and lagging features and the multi-scale spatial features are integrated. For scale s, the calculation formula is as follows:
[0067]
[0068] in, is the fusion feature of the output scale s, λ1 and λ2 are learnable weights, is the fusion feature at scale s output by the previous network layer, i.e., the residual, and finally the updated multi-scale features at all spatial scales are obtained.
[0069] Preferably, the prediction module performs prediction at each scale according to the updated multi-scale features, and fuses the multi-scale prediction results to obtain the final traffic flow prediction result, including:
[0070] For scale s, It is sent to the predictor composed of multiple layers of MLP, and the calculation formula is as follows:
[0071]
[0072] Among them, Predictor(·) is the predictor, N is the scale s s The prediction results of the H-step sequence are combined with the prediction values of each scale to obtain the final prediction result. The calculation formula is as follows:
[0073]
[0074] Among them, S s is the distribution matrix under scale s, l is the index of the number of cumulative multiplications, and the superscript T is the transpose. is the predicted value of the traffic flow sequence obtained at the original scale, is the final prediction result.
[0075] The present invention combines predefined rules and graph learning technology to model the directed and sparse multi-scale lead-lag relationship in the traffic flow sequence, and considers the lead-lag effect of dynamic attenuation to effectively utilize the multi-scale lead-lag relationship. Compared with the prior art, the present invention has at least the following beneficial effects:
[0076] (1) The present invention designs a multi-scale lead-lag graph learning module, which combines the multi-scale lead-lag masks predefined based on cross-correlation and Granger causality to learn the lead-lag graphs at each scale. The learned graph is sparsely processed to model the directed and sparse lead-lag relationship between features.
[0077] (2) The present invention designs a multi-scale lead-lag graph convolution module, combines the attention mechanism and the attenuation function, considers the lead-lag effect of dynamic attenuation, performs graph convolution on the multi-scale lead-lag graph, and updates the multi-scale features. BRIEF DESCRIPTION OF THE DRAWINGS
[0078] 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 creative work.
[0079] Figure 1 It is an overall flow chart of a traffic flow prediction method based on multi-scale lead-lag relationship modeling provided by an embodiment of the present invention;
[0080] Figure 2 It is an overall framework diagram of a traffic flow prediction method based on multi-scale lead-lag relationship modeling provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0081] To make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific implementation methods described herein are only used to explain the present invention and do not limit the scope of protection of the present invention.
[0082] The inventive concept of the present invention is as follows: in view of the problem of how to model the lead-lag relationship at multiple spatial scales in the traffic flow sequence in the prior art, the embodiment of the present invention provides a traffic flow prediction method based on multi-scale lead-lag relationship modeling, firstly, the traffic flow sequence is preprocessed, and the samples are divided by a sliding window method based on the time sequence to construct a data set; secondly, a multi-scale feature extraction module is introduced to extract features from the traffic flow sequence at each spatial scale; then, a multi-scale lead-lag mask construction module is introduced to predefine the lead-lag relationship between features at each scale based on the mutual correlation and Granger causality between multi-scale features; then, a multi-scale lead-lag graph learning module is introduced to learn the lead-lag graph at each scale in combination with the multi-scale lead-lag mask to model the directed and sparse lead-lag relationship between features; then, a multi-scale lead-lag graph convolution module is introduced to consider the lead-lag effect of dynamic attenuation, perform graph convolution on the multi-scale lead-lag graph, and update the multi-scale features; finally, the updated multi-scale features are used to make predictions at each scale, and the multi-scale prediction results are fused to obtain the final traffic flow prediction result.
[0083] Figure 1 is an overall flow chart of a traffic flow prediction method based on multi-scale lead-lag relationship modeling provided by an embodiment of the present invention, Figure 2 is a general framework diagram of a traffic flow prediction method based on multi-scale lead-lag relationship modeling provided by an embodiment of the present invention. Figure 1 and Figure 2 As shown, the embodiment provides a traffic flow prediction method based on multi-scale lead-lag relationship modeling, comprising the following steps:
[0084] Step 1: Process the given original traffic flow sequence and eliminate outliers and missing values. Standardize the cleaned data. Based on the time sequence, use the sliding window method to divide the standardized data into samples to construct the data set.
[0085] The outliers (such as values beyond the normal range) in the given original traffic flow sequence are removed, and the missing values are interpolated using linear interpolation. The cleaned data is subjected to z-score standardization, and the calculation formula is as follows:
[0086]
[0087] Among them, X i,raw is the i-th original traffic flow sequence, μ i,raw is the average value in the i-th original traffic flow sequence, σ i,raw is the variance of the original traffic flow sequence of the ith item, X i is the i-th traffic flow sequence after standardization.
[0088] Based on the time sequence, the time window size T is set manually according to experience, and the standardized data is divided into samples using a fixed-length sliding step to construct a data set.
[0089] Step 2: Calculate the similarity between the traffic flow sequences collected by all traffic flow sensors in the dataset. Represent the traffic flow sensors as nodes and the similarity values as edges to construct the original spatial graph D.
[0090] Using the DTW algorithm, the similarity between the original traffic flow sequences in the data set and the similarity between the standardized traffic flow sequences are calculated. According to the corresponding threshold, the DTW similarity greater than the threshold is set to 1, and the DTW similarity less than the threshold is set to 0. The calculation formula is as follows:
[0091]
[0092] Among them, X raw and are the original traffic flow sequence and the standardized traffic flow sequence respectively. ∈ 1 and ∈ 2 As the corresponding threshold, D 1 and D 2 Take the intersection and get the final original space graph D.
[0093] Step 3: Use the spectral clustering algorithm to perform hierarchical clustering on the original spatial graph D to obtain spatial graphs D, D at different spatial scales. 1 ,…,D S and the corresponding allocation matrix S 1 ,S 2 ,…,S S .
[0094] Using the spectral clustering algorithm, the original spatial graph D is hierarchically grouped, and the calculation formula is as follows:
[0095] S s = SpectralClustering(N s ,D s-1 ), (3)
[0096] Among them, SpectralClustering(·) is the spectral clustering algorithm, N s is the number of groups corresponding to scale s, D s-1 is the spatial graph corresponding to scale s-1, is the distribution matrix corresponding to scale s, indicating the distribution of sequences of scale s-1 to groups of scale s, and finally obtaining the distribution matrix S at different spatial scales 1 ,S 2 ,…,S S, where S is the total number of spatial scales.
[0097] Spatial graph D at scale s s It is calculated based on the spatial graph of scale s-1 and the allocation matrix corresponding to scale s. The calculation formula is as follows:
[0098] D s =(S s ) T D s-1 S s , (4)
[0099] in, The edges in D represent the spatial relationship between groups at scale s. When s = 0, D 0 =D, which is the original spatial map, and finally the spatial maps D, D at different spatial scales are obtained. 1 ,…,D S .
[0100] Step 4: Divide the data set into batches according to a fixed batch size, with a total batch size of B.
[0101] The data set is divided into batches based on the batch size M set manually by experience. The total number of batches is B. The calculation formula is as follows:
[0102]
[0103] Among them, N Samples is the total number of samples in the dataset.
[0104] Step 5: Randomly select a batch of training samples from the data set, where each sample contains the traffic flow sequence of N traffic sensors on the traffic network for T time steps.
[0105] Step 6: Use the traffic flow sequence X and the allocation matrix S at the original spatial scale 1 ,S 2 ,…,S S , calculate the multi-scale traffic flow sequence X 1 ,X 2 ,…,X S , and feature encode the multi-scale traffic flow sequence to obtain multi-scale features.
[0106] For scale s, the corresponding traffic flow sequence X s , the calculation formula is as follows:
[0107]
[0108] in, Is of shape 1×N s-1The one-hot vector of X, when s = 0, 0 That is the original traffic flow sequence.
[0109] For the obtained multi-scale traffic flow sequence, feature encoding is performed. Specifically, for each scale, the traffic flow sequence is segmented according to different segment lengths. For scale s, the segment length is p. s , each sequence can be divided into P s Duan, P s =T / p s For each short sequence, the features extracted by the linear layer are calculated as follows:
[0110]
[0111] Among them, MLP(·) is a multi-layer perceptron, is the segmented sequence under scale s, is the extracted feature, d is the feature dimension, and finally multi-scale features at all spatial scales are obtained.
[0112] Step 7: For any sequence at scale s+1, according to the allocation matrix S s , filter out the subsequences belonging to the sequence under scale s. For these subsequences, according to the spatial graph D s , filter out adjacent subsequence pairs and calculate their mutual correlation coefficient. If the mutual correlation coefficient is greater than the threshold, Granger causality test is performed on the subsequence pair. If the F-test coefficient is greater than the threshold, it is considered that there is a lead-lag relationship between the subsequence pairs, which is used to construct a multi-scale lead-lag mask and record the corresponding lag time step.
[0113] Assume that at scale s, the lead-lag relationship only exists between pairs of sequences that belong to the same sequence at scale s+1 and have a spatial relationship with each other. For a sequence at scale s+1, according to the distribution matrix S s , filter out all subsequences belonging to the sequence under scale s. Then according to the spatial graph D s , and further filter out adjacent subsequence pairs from these subsequences.
[0114] For the selected subsequence pairs, calculate their mutual correlation coefficients at different lag time steps. Here, the lag time step value belongs to {0, p s ,2p s ,…,T}, that is, the value is taken according to the integer multiple of the segment length. If the calculated mutual correlation coefficient is greater than the threshold, the subsequence pair is further Granger causality tested at the lag time step to calculate its F-test coefficient. If the F-test coefficient is greater than the threshold, it is considered that there is a lead-lag relationship between the subsequence pairs.
[0115] After traversing all subsequence pairs at scale s, the leading and lagging masks at scale s can be constructed Specifically, if at scale s, sequence i has a leading-lagging relationship with sequence j with a lag time step τ, then If there is no lead-lag relationship, it is recorded as 0.
[0116] Step 8: For each scale, randomly initialize the learnable sequence embedding representation and time embedding representation. Calculate the degree of the spatial graph, the out-degree and in-degree of the lead-lag mask at the corresponding scale, and learn the center embedding representation based on the three. Input the sequence embedding representation, time embedding representation, and center embedding representation into the lead-lag graph learning module, and combine with the multi-scale lead-lag mask to learn a directed and sparse multi-scale lead-lag graph.
[0117] For scale s, first, the learnable sequence embedding representation is randomly initialized and time embedding representation Where N s is the number of sequences under scale s, P s is the number of segments of each sequence, d e is the number of dimensions of the embedding representation. Secondly, the degree of the spatial graph at the corresponding scale, the out-degree and in-degree of the leading-lag mask are calculated, and the center embedding representation is learned based on these three. The calculation formula is as follows:
[0118]
[0119] in, Represents the sequence n in the spatial graph D under scale s s The degree of and It represents the sequence n under the leading and lagging mask M under the scale s s The out-degree and in-degree of .
[0120] is the central embedding representation of sequence n.
[0121] use and For graph learning, the calculation formula is as follows:
[0122]
[0123] G s =softmax(relu(Es(Es) T )), (9)
[0124] in, represents addition with propagation mechanism, relu(·) is ReLU activation function, softmax(·) is Softmax function, is the fused node embedding representation, the superscript T stands for transposition, is the fully connected graph for learning.
[0125] Three sparse rules are used to s The sparse processing is performed in sequence. First, only the lead-lag relationship with spatial relationship between sequences is retained. Second, since the lead-lag relationship means that the past segment of a sequence will affect the future segment of another sequence, G s Set it to the upper triangular form. Furthermore, retain the K edges with the largest edge weights in the graph, and get the sparse graph
[0126] According to the leading lag mask M s , construct a connection graph like is 1, then is a diagonal matrix τ steps above the main diagonal.
[0127] G s′ With C s Combined, we get the final lead-lag diagram, and the calculation formula is as follows:
[0128] A s =G s′ +wC s , (10)
[0129] in, is the lead-lag map at scale s, w is the learnable weight, and finally the multi-scale lead-lag maps at different spatial scales are learned.
[0130] Step 9: Based on the multi-scale features, the attention mechanism is used to dynamically adjust the weights of the edges in the lead-lag graph. The exponential decay function is used to calculate the decay effect according to the lag time interval, and the weights of the edges in the lead-lag graph are further adjusted. Graph convolution is performed on the adjusted lead-lag graph to update the multi-scale lead-lag features.
[0131] According to the multi-scale feature H calculated in formula (7) s , the attention mechanism is used to dynamically adjust the weights of the edges in the leading-lagging graph. The calculation formula is as follows:
[0132]
[0133] Among them, Q s is the query in the attention mechanism, and Linear1(·) is the query for Q s The corresponding linear layer, K sis the key value in the attention mechanism, Linear2(·) is to find K s The corresponding linear layer, d is the dimension of the feature vector, the superscript T is the transpose, A s′ A dynamic lead-lag diagram considering multi-scale features.
[0134] Next, according to the lag time interval, the decay function is used to further adjust the dynamic lead-lag diagram. The calculation formula is as follows:
[0135] Λ s =1-β s exp(γ s Δt),
[0136] α s =A s′ ⊙Λ s , (12)
[0137] Among them, Δt is the time interval between the historical time step and the current time step, and is the time interval between the leading and lagging mask M. s Calculated, β s and γ s is the parameter of the decay function, is the attenuation coefficient calculated based on the attenuation function and time interval. s This is the dynamic lead-lag diagram after considering the attenuation effect. s Graph convolution is performed on the graph, and the calculation formula is as follows:
[0138]
[0139] in, represents the updated lead-lag characteristics at scale s, represents the identity matrix, Represents MLP.
[0140] Step 10: In the multi-scale space graph D,D 1 ,…,D S Graph convolution is performed on the multi-scale spatial features to obtain multi-scale spatial features, and the multi-scale leading and lagging features are fused with the multi-scale spatial features to obtain updated multi-scale features.
[0141] At scale s, in the spatial graph D s Graph convolution is performed on the graph, and the calculation formula is as follows:
[0142]
[0143] in, represents the updated spatial features at scale s, represents the identity matrix, Represents MLP, and finally multi-scale spatial features are obtained by performing graph convolution on spatial graphs at different spatial scales.
[0144] The updated leading and lagging features and spatial features are fused, and the calculation formula is as follows:
[0145]
[0146] in, is the fusion feature of the output scale s, λ1 and λ2 are learnable weights, is the fusion feature at scale s output by the previous network layer, i.e., the residual, and finally the updated multi-scale features at all spatial scales are obtained.
[0147] Step 11: Input the updated multi-scale features into the prediction module, make predictions at each scale, and fuse the multi-scale prediction results to obtain the final traffic flow prediction result.
[0148] For scale s, It is fed into a predictor consisting of two layers of MLP, and the calculation formula is as follows:
[0149]
[0150] Among them, Predictor(·) is the predictor, N is the scale s s The prediction results of the H-step sequence are obtained by integrating the prediction values of each scale to obtain the final prediction result. The calculation formula is as follows:
[0151]
[0152] Among them, S s is the distribution matrix calculated in step 3, l is the index of the number of cumulative multiplications, and the superscript T is the transpose. is the predicted value of the traffic flow sequence obtained at the original scale, is the final prediction result.
[0153] Step 12: Calculate the error between the true observed value and the model predicted value of all samples in a batch to obtain the training loss
[0154] Using mean absolute error as training loss The calculation formula is as follows:
[0155]
[0156] Among them, M is the total number of samples and m is the sample index.
[0157] Step 13, based on the training loss Adjust the network parameters in the entire model.
[0158] Based on the training loss obtained in step 12 Update the network parameters θ in the entire model, and the calculation formula is as follows:
[0159]
[0160] Among them, η is an artificially set learning rate.
[0161] Step 14: Repeat steps 5-13 until all batches in the dataset participate in model training.
[0162] Step 15, repeat steps 5-14 until the specified number of iterations is reached.
[0163] Step 16: Input the traffic flow sequence to be predicted into the trained model to obtain the prediction result.
[0164] The specific implementation methods described above provide a detailed description of the technical solutions and beneficial effects of the present invention. It should be understood that the above is only the most preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, supplements and equivalent substitutions made within the scope of the principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A traffic flow prediction method based on multi-scale lead-lag relationship modeling, characterized in that: The following steps are involved: The similarity between the original traffic flow sequences and the similarity between the standardized traffic flow sequences are calculated to construct the original spatial graph, and the spatial graphs at different spatial scales and the allocation matrices at different spatial scales are constructed based on the original spatial graph; A traffic flow prediction model is constructed, which includes a multi-scale feature extraction module, a multi-scale lead-lag mask construction module, a multi-scale lead-lag graph learning module, a multi-scale lead-lag graph convolution module and a prediction module. In the multi-scale feature extraction module, multi-scale features are extracted from the selected standardized traffic flow sequence. In the multi-scale lead-lag mask construction module, the multi-scale lead-lag mask is constructed based on the distribution matrix and spatial graph at different spatial scales based on the mutual correlation coefficient and Granger causality detection; In the multi-scale lead-lag map learning module, the multi-scale lead-lag mask learning is combined to obtain the multi-scale lead-lag map; In the multi-scale lead-lag graph convolution module, an attenuated multi-scale lead-lag graph is constructed according to the multi-scale features and graph convolution is performed on it to obtain multi-scale lead-lag features. Graph convolution is performed on spatial graphs at different spatial scales to obtain multi-scale spatial features. The multi-scale lead-lag features and multi-scale spatial features are fused to obtain updated multi-scale features. In the prediction module, predictions are made at each scale based on the updated multi-scale features, and the multi-scale prediction results are integrated to obtain the final traffic flow prediction result; All standardized traffic flow sequences are used to train the traffic flow prediction model, and the trained traffic flow prediction model is used to predict traffic flow.
2. The traffic flow prediction method based on multi-scale lead-lag relationship modeling according to claim 1 is characterized in that: The calculating the similarity between the original traffic flow sequences and the similarity between the normalized traffic flow sequences to construct the original spatial graph includes: Using the dynamic time warping algorithm, calculate all the original traffic flow sequences X raw The similarity between the two and the traffic flow sequence after standard processing The similarity between them is based on the first threshold set# 1 and the second threshold ∈ 2 The first spatial graph D is constructed respectively 1 and the second spatial graph D 2 , the calculation formula is as follows: Among them, DTW(·) is the dynamic time warping algorithm; D 1 and D 2 Take the intersection and get the original space graph D.
3. The traffic flow prediction method based on multi-scale lead-lag relationship modeling according to claim 1 is characterized in that: The step of constructing the spatial graphs at different spatial scales and the allocation matrices at different spatial scales based on the original spatial graph includes: Using the spectral clustering algorithm, the original spatial graph D is hierarchically grouped, and the calculation formula is as follows: S s =SpectralClustering(N s ,D s-1 ) Among them, SpectralClustering(·) is the spectral clustering algorithm, N s is the number of groups corresponding to scale s, D s-1 is the spatial graph corresponding to scale s-1, is the distribution matrix corresponding to scale s, indicating the distribution of sequences of scale s-1 to groups of scale s, and finally obtaining the distribution matrix S at different spatial scales 1 ,S 2 ,…,S S , where S is the total number of spatial scales; Spatial graph D at scale s s It is calculated based on the spatial graph of scale s-1 and the allocation matrix corresponding to scale s. The calculation formula is as follows: D s =(S s ) T D s-1 S s in, The edges in D represent the spatial relationship between groups at scale s. When s = 0, D 0 =D, which is the original spatial map, and finally the spatial maps D, D at different spatial scales are obtained. 1 ,…,D S .
4. The traffic flow prediction method based on multi-scale lead-lag relationship modeling according to claim 3 is characterized in that: The multi-scale feature extraction module extracts multi-scale features from the selected standardized traffic flow sequence, including: For scale s, the corresponding traffic flow sequence X s , the calculation formula is as follows: in, Is of shape 1×N s-1 The one-hot vector of X, when s = 0, 0 That is, the original normalized traffic flow sequence is finally extracted into multi-scale traffic flow sequence; The obtained multi-scale traffic flow sequence is feature encoded, where for scale s, the segment length is p s , each sequence is divided into P s Duan, P s =T / p s , T is the time window size. For each small sequence, the features extracted by the linear layer are calculated as follows: Among them, MLP(·) is a multi-layer perceptron, is the segmented sequence under scale s, is the extracted feature, d is the feature dimension, and finally multi-scale features at all spatial scales are obtained.
5. The traffic flow prediction method based on multi-scale lead-lag relationship modeling according to claim 1 is characterized in that: The multi-scale lead-lag mask construction module constructs a multi-scale lead-lag mask based on the distribution matrix and the spatial graph at different spatial scales based on the mutual correlation coefficient and Granger causality detection, including: For any sequence at scale s+1, according to the allocation matrix S at scale s s , filter out subsequences under scale s that belong to any sequence under scale s+1, and for these subsequences, according to the spatial graph D under scale s s , filter out adjacent subsequence pairs, calculate their mutual correlation coefficients, and if their mutual correlation coefficients are greater than the threshold, perform Granger causality test on the subsequence pairs and calculate the F-test coefficients of the subsequence pairs. If the F-test coefficient is greater than the threshold, it is considered that there is a lead-lag relationship between the subsequence pairs, which is used to construct a multi-scale lead-lag mask and record the corresponding lag time steps.
6. The traffic flow prediction method based on multi-scale lead-lag relationship modeling according to claim 4 is characterized in that: The multi-scale lead-lag map learning module combines the multi-scale lead-lag mask learning to obtain the multi-scale lead-lag map, including: For scale s, first, the learnable sequence embedding representation is randomly initialized and time embedding representation Where N s is the number of sequences under scale s, P s is the number of segments of each sequence, d e is the number of dimensions of the embedding representation; secondly, the degree of the spatial graph at the corresponding scale, the out-degree and in-degree of the leading-lag mask are calculated, and the central embedding representation is learned based on these three The calculation formula is as follows: in, Represents the sequence n in the spatial graph D under scale s s The degree of and It represents the sequence n under the leading and lagging mask M under the scale s s The out-degree and in-degree of is the central embedding representation of sequence n; Use the sequence embedding representation of all sequences at scale s Temporal Embedding Representation and the center embedding representation For graph learning, the calculation formula is as follows: G s =softmax(clock(E s (AND s ) T )) in, represents addition with propagation mechanism, relu(·) is ReLU activation function, softmax(·) is Softmax function, is the node embedding representation of fusion at scale s, the superscript T is transposed, is the fully connected graph learned at scale s; Three sparse rules are used to s The sparse processing is performed sequentially, and only the leading and lagging relationships with spatial relationships between sequences are retained, and G s Set it to upper triangular form, and then retain the K edges with the largest edge weights in the graph to obtain the sparse graph According to the leading lag mask M s , construct a connection graph G s′ With C s Combined, we get the final lead-lag diagram, and the calculation formula is as follows: A s =G s′ +wC s in, is the lead-lag map at scale s, w is the learnable weight, and finally the multi-scale lead-lag maps at different spatial scales are learned.
7. The traffic flow prediction method based on multi-scale lead-lag relationship modeling according to claim 6 is characterized in that: The attenuated multi-scale lead-lag graph is constructed according to the multi-scale features in the multi-scale lead-lag graph convolution module and graph convolution is performed to obtain the multi-scale lead-lag features, including: According to the calculated multi-scale features, the attention mechanism is used to dynamically adjust the weights of the edges in the lead-lag graph. For scale s, the calculation formula is as follows: Q s =Linear1(H s ),K s =Linear2(H s ) Among them, Q s is the query in the attention mechanism, and Linear1(·) is the query for Q s The corresponding linear layer, K s is the key value in the attention mechanism, Linear2(·) is to find K s The corresponding linear layer, d is the dimension of the feature vector, the superscript T is the transpose, A s′ A dynamic lead-lag diagram considering multi-scale features; According to the lag time interval, the dynamic lead-lag diagram is further adjusted using the decay function, and the calculation formula is as follows: L s =1-β s exp(γ s Δt) α s =A s′ ⊙ s Among them, Δt is the time interval between the historical time step and the current time step, β s and γ s is the parameter of the decay function, is the attenuation coefficient calculated based on the attenuation function and time interval, α s This is the dynamic lead-lag diagram after considering the attenuation effect; In α s Graph convolution is performed on the graph, and the calculation formula is as follows: in, is the updated lead-lag feature at scale s, is the identity matrix, It is a multi-layer perceptron, and finally performs graph convolution on the multi-scale lead-lag graph to obtain the multi-scale lead-lag features.
8. The traffic flow prediction method based on multi-scale lead-lag relationship modeling according to claim 7 is characterized in that: The multi-scale spatial features are obtained by performing graph convolution on spatial graphs at different spatial scales, including: At scale s, in the spatial graph D s Graph convolution is performed on the graph, and the calculation formula is as follows: in, is the updated spatial feature at scale s, is the identity matrix, It is a multi-layer perceptron, and finally multi-scale spatial features are obtained by performing graph convolution on spatial graphs at different spatial scales.
9. The traffic flow prediction method based on multi-scale lead-lag relationship modeling according to claim 8 is characterized in that: The method of fusing the multi-scale leading and lagging features with the multi-scale spatial features to obtain updated multi-scale features includes: The multi-scale leading and lagging features and the multi-scale spatial features are integrated. For scale s, the calculation formula is as follows: in, is the fusion feature of the output scale s, λ1 and λ2 are learnable weights, is the fusion feature at scale s output by the previous network layer, i.e., the residual, and finally the updated multi-scale features at all spatial scales are obtained.
10. The traffic flow prediction method based on multi-scale lead-lag relationship modeling according to claim 9 is characterized in that: The prediction module performs prediction at each scale according to the updated multi-scale features, and fuses the multi-scale prediction results to obtain the final traffic flow prediction result, including: For scale s, It is sent to the predictor composed of multiple layers of MLP, and the calculation formula is as follows: Among them, Predictor(·) is the predictor, N is the scale s s The prediction results of the H-step sequence are combined with the prediction values of each scale to obtain the final prediction result. The calculation formula is as follows: Among them, S s is the distribution matrix under scale s, l is the index of the number of cumulative multiplications, and the superscript T is the transpose. is the predicted value of the traffic flow sequence obtained at the original scale, is the final prediction result.
Citation Information
Patent Citations
Traffic flow prediction method based on multi-scale spatial feature mining
CN116070778A
Urban area passenger flow volume prediction method based on big data
CN116542391A
System and Method for Estimating a Future Traffic Density in an Environment
US20240304081A1
A computer-implemented method for forecasting traffic indicators in a road network
WO2024068527A1
Cited By
Prediction method and system based on multi-scale space-time hypergraph and lead lag structure
CN121188456A