Interpretable Spatiotemporal Analysis Methods for Traffic Congestion Prediction
By pre-training the STGCN model and generating a spatiotemporal interpretation model, combined with spatial and temporal masks, the second-order spatial relationships of the traffic network are separated, achieving high accuracy and interpretability in traffic congestion prediction and revealing the deep connections and key factors of traffic.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- TONGJI UNIV
- Filing Date
- 2022-09-08
- Publication Date
- 2026-07-03
AI Technical Summary
Existing traffic congestion prediction methods struggle to incorporate spatiotemporal information, clustering results fail to accurately reflect key congestion points, correlation analysis methods cannot fully reveal deep traffic connections and key factors, and the interpretability of neural networks is insufficient in regression problems and lacks in-depth explanations.
The STGCN model is pre-trained to construct a spatiotemporal interpretation generation model. Spatial and temporal preferences are extracted using initial spatial and temporal masks. Combined with perturbation and gradient-based interpretation methods, second-order spatial relationships are separated and spectral clustering is performed to extract key information on road congestion.
By extracting the deep influencing factors and spatiotemporal relationships between roads using the STGCN model, the accuracy and effectiveness of traffic prediction and interpretation are improved, the granularity of interpretation is reduced, and a multi-faceted model interpretation is obtained.
Smart Images

Figure CN115496202B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of machine learning technology, specifically relating to an interpretable spatiotemporal analysis method for traffic congestion prediction. Background Technology
[0002] With the rapid development of the social economy and the increasing travel demands of urban residents, the contradiction between traffic supply and demand has become increasingly prominent. Surveys show that most traffic congestion incidents are related to key congestion points. Therefore, analyzing urban congestion incidents and identifying key points within them is particularly important. However, extracting key congestion points from the entire traffic network is a challenging task. On the one hand, the roads in the network are intricately intertwined, resulting in highly coupled relationships between them, making it difficult to identify key points during analysis. On the other hand, factors influencing road congestion have many dimensions; different road segments have both temporal and spatial relationships, and social information such as points of interest (POIs) near the roads also affects the development of congestion events.
[0003] In recent years, researchers both domestically and internationally have done a great deal of work in the field of traffic congestion data mining. One popular method is to perform cluster analysis on roads, grouping road segments with similar traffic condition sequences into one category to find commonalities in congestion; another popular method is to extract association rules between road segments to obtain the influence relationships between different roads, thereby inferring the key occurrence points and propagation points of road congestion.
[0004] Interpretability methods in deep learning can generate explanations for traffic prediction models, containing key information influencing traffic congestion, and can also serve as a data mining approach. Interpretability techniques can be broadly categorized into pre-interpretation and post-interpretation. Pre-interpretation techniques involve designing and deploying more interpretability mechanisms within neural networks, such as regularization techniques to enhance interpretability. Post-interpretation techniques maintain the original model results, with low coupling between the interpretation and prediction processes. The interpretation process does not reduce the accuracy of the interpreted model, but the interpretation conclusions are often not entirely faithful to the original model. Current interpretability research largely focuses on post-interpretation, especially saliency methods. In graph neural networks, post-interpretation techniques can be further decomposed into gradient- and feature-based methods, perturbation-based methods, decomposition-based methods, and surrogate-based methods. In gradient- and feature-based methods, the importance of different features within the input data is represented by gradients or eigenvalues. Perturbation-based methods examine how changes in the input affect the model's output; the greater the impact on the model's output, the more important the input data. Decomposition methods use mathematical decomposition techniques (such as expansion approximation) to expand and decompose the model output, and then propagate the decomposition back to the hidden neural nodes until it reaches the input data. The decomposition result of the input data is a measure of its importance in interpretable analysis. Surrogate methods, on the other hand, train a simpler surrogate model on the generated datasets of examples under various classification criteria, based on the behavior of the model being explained. The surrogate model has stronger interpretability than the model being explained, and the interpretability analysis of the model being explained is ultimately completed by interpreting the surrogate model.
[0005] Traffic clustering struggles to integrate spatiotemporal information, resulting mostly in geographical divisions that fail to accurately reflect key congestion points. Furthermore, clustering results are often homogeneous with urban functional planning, requiring social science support for their conclusions, making it difficult to uncover valuable congestion information. Association analysis methods cannot fully aggregate topological relationships and spatiotemporal characteristics between road segments, and their model complexity cannot match that of artificial neural networks, thus failing to fully reveal the deep connections and key factors of traffic congestion. In the field of interpretability methods for neural networks, most research focuses on classification problems, while traffic prediction is a regression problem, resulting in limited interpretability studies. Most interpretability research methods for traffic prediction rely on attention mechanisms to explain the model, failing to leverage the advantages of graph neural network models in extracting spatial information from the road network, thus providing shallow explanations.
[0006] Therefore, there is an urgent need to design a technical solution that can overcome the above-mentioned defects. Summary of the Invention
[0007] This invention addresses the aforementioned problems by providing an analytical method for accurately predicting and interpreting traffic congestion. The invention employs the following technical solution:
[0008] This invention provides an interpretable spatiotemporal analysis method for traffic congestion prediction, characterized by the following steps:
[0009] Step S1: Pre-train the STGCN model to be explained;
[0010] Step S2, constructing a spatiotemporal interpretation generative model, which includes:
[0011] The pre-trained STGCN;
[0012] Two initial spatial masks are used to mask the edges of the input topology graph during the two spatial convolutions of the STGCN, thereby extracting the spatial preference of the STGCN when making predictions; and
[0013] An initial temporal mask is used to cover the historical velocity sequence features of each node in the input topology during training, thereby extracting the temporal preference of the STGCN when making predictions.
[0014] Step S3, training the spatiotemporal interpretation generation model, including:
[0015] The training data is input into the spatiotemporal interpretation generation model, which generates two spatial masks and multiple temporal masks based on the initial spatial mask and the initial temporal mask using a perturbation-based interpretation method, and obtains the gradient mapping of each of the spatial masks and each of the temporal masks using a gradient-based interpretation method.
[0016] Step S4: The spatiotemporal interpretation generation model combines the two spatial masks into a combined mask to separate second-order spatial relationships, and performs spectral clustering on multiple temporal masks to obtain an average temporal mask.
[0017] Step S5: Input the traffic data of the target area into the trained spatiotemporal interpretation generation model to obtain the prediction result, and use the combined mask, the average temporal mask, and the POI information of road nodes in the traffic data to extract key road congestion information from the spatiotemporal interpretation generation model.
[0018] The interpretable spatiotemporal analysis method for traffic congestion prediction provided by this invention may also have the following technical features: In step S2, the initial spatial mask is the same size as the adjacency matrix of the input topology graph, and is used to mask the edge weights of the adjacency matrix; the initial temporal mask is the same size as the node feature vector of the input topology graph, and is used to mask the input of each node; in step S3, the goal of the spatiotemporal interpretation generation model is to learn the spatial mask M and the temporal mask F such that:
[0019]
[0020] In the formula, Y represents the true value. G represents the prediction given by STGCN. S X represents the result of the topological adjacency matrix after being masked by the spatial mask M. S The result is the representation of features after being masked by a temporal mask F.
[0021] The interpretable spatiotemporal analysis method for traffic congestion prediction provided by this invention may also have the following technical features: the STGCN includes two spatial convolutional blocks; the spatiotemporal interpretation generation model trains two independent spatial masks, namely a first spatial mask and a second spatial mask, which are respectively applied to two convolution operations of the two spatial convolutional blocks; in step S3, for the first spatial convolutional block, a certain edge e1(v) on the corresponding first spatial mask... i ,v j The change value during training is:
[0022]
[0023] For the second spatial convolutional block, the corresponding edge e2(v) on the second spatial mask i ,v j The change value during training is:
[0024]
[0025] In the formula, N(v) i ) is node v i The neighboring nodes, N(v) j ) is node v j The neighboring nodes.
[0026] After training, the first spatial mask learns the weight information of edges with respect to second-order neighbor nodes, and the second spatial mask learns the weight information of edges with respect to first-order neighbor nodes. The convolutional weights between the second-order neighbor nodes are represented as follows:
[0027] e1(vi ,v j )·e(v j ,v k ).
[0028] The interpretable spatiotemporal analysis method for traffic congestion prediction provided by this invention may also have the following technical feature: in step S4, the matrix product of the first spatial mask and the second spatial mask is calculated to construct the combined mask.
[0029] M3 = M1 × M2
[0030] In the formula, M1 is the first spatial mask, and M2 is the second spatial mask.
[0031] The combined mask M3 contains edges that are not actually connected, representing the critical weights of the second-order neighbor nodes to each other.
[0032] The interpretable spatiotemporal analysis method for traffic congestion prediction provided by this invention may also have the following technical features: In step S3, during the training process of the spatiotemporal interpretation generation model, the gradient value of the spatial mask is recorded as the basis for the importance of the spatial mask weight, and the gradient value of the temporal mask is recorded as the basis for the importance of the temporal mask weight.
[0033] The interpretable spatiotemporal analysis method for traffic congestion prediction provided by this invention may also have the following technical features: in step S4, the similarity of each of the temporal masks is measured, and the multiple temporal masks are clustered using a spectral clustering method based on the similarity, thereby interpreting the temporal commonalities of various nodes in the input topology graph.
[0034] The interpretable spatiotemporal analysis method for traffic congestion prediction provided by this invention may also have the following technical features: in step S4, when calculating the similarity between the two temporal masks m1 and m2, an exponentially weighted moving average method is used, and the difference between the two temporal masks m1 and m2 at the first time slice is:
[0035] d[1]=|m1[1]-m2[1]|
[0036] The difference at the i-th time slice is:
[0037] d[i]=1.1*d[i-1]+|m1[i]-m2[i]|
[0038] The difference values of the two temporal masks m1 and m2 are obtained by iterative calculation using the above formula, and then the Gaussian kernel function is used to transform the difference values into similarity values.
[0039] Invention Function and Effect
[0040] According to the interpretable spatiotemporal analysis method for traffic congestion prediction of the present invention, the deep influencing factors and spatiotemporal relationships between roads are extracted through STGCN, which can reveal the key factors of traffic congestion. When the spatiotemporal interpretation generative model training ends, the accuracy of the STGCN model for traffic prediction also reaches its highest level, indirectly completing the validity verification of the interpretation results. By combining gradient-based and perturbation-based interpretation methods, multi-angle interpretations of the STGCN model can be obtained. Two independent spatial masks are used respectively in the two convolution operations of STGCN, that is, the step-by-step masking method is used to separate the first-order relationship and the second-order relationship between road network nodes, thereby reducing the interpretation granularity and improving the interpretation performance. Attached Figure Description
[0041] Figure 1 This is a flowchart of an interpretable spatiotemporal analysis method for traffic congestion prediction in an embodiment of the present invention;
[0042] Figure 2 This is a schematic diagram of the spatiotemporal interpretation and generation model based on STGCN in an embodiment of the present invention;
[0043] Figure 3 This is a schematic diagram of the STGCN model in an embodiment of the present invention;
[0044] Figure 4 This is a graph showing the decrease in loss of the STGCN training set in an embodiment of the present invention;
[0045] Figure 5 This is a graph showing the decrease in loss of the STGCN validation set in an embodiment of the present invention;
[0046] Figure 6 This is a graph showing the decrease in training set loss of the spatiotemporal interpretation generation model in this embodiment of the invention;
[0047] Figure 7 This is a graph showing the decrease in loss on the validation set of the spatiotemporal interpretation generation model in this embodiment of the invention.
[0048] Figure 8 This is the result image of edge filtering through the first spatial domain mask in an embodiment of the present invention;
[0049] Figure 9 This is the result image of edge filtering through the second spatial domain mask in an embodiment of the present invention;
[0050] Figure 10 This is the result image of filtering edges by combining masks in an embodiment of the present invention;
[0051] Figure 11 Is Figure 10 A diagram illustrating the focus area in the center;
[0052] Figure 12 This is the first spatial domain mask gradient mapping diagram in this embodiment of the invention;
[0053] Figure 13 This is the second spatial domain mask gradient mapping diagram in this embodiment of the invention;
[0054] Figure 14 This is the time-domain mask average plot in this embodiment of the invention;
[0055] Figure 15 These are schematic diagrams of various time-domain masks in embodiments of the present invention;
[0056] Figure 16 These are various temporal mask gradient mapping diagrams in the embodiments of the present invention;
[0057] Figure 17 This is a bar chart showing the statistics of POI information in this embodiment of the invention. Detailed Implementation
[0058] To make the technical means, creative features, objectives and effects of this invention easy to understand, the following describes in detail the interpretable spatiotemporal analysis method for traffic congestion prediction of this invention with reference to embodiments and accompanying drawings.
[0059] <Example>
[0060] Figure 1 This is a flowchart of the interpretable spatiotemporal analysis method for traffic congestion prediction in this embodiment.
[0061] like Figure 1 As shown, the interpretable spatiotemporal analysis method for traffic congestion prediction includes the following steps:
[0062] Step S1: Pre-train the STGCN model to be explained;
[0063] Step S2: Construct a spatiotemporal interpretation generative model based on the pre-trained STGCN;
[0064] Step S3: Train the spatiotemporal interpretation generation model using traffic data. The model learns to obtain two spatial masks and multiple temporal masks.
[0065] Step S4: The spatiotemporal interpretation generation model combines two spatial masks into a combined mask to separate second-order spatial relationships, and performs spectral clustering on multiple temporal masks to obtain an average temporal mask.
[0066] Step S5: Input traffic data of the target area into the spatiotemporal interpretation generation model to obtain prediction results, and extract key road congestion information from the spatiotemporal interpretation generation model using the combined mask, average temporal mask, and POI information of road nodes.
[0067] The following will explain each step in detail.
[0068] Step S1: Pre-train the STGCN model to be explained using traffic data.
[0069] STGCN's spatiotemporal convolution kernels can fully extract spatiotemporal information from traffic data and record it into its hidden layer parameters.
[0070] Figure 3 This is a schematic diagram of the STGCN model in this embodiment.
[0071] like Figure 3 As shown, STGCN mainly consists of three layers: two spatiotemporal convolutional blocks (ST-Conv Blocks) and one fully connected output layer. Each spatiotemporal convolutional block contains two temporally gated convolutional layers and an intermediate spatial graph convolutional layer. Residual connections are applied within each module (i.e., the spatiotemporal convolutional block). Spatiotemporal traffic data is processed uniformly by the spatiotemporal convolutional blocks to fully extract spatiotemporal features. Finally, the fully connected output layer integrates and synthesizes these features to generate the final prediction. The STGCN model uses the masked_mse loss function, which only calculates the difference between the predicted value of a node with a non-zero prediction result and its true value, and returns the overall average difference.
[0072] The spatial convolution process in STGCN is performed on the Laplacian matrix. Let the adjacency matrix be A, and the Laplacian matrix can be defined as: L = DA, where D is the degree matrix of A. In the STGCN model, the Laplacian matrix is standardized as: L = ID. -1 / 2 WD -1 / 2 Then, the matrix is orthogonally diagonalized to obtain an orthogonal matrix P and a diagonal matrix D, such that L = PDP. -1 =PDP T Where the column vectors of P are the eigenvectors u1,…,u of L. n The diagonal elements in D are the corresponding eigenvalues λ1,…,λ n .
[0073] According to the convolution theorem, the Fourier transform of a function convolution is the convolution of the Fourier transform of the function; that is, the convolution of the node feature f(t) and the convolution kernel h(t) is the inverse transform of their product of Fourier transforms.
[0074]
[0075] Extending the convolution theorem to graphs yields:
[0076]
[0077] structure for Where α is a parameter defined in the neural network, then:
[0078]
[0079] This construction of the convolution kernel allows the Laplacian matrix to complete the convolution operation without spectral decomposition. On the other hand, the convolution kernel has good spatial characteristics. The hyperparameter K indicates the receptive field of the convolution kernel, that is, each convolution operation will perform a weighted summation of the vectors of the K-order neighbors of the node.
[0080] To reduce the number of parameters and optimize the computational performance of the STGCN model, the Chebyshev polynomial approximation restricts the convolution kernel to a polynomial with respect to the Laplacian matrix L:
[0081]
[0082] In the formula, θ∈R k It is the polynomial coefficient matrix, and K is the size of the graph convolution kernel, which determines the maximum radius (receptive field) of the convolution at the central node. Using a k-th order Chebyshev polynomial T... k (·) Approximate representation of the eigenvalue matrix: L needs to be normalized because the domain of the Chebyshev polynomial is [-1, 1]. The normalization process is as follows: Since the Laplace matrix is a positive semi-definite matrix with non-negative eigenvalues, we can divide the Laplace matrix by its largest eigenvalue to scale it to [0, 1]. Then, multiplying by 2 and subtracting the identity matrix transforms it to [-1, 1], i.e.: Applying this to the convolution function yields:
[0083]
[0084] The recurrence relation for Chebyshev polynomials is: A Chebyshev polynomial approximation convolution kernel of a specified order can be calculated using a recursive formula, given a specified hyperparameter K. Therefore, by using the Chebyshev approximation, the number of parameters in the convolution kernel is reduced, complexity is lowered, and the performance of the STGCN model is improved.
[0085] Chebyshev polynomial approximation requires first normalizing the Laplace matrix, which necessitates using the largest eigenvalue of the Laplace matrix. The original model calculates all eigenvalues of the Laplace matrix, resulting in unnecessary computation. Below, we will introduce an optimized method using the power iteration method to directly obtain the approximate value of the largest eigenvalue. According to spectral theory, the Laplace matrix can always be spectrally decomposed. Assume a given Laplace matrix L has eigenvalues λ1,…,λ… n The corresponding feature vectors are u1,…,u n Where u1,…,u n This forms an orthogonal basis. Now, introducing any n-dimensional vector x, we can use an orthogonal basis u1,…,u n Express x as: x = α1u1 + α2u2 + ... + α n u n Then perform matrix multiplication:
[0086] Lx = Lα1u1 + Lα2u2 + … + Lα n u n =λ1α1u1+λ2α2u2+…+λ n α n u n
[0087] After iterating the above operations k times, we can obtain:
[0088]
[0089] Let λ m =max(λ1,…,λ) n If we transform the above equation, then it becomes as follows:
[0090]
[0091] When k→∞ In other words, when performing iterative multiplication of L on x, the result will converge to the direction of the eigenvector corresponding to the largest eigenvalue of L, at which point: This allows us to obtain the largest eigenvalue of L.
[0092] STGCN's spatiotemporal convolutional blocks contain a one-dimensional convolution operation that uses K... t A convolutional kernel of size K is added, followed by a gated linear unit (GLU) to provide nonlinearity. For each node in the topological graph, the spatiotemporal convolutional block reads K from the input elements. t For order neighbors, since no padding is added during the convolution process, each convolution will reduce the time series by K. t -1 length. Thus, the input to the temporal convolution of each node can be considered as a vector of length M and number of channels C.i Sequence: Y∈R M×C convolution kernel Map the input Y to a single output element [PQ] divides the result into two halves with the same number of channels. From this, we can obtain the representation of temporally gated convolution: Where P and Q are the inputs of GLU, the sigmoid gate σ(Q) controls which parts of the current state input P help to discover the compositional structure and dynamic differences in the time series, and the nonlinear gate also helps to utilize the inputs of stacked time layers and realize residual connections between stacked time-domain convolutional layers.
[0093] Step S2: Construct a spatiotemporal interpretation generative model based on the pre-trained STGCN.
[0094] Figure 2 This is a schematic diagram of the spatiotemporal interpretation generation model in this embodiment.
[0095] like Figure 2 As shown in this embodiment, the spatiotemporal interpretation generation model is built based on the pre-trained STGCN. Its core function is to generate a spatiotemporal mask. The spatiotemporal interpretation generation model includes a pre-trained STGCN, two learnable initial spatial masks, and one learnable initial temporal mask.
[0096] Since traffic data is spatiotemporal data, masks need to be built in both time and space.
[0097] In the spatial domain, the spatiotemporal interpretation generative model uses two spatial masks of the same size as the adjacency matrix of the input topology graph to mask the edge weights of the adjacency matrix, and applies them to the two spatiotemporal convolutional blocks of STGCN to extract the spatial preference given by STGCN in the prediction.
[0098] In the time domain, a time-domain mask of the same size as the node feature vector of the input topology is used to mask the input of each node in the input topology, and the temporal preference of STGCN for prediction is extracted.
[0099] Ultimately, key information about traffic congestion is obtained through airspace masks and time-domain masks.
[0100] The spatiotemporal interpretive generative model requires loading the pre-trained structure and input parameters of STGCN during initialization. Then, its parameters are initialized based on the STGCN pre-training results. Afterward, two learnable initial spatial masks and one learnable initial temporal mask are constructed. Both the initial spatial and temporal masks are initialized to 0, indicating that no features are selected. During the training process of the spatiotemporal interpretive generative model, the spatial and temporal masks are learned, and key features are extracted. The forward propagation and loss function of the spatiotemporal interpretive generative model both call the corresponding functions of STGCN. The storage of each mask and its gradient information is completed in the destructor function of the spatiotemporal interpretive generative model.
[0101] The spatiotemporal interpretation generative model learns a spatial mask on STGCN and masks the edges on its input topology graph, thereby identifying the graph patterns that have the greatest impact on STGCN; it also learns a temporal mask on STGCN and masks the historical velocity sequence features of each node in the input topology graph, thereby identifying the temporal patterns that have the greatest impact on STGCN.
[0102] Step S3: Train the spatiotemporal interpretation model using traffic data.
[0103] That is, the traffic data used for training is input into the spatiotemporal interpretation model for training. The spatiotemporal interpretation model generates two spatial masks and multiple temporal masks based on the initial spatial mask and the initial temporal mask using a perturbation-based interpretation method, and obtains the gradient mapping of each spatial mask and temporal mask using a gradient-based interpretation method.
[0104] For a node set V in a transportation network, the goal of the spatiotemporal interpretation generative model is to learn the spatial mask M and the temporal mask F, such that... Where Y represents the true value. G represents the prediction given by the STGCN neural network. S X represents the result of the topological adjacency matrix after M-masking. S The result after the representative features are masked by F.
[0105] In practical spatiotemporal interpretation and generation models, since the traffic network is an undirected graph, it is necessary to ensure that the spatial mask is a symmetric matrix. The solution is to calculate the average of the spatial mask and its transpose. Furthermore, it is desirable for the spatial mask to be binary in terms of feature selection, so a sigmoid activation function is added, ultimately processing the original spatial mask into a Sigmoid((M+M)) matrix. T) / 2) Then perform the Hadamard product with the adjacency matrix. Similarly, the time-domain mask also needs to be activated by the sigmoid function before masking the features of the input sequence.
[0106] The following focuses only on the data flow process of the spatial mask. Let a node be v, and its input feature be x. v N(v) represents the neighboring nodes of v. Since the receptive field set by spatial convolution only includes the first-order neighbors of a node, spatial convolution can be abstracted and summarized as:
[0107]
[0108] The input data, after passing through an STGCN neural network containing two spatiotemporal convolutional blocks, can be abstractly represented as:
[0109]
[0110] During the backpropagation of loss, a portion of the loss is backpropagated to e(v) through two spatiotemporal convolutional blocks. i ,v j The other part of the loss is propagated to e(v,v) through the second spatiotemporal convolution block. i Then for e(v) i ,v j During training, its change value is:
[0111]
[0112] This indicates that an edge in the final trained spatial mask not only represents its criticality to its two endpoints (first-order neighbors), but also its criticality to the neighbors of its two endpoints (second-order neighbors). Therefore, when analyzing the interpretation results, it is difficult to clearly identify the influencing factors of a particular edge on its nearby nodes, resulting in a coarse-grained spatial mask and poor interpretation specificity. To address this issue, a step-by-step masking solution is proposed.
[0113] Step-by-step masking refers to training two independent spatial masks, which are then applied separately in two convolution operations. This separates the weights of edges with respect to their first-order neighbors and their second-order neighbors, reducing granularity and improving interpretation performance. Using the notation defined above: for the spatial mask of the first spatial convolution block (denoted as the first spatial mask), a certain edge e1(v... i ,v j The change value during training is:
[0114]
[0115] For the spatial mask of the second spatial convolution block (denoted as the second spatial mask), there is an edge e2(v) on it. i ,v j The change value during training is:
[0116]
[0117] Therefore, the first spatial mask learns the weight information of the edges with respect to second-order neighbor nodes, and the second spatial mask learns the weight information of the edges with respect to first-order neighbor nodes.
[0118] Furthermore, the spatiotemporal interpretation generative model uses the gradient values of the mask during model training as the basis for determining the importance of mask weights. The basis for gradient mapping is that if the historical gradients of a certain parameter are relatively large, it indicates that changes in that parameter have a large perturbation to the prediction result, and correspondingly, that parameter is more important and thus has interpretive significance.
[0119] In step S4, the spatiotemporal interpretation generation model combines two spatial masks into a combined mask to separate second-order spatial relationships, and performs spectral clustering on multiple temporal masks to obtain an average temporal mask.
[0120] Regarding the spatial mask, as mentioned above, the first spatial mask learns the weight information of edges with respect to second-order neighbors, and the second spatial mask learns the weight information of edges with respect to first-order neighbors. However, for the first spatial mask, a certain edge e1(v) i ,v j ) may represent traffic information from v i Flow to v k ,k∈N(v j This approach doesn't provide an intuitive explanation of the final result, as it would be more preferable to use e(v). i ,v k ),k∈N(v j The weights for transmitting traffic information are directly represented by ) . Examining the convolution process, the first convolution will... i The information of the node is convolved into v j Above, the second convolution process further converts traffic information from v j Convolution to v k Therefore, we can use e1(v) i ,v j )·e(v j ,v k ) represents the convolution weights of information between second-order neighbors, while v i propagated to v kThe process may involve various intermediate nodes. Therefore, the matrix product of the two step-by-step masks can be calculated to construct a new combined mask: M3 = M1 × M2. M3 contains many edges that are not actually connected, representing the critical weights of second-order neighbors to each other.
[0121] For the temporal mask, after the spatiotemporal interpretation generative model is trained, the spatiotemporal interpretation generative model will learn a temporal mask for each node. In this embodiment, there are 4500 nodes in the entire road network topology map, so the size of the generated temporal mask is 4500×12, which is a huge matrix. It is difficult to effectively analyze the temporal mask. Therefore, we consider clustering the temporal mask and then analyzing it at different levels of different categories.
[0122] In the process of temporal mask clustering, the first step is to generate a similarity matrix for the temporal masks. Since the average vector of the temporal masks shows that the STGCN model generally prefers the most recent historical data, an exponentially weighted moving average method is used when calculating the similarity between two different temporal masks. The earlier the mask difference appears, the greater its weight, which can be expressed by the following formula:
[0123] Given two time-domain masks, m1 and m2, their difference at the first time slice is d[1] = |m1[1] - m2[1]|, and their difference at the i-th time slice is d[i] = 1.1 * d[i-1] + |m1[i] - m2[i]|. By iteratively calculating in this way, the difference between the two time-domain masks can be calculated. In order to obtain the similarity matrix, the difference value needs to be converted into a similarity value by using the Gaussian kernel function. After exponential weighted moving average, the time-domain masks with similar weights in the first few time slices will be prioritized to be classified into one class. Then, spectral clustering is performed on the similarity matrix. Spectral clustering is a graph-based clustering method. The algorithm calculates the eigenvalues and eigenvectors of the given similarity matrix and then selects the appropriate eigenvectors to cluster different data points.
[0124] Step S5: Input the traffic data of the target area into the trained spatiotemporal interpretation generation model to obtain the prediction result, and use the combined mask, average temporal mask, and POI information of road nodes in the traffic data to extract key information on road congestion from the prediction result.
[0125] In this embodiment, the above method was used to conduct experiments on the Shanghai traffic condition dataset. The data came from the Gaode Map Open Platform and the OSM (Open Street Map) open-source map platform. The Gaode Map Open Platform provided historical traffic condition data and POI information, while OSM provided geographic information about the Shanghai road network. After data collection, data cleaning was performed, including removing data with excessive missing values, stitching the traffic condition information of each road into a raster map, generating a traffic network topology map, and combining the historical traffic condition sequences with the traffic network topology map into a spatiotemporal data structure called SpatialMaps.
[0126] First, complete the pre-training of STGCN according to step S1, setting the batch size to 64, training 50 times, and the learning rate to 0.001. The loss descent curves on the training set, the loss descent curves on the validation set, and the training results during model training are shown below. Figure 4 , Figure 5 As shown in Table 1.
[0127] Table 1 STGCN Training Results
[0128]
[0129] Depend on Figure 4 The loss descent curve shows that the STGCN model's loss value on the training set decreases with increasing training iterations, and the descent curve plateaus after the 35th training iteration. Figure 5 It can be seen that the loss value of the STGCN model fluctuates greatly on the validation set, but generally shows a downward trend, converging to around 22 after the 35th training iteration. The final training results are shown in Table 1. The MSE for predicting the next two time slices is within 20, and the MSE for predicting the next five time slices is within 30, indicating good prediction results.
[0130] Then, following step S2, the spatiotemporal interpretation generative model is constructed. Next, following step S3, the parameters of STGCN are fixed and loaded into the spatiotemporal interpretation generative model for training. During training, the number of training iterations is set to 10, because more training iterations would cause the loss value to oscillate significantly and fail to converge. The loss descent curves on the training set, the loss descent curves on the validation set, and the training results during the training of the spatiotemporal interpretation generative model are shown below. Figure 6 , Figure 7 As shown in Table 2.
[0131] Table 2 Training Results of the Spatiotemporal Interpretation Generative Model
[0132]
[0133] Depend on Figure 6As can be seen from the loss descent curve, the loss descent curve of the spatiotemporal interpretation generative model on the training set tends to plateau after the third training iteration, meaning the loss value tends to stabilize. Figure 7 It can be seen that the loss reduction curve of the spatiotemporal interpretation generative model on the validation set tends to plateau after the 5th training iteration, with the loss value stabilizing at around 45. The final training results are shown in Table 2. The MSE of the spatiotemporal interpretation generative model for predicting the next two time slices is within 30, and the MSE for predicting the next five time slices is within 45, showing a significant decline compared to STGCN. This is because, without changing the STGCN parameters, the data after adding the mask cannot be consistent with the initial data. Therefore, the pre-trained parameters do not match the masked data, leading to a significant increase in the loss value of the spatiotemporal interpretation generative model. Although the overall performance of the model decreases after introducing STGCN into the interpretation generative model, fixing the STGCN parameters ensures that its model structure remains unchanged, preventing the interpretation information from being coupled into STGCN, thus making the interpretation results faithful to the original model. Therefore, the subsequent analysis is based on the training results of the spatiotemporal interpretation generative model with fixed STGCN parameters.
[0134] Next, we will analyze the airspace mask. Figure 8 The result graph is the one that filters out edges with a weight greater than 0.5 using the first spatial mask. Figure 9 This is the resulting graph after filtering edges with weights greater than 0.5 using the second spatial domain mask. From... Figure 8-9 It can be observed that the average weight extracted from the first spatial domain mask is smaller than that from the second spatial domain mask, and the number of edges with weights greater than 0.5 is also smaller. This indicates that STGCN pays more attention to the information from the second convolution process, because the second convolution process includes the aggregated information from the first convolution, thus obtaining the historical road conditions of second-order neighbor nodes. More information improves the prediction performance of STGCN.
[0135] Figure 10 This is the result graph that filters out edges with a weight greater than 0.4 by combining masks. Figure 11 Is Figure 10 A schematic diagram illustrating the clustered areas. From... Figure 10-11 It can be observed that high-weight road sections in the combined mask exhibit a small-scale clustering phenomenon, most notably in Xuhui District in the southwest of the city, Jing'an District in the city center, Lujiazui and Yangpu Districts along the middle reaches of the Huangpu River, and Jinqiao Town in Pudong and Sanlin Town in Punan. These road sections are either centrally located or in industrial economic zones, and these locations have a significant impact on surrounding traffic. Therefore, when addressing urban congestion, it is crucial to prioritize road sections within areas that function as urban sub-centers or where concentrated industrial production takes place, in order to prevent the congestion from radiating outwards.
[0136] Figure 12 and Figure 13 These are gradient mappings of two spatial masks; edges with gradient values greater than 0.1 were selected for plotting. From... Figure 12-13 It can be observed that the average gradient mapping of the first spatial domain mask is larger than that of the second spatial domain mask, and there are also more edges greater than 0.1. This indicates that the edges in the first convolution process have a greater impact on the accuracy of STGCN. The reason for this is that road condition information in the first convolution process can propagate to a wider range, thus the road segments have a greater influence in the first convolution. In addition, it can be seen that most of the road segments marked in the figure are short-distance roads rather than ring roads or expressways. This indicates that short-distance roads within the city have a greater capacity to disturb traffic than long-distance roads. This may be because the traffic conditions on short-distance roads are more complex and prone to congestion, and short-distance roads have more connection points, making congestion easier to propagate. Therefore, when studying urban congestion, attention should be paid to short-distance roads or roads with more connection points that have a greater impact on the surrounding environment.
[0137] Next, we will analyze the time-domain mask. Figure 14 This is the result of averaging the time-domain masks of all road segments; observe... Figure 14 It can be seen that, generally speaking, STGCN focuses more on recent historical data (time slices within the first 15 minutes) when making predictions for the current moment, especially the first time slice within the first 5-10 minutes. This indicates that the information from the first 5-10 minutes is the most relevant when predicting vehicle speed. Furthermore, STGCN also pays significant attention to data from the first 7-9 time slices. This reveals a periodicity in the propagation of road conditions: the first 0-2 time slices propagate the road conditions of first-order neighbors, while the first 7-9 time slices propagate the road conditions of second-order neighbors. Therefore, it can be inferred that the process of road conditions propagating from one road segment to the next takes approximately 35 minutes. Thus, the key timeframes for traffic congestion problems are the historical information from the first 10 minutes and the first 35 minutes, with the average propagation time of a congestion event on a road being 35 minutes.
[0138] Figure 15 This is a graph showing the average time-domain masks after clustering the time-domain masks into four categories. The number of time-domain masks contained in the four categories are 1270, 1157, 985, and 1087, respectively. This can be observed... Figure 15 It can be observed that in Category 0, the first two time slots have the largest weights, with an average of 67.6 congestion incidents on the road segments within this category; in Category 1, the weights of time slots from 1 to 7 are relatively large, with an average of 91.7 congestion incidents on the road segments within this category; in Category 2, the weights of all time slots are relatively small, with an average of 53.2 congestion incidents on the road segments within this category; and in Category 3, the weights of only the 0th time slot are relatively large, with an average of 61.4 congestion incidents on the road segments within this category. Figure 16This represents the average gradient mapping values for various time-domain masks. While the differences between these types are not significant, they exhibit a relatively consistent commonality: the intra-slice gradient mapping values are positive, close to 0, between the 0th and 6th time slices. However, after the 7th time slice, the gradient mapping values are generally negative, especially the gradient mapping values in the last time slice, which are significantly smaller. This indicates that changes in the data of the first few time slices have a smaller impact on the accuracy of the STGCN model, while the later time slices have a greater impact on the accuracy. This suggests that when studying key points of road congestion, it is important to focus on the historical road conditions within the first half hour. Information from more distant time slices should be used with caution, as overemphasizing historical data after half an hour may lead to misjudgments of key points of road congestion.
[0139] Then, the POI information for each type was analyzed, and the results are as follows: Figure 17 As shown, the average distribution of the above-mentioned average time-domain masks across various POIs is generally very small. This is because various facilities in a city are always evenly distributed, and it is impossible for there to be highly differentiated dedicated plots. However, meaningful information can still be interpreted from the relatively small differences: Category 0 nodes are prominent in catering, shopping, and accommodation services, and their traffic conditions are mainly affected by the historical data within the last 10 minutes. This indicates that the duration of the traffic condition impact on road segments with consumer-related POI information is short. Category 1 nodes are prominent in life services and businesses, and are the most prone to congestion. Their time-domain mask information shows that this type of road is sensitive to historical data from the previous 1 to 7 time slots, but less so to the 0th time slot. This may be because life services and businesses are prone to morning and evening rush hours, resulting in wider congestion areas and longer durations when congestion occurs, thus affecting traffic conditions. The longer duration of the impact leads STGCN to favor more distant historical information; the second type of nodes is prominent in catering services and government agencies and social groups, and is the type with the fewest congestion times. The time-domain mask indicates that the model generally does not favor past time slices, which may be because the road conditions in this type of road segment are generally stable, so it is not necessary to pay attention to too much information to predict the road conditions; the third type of nodes is prominent in shopping services and transportation facilities services. The time-domain mask indicates that the model pays more attention to the most recent time slice, especially the previous time slice. This indicates that the influence of road condition data in this type of road segment is not lasting and the road conditions change frequently. This is related to the well-developed road facilities and complex road conditions near shopping services and transportation facilities.
[0140] Functions and effects of the embodiments
[0141] According to the interpretable spatiotemporal analysis method for traffic congestion prediction provided in this embodiment, the STGCN extracts deep influencing factors and spatiotemporal relationships between roads, revealing key factors of traffic congestion. At the end of the training of the spatiotemporal interpretation generative model, the STGCN model's accuracy in traffic prediction also reaches its highest level, indirectly verifying the effectiveness of the interpretation results. By combining gradient-based and perturbation-based interpretation methods, multi-angle interpretations of the STGCN model can be obtained. Two independent spatial masks are used in the two convolution operations of STGCN, respectively, i.e., a step-by-step masking method is used to separate the first-order and second-order relationships between road network nodes, thereby reducing the interpretation granularity and improving interpretation performance.
[0142] Furthermore, during the training of the spatiotemporal interpretative generative model, the gradient values of the mask are recorded as the basis for the importance of the mask weights. If the historical gradients of a certain parameter are all large, it indicates that when the parameter changes, the perturbation to the prediction result is large. Accordingly, the parameter becomes more important and thus has interpretative significance.
[0143] Furthermore, the matrix product of the two spatial masks is calculated to construct a combined mask, which contains many edges that are not actually connected, representing the critical weights of second-order neighbor nodes to each other, thus making the interpretation of the transmission weights of traffic information more intuitive.
[0144] Furthermore, since the generative model will learn a time-domain mask for each node, and there are many nodes in the road network, the generated time-domain mask is a huge matrix. Therefore, the time-domain mask is spectral clustered and then analyzed at different levels of different categories, so that the time-domain mask can be effectively analyzed.
[0145] The above embodiments are only used to illustrate specific implementations of the present invention, and the present invention is not limited to the scope of the description of the above embodiments.
Claims
1. A congestion prediction oriented explainability spatio-temporal analysis method, characterized in that, Includes the following steps: Step S1: Pre-train the STGCN model to be explained; Step S2, constructing a spatiotemporal interpretation generative model, which includes: The pre-trained STGCN; Two initial spatial masks are used to mask the edges of the input topology graph during the two spatial convolutions of the STGCN, thereby extracting the spatial preference of the STGCN when making predictions; and An initial temporal mask is used to cover the historical velocity sequence features of each node in the input topology during training, thereby extracting the temporal preference of the STGCN when making predictions. Step S3, training the spatiotemporal interpretation generation model, including: The training data is input into the spatiotemporal interpretation generation model, which generates two spatial masks and multiple temporal masks based on the initial spatial mask and the initial temporal mask using a perturbation-based interpretation method, and obtains the gradient mapping of each of the spatial masks and each of the temporal masks using a gradient-based interpretation method. Step S4: The spatiotemporal interpretation generation model combines the two spatial masks into a combined mask to separate second-order spatial relationships, and performs spectral clustering on multiple temporal masks to obtain an average temporal mask. Step S5: Input the traffic data of the target area into the trained spatiotemporal interpretation generation model to obtain the prediction result, and extract key road congestion information from the spatiotemporal interpretation generation model using the combined mask, the average temporal mask, and the POI information of road nodes in the traffic data. The STGCN comprises two spatial convolutional blocks. The spatiotemporal interpretation generative model trains two independent spatial masks, namely a first spatial mask and a second spatial mask, which are respectively applied to the two convolutional operations of the two spatial convolutional blocks. In step S3, for the first spatial domain convolution block, a certain edge on the corresponding first spatial domain mask The change value in training is: For the second spatial convolutional block, there is a certain edge on the corresponding second spatial mask. The changes during training are: In the formula, For nodes The neighboring nodes, For nodes The neighboring nodes, After training, the first spatial mask learns the weight information of edges with respect to second-order neighbor nodes, and the second spatial mask learns the weight information of edges with respect to first-order neighbor nodes. The information convolution weights between the second-order neighbor nodes are represented as follows: , In step S4, the matrix product of the first spatial mask and the second spatial mask is calculated to construct the combined mask: In the formula, For the first spatial mask, This is the second spatial mask. The combined mask There are edges in the middle that are not actually connected, which represent the critical weights of the second-order neighbor nodes to each other.
2. The interpretable spatiotemporal analysis method for traffic congestion prediction according to claim 1, characterized in that: in, In step S2, the initial spatial mask is the same size as the adjacency matrix of the input topology graph, and is used to mask the edge weights of the adjacency matrix. The initial temporal mask is the same size as the node feature vector of the input topology graph, and is used to mask the input of each node. In step S3, the goal of the spatiotemporal interpretation generation model is to learn the spatial mask. and the temporal mask , so that: In the formula, Represents the true value. This represents the prediction given by STGCN. Represents the topological adjacency matrix after passing through a spatial mask. The result after covering Representative features are masked in the temporal domain. The result after covering it up.
3. The interpretable spatiotemporal analysis method for traffic congestion prediction according to claim 1, characterized in that: in, In step S3, during the training of the spatiotemporal interpretation generation model, the gradient value of the spatial mask is recorded as the basis for the importance of the spatial mask weight, and the gradient value of the temporal mask is recorded as the basis for the importance of the temporal mask weight.
4. The interpretable spatiotemporal analysis method for traffic congestion prediction according to claim 1, characterized in that: in, In step S4, the similarity of each of the temporal masks is measured, and the multiple temporal masks are clustered using a spectral clustering method based on the similarity, thereby interpreting the temporal commonalities of various nodes in the input topology graph.
5. The interpretable spatiotemporal analysis method for traffic congestion prediction according to claim 4, characterized in that: in, In step S4, the two temporal masks are calculated. and When determining the similarity between the two time-domain masks, an exponentially weighted moving average method is used. and The difference at the first time slice is: In the The differences at each time slice are: The two temporal masks are obtained through iterative calculation using the above formula. and The difference values are then converted into similarity values using a Gaussian kernel function.