Traffic information prediction method based on time graph convolutional network and attention mechanism
By adopting a traffic information prediction method based on a temporal graph convolutional neural network and an attention mechanism in the Internet of Vehicles system, the accuracy problem of existing methods in complex traffic environments is solved, and efficient traffic information prediction for urban road networks is achieved.
Patent Information
- Application Number
- CN202510779235.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-12
- Publication Date
- 2025-09-19
AI Technical Summary
Existing traffic information prediction methods are difficult to adapt to complex and changing traffic environments, have poor accuracy, cannot meet the needs of vehicle network applications, and ignore the temporal and spatial constraints of urban road networks on traffic information data.
A traffic information prediction method based on temporal graph convolutional neural network (TGCN) and attention mechanism is adopted. The missing values and outliers in the dataset are processed by the adjacency-similarity algorithm, the gated recurrent unit (GRU) and graph convolutional network (GCN) are combined to capture the spatiotemporal correlation of the data, and the attention mechanism is used to extract key information.
It improves the accuracy of traffic information prediction, enhances the model's adaptability, enables better analysis of complex graph structures, and achieves accurate prediction of future traffic information.
Smart Images

Figure CN120673588A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of intelligent transportation technology, and specifically relates to a traffic information prediction method based on a temporal graph convolutional network and an attention mechanism applied to Internet of Vehicles (IoV) scenarios. Background Art
[0002] The Internet of Vehicles (IoV) is an intelligent transportation system based on the internet and sensor technology. It enables data transmission and information exchange between vehicles (V2V) and between vehicles and infrastructure (V2I) by acquiring relevant information about vehicles, roads, and their surroundings. With the continuous development of IoV technology, the requirements for the real-time and accurate traffic information are also increasing. However, traditional traffic information prediction methods (such as historical averaging) are difficult to adapt to today's complex and changing traffic environment, and their accuracy is poor, which cannot meet the needs of IoV applications. Deep learning technology, as a powerful feature learning and data processing tool, can capture correlations and dependencies between data from massive historical data and has significant advantages in processing complex and large-scale data. Therefore, deep learning technology can be applied to IoV systems to achieve real-time traffic information prediction.
[0003] Existing traffic information prediction models can be divided into parametric models and non-parametric models. Parametric models assume that the data follows a known distribution and that the distribution has a set of unknown parameters. By fitting the observed data, the values of these unknown parameters can be determined. Non-parametric models directly model the data without making any assumptions about the distribution of the data. This type of model can be used to handle complex nonlinear relationships. Common parametric models include linear regression models, logistic regression models, time series models, etc., which are suitable for situations with low complexity and small data volumes. Common non-parametric models include decision trees, support vector machines, neural network models, etc. Compared with parametric models, they can handle complex data patterns more flexibly and can still achieve good prediction results when prior information is unknown.
[0004] In recent years, with the rapid development of deep learning technology, neural network models have gradually attracted the attention of researchers. However, many models only consider the temporal characteristics of the data and ignore the constraints of the urban road network on traffic information data, resulting in inaccurate prediction results. In order to make full use of the spatiotemporal correlation of data, the present invention proposes a traffic information prediction model based on a time-graph convolutional neural network (TGCN) and an attention mechanism. TGCN is composed of a gated recurrent unit (GRU) and a graph convolutional network (GCN), which can propagate and update information in both time and space dimensions; the attention mechanism can more accurately capture the key information in the graph data, thereby improving the model's expressive power and prediction performance. Summary of the Invention
[0005] The purpose of this invention is to provide a traffic information prediction method based on a temporal graph convolutional network and an attention mechanism, which can more accurately predict vehicle traffic information under the constraints of road network structure.
[0006] The technical solutions adopted by the present invention are as follows:
[0007] The traffic information prediction method based on the temporal graph convolutional network and attention mechanism includes the following steps:
[0008] S1: Dataset acquisition and preprocessing;
[0009] S101: Acquire a data set recording a user's historical traffic information data and a data set recording road connectivity relationships;
[0010] S102: Using the adjacency-similarity algorithm to supplement or correct missing values and outliers in the data set; specifically, the following steps are included:
[0011] Step 1021: Use the interquartile range method to calculate the upper quartile Q3 and the lower quartile Q1 to define the outlier range: [Q1-1.5×IQR, Q3+1.5×IQR]. Points outside this range are considered outliers; identified outliers are marked as missing values, forming data gaps;
[0012] Step 1022: Calculate the similarity between samples and replace the missing value with the mean or median of the K points closest to the missing value.
[0013] Traffic information data from connected vehicle users is highly periodic and self-similar, resulting in a certain degree of temporal correlation. Furthermore, due to the constraints of the road network structure, this data also exhibits a certain degree of spatial correlation. Urban roads generally have complex topological structures, which, to a certain extent, determine vehicle driving characteristics, including speed and direction. Therefore, to predict a user's traffic information data for a period of time in the future, it is necessary not only to obtain a dataset that records the user's historical traffic information data, but also a dataset that records road connectivity. For missing values and outliers in the dataset, this paper designs an adjacency-similarity algorithm to supplement or correct them to ensure the integrity and correctness of the dataset.
[0014] S2: Build the TGCN-AT neural network model;
[0015] A neural network model based on the temporal graph convolutional neural network (TGCN) and the attention mechanism (AT) is designed to capture the spatiotemporal correlation between data in the dataset. The temporal graph convolutional neural network (TGCN) consists of a gated recurrent unit (GRU) and a graph convolutional network (GCN). The gated recurrent unit (GRU) is used to capture the temporal dependency of data in the dataset, while the gated recurrent unit (GRU) and the graph convolutional network (GCN) are used to capture the spatial dependency of data in the dataset. The attention mechanism is used to extract key information from the input data.
[0016] In step 2, the gated recurrent unit (GRU) dynamically adjusts historical and current information by updating the gate and resetting the gate, gradually transfers the hidden state, and automatically extracts time-dependent patterns from the sequence data; ultimately, the time dependency of the data in the dataset is captured.
[0017] In step 2, the graph convolutional network GCN captures the spatial dependencies between nodes and their neighbors through the adjacency matrix of the graph structure, and uses the graph convolution layer to gradually propagate and update node features to learn the spatial dependencies of data in the node or graph representation dataset.
[0018] In step 2, the attention mechanism dynamically assigns higher weights to key information by calculating the relative importance of input features, helping the model focus on more important parts; and ultimately extracting key information from the input data.
[0019] This model can not only effectively process long-term time series data, but also better analyze complex graph structures. In addition, the addition of the attention mechanism enhances the model's focus on important nodes and edges, enabling it to more accurately capture key information in the graph data, thereby improving the model's expressiveness and predictive performance.
[0020] S3: Train the TGCN-AT neural network model and save the trained TGCN-AT neural network model parameters for subsequent prediction;
[0021] Described step 3 comprises the following specific steps:
[0022] S301: First, the preprocessed dataset is divided into training and test sets, and then the loss function, optimizer, number of hidden units, learning rate, batch size, and number of training times are selected to balance the complexity and generalization ability of the model;
[0023] S302: During the training process, the TGCN-AT neural network model dynamically adjusts the weights of each node and edge through the attention mechanism, focusing on the features that significantly affect the prediction results, and improving the model's ability to capture the spatiotemporal dependencies between data; after training is completed, the TGCN-AT neural network model parameters are saved for subsequent predictions.
[0024] S4: Use the TGCN-AT neural network model to predict traffic information and evaluate the performance of the TGCN-AT neural network model based on the prediction results;
[0025] In step 4, the data in the test set is input into the trained TGCN-AT neural network model to predict traffic information data for a period of time in the future. Based on the prediction results, the prediction performance of the model is evaluated using the root mean square error and mean absolute error indicators, and the evaluated TGCN-AT neural network model is output.
[0026] The root mean square error RMSE in step 4 is:
[0027]
[0028] Mean Absolute Error (MAE):
[0029]
[0030] Accuracy:
[0031]
[0032] Where M and N are the number of time samples and the number of roads respectively; y ij and are the actual value and predicted value of the vehicle speed at the jth time node on the i-th road; Y and Represents y ij and The smaller the RMSE and MAE, the smaller the difference between the predicted value and the true value, the higher the prediction accuracy of the model, and the better the prediction performance of the neural network.
[0033] S5: Use the evaluated TGCN-AT neural network model output in step 4 to perform predictive analysis on real-time traffic information.
[0034] The technical effects achieved by the present invention are:
[0035] The present invention discloses a traffic information prediction method based on a time-graph convolutional neural network (TGCN) and an attention mechanism in a vehicle network system. The method can effectively capture the spatiotemporal dependency of historical traffic data, enhance the adaptability of the prediction model, and thus improve the prediction accuracy of the model. The innovation of this technical solution is mainly reflected in the following two aspects: First, when performing data preprocessing, an adjacency-similarity algorithm is designed to process missing values and outliers in the data set based on the topological structure of the urban road network; secondly, when constructing a traffic information prediction model, a gated recurrent unit (GRU) and a graph convolutional network (GCN) are used to capture the temporal correlation and spatial correlation of the data. In addition, an attention mechanism is added to the model to extract key information from the input data, so that the model can better analyze complex graph structures. Through the above method, this solution can predict traffic information data for a period of time in the future based on historical data, providing assistance for research in fields such as intelligent transportation. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Figure 1 It is a schematic diagram of the urban road network model of the present invention;
[0037] Figure 2 Schematic diagram of the basic structure of the gated recurrent unit GRU of the present invention;
[0038] Figure 3 This is a schematic diagram of the basic structure of the graph convolutional network GCN of the present invention;
[0039] Figure 4 This is a schematic diagram of the basic structure of the TGCN-AT neural network model based on the temporal graph convolutional network and attention mechanism of the present invention;
[0040] Figure 5 This is a comparison chart of the prediction results of the TGCN-AT neural network model of the present invention and the TGCN and GRU models;
[0041] Figure 6 It is a graph showing the change in loss function value of the TGCN-AT neural network model and the TGCN and GRU models during training;
[0042] Figure 7This is a graph showing the RMSE changes of the TGCN-AT model, TGCN, and GRU models during training.
[0043] Figure 8 This is a curve diagram of the prediction accuracy change of the TGCN-AT model of the present invention and the TGCN and GRU models during the training process. DETAILED DESCRIPTION
[0044] In order to make the purpose and advantages of the present invention more clearly understood, the present invention is described in detail below with reference to the following examples. It should be understood that the following text is only used to describe one or more specific embodiments of the present invention and does not strictly limit the scope of protection of the present invention.
[0045] This patent provides a traffic information prediction method based on a temporal graph convolutional network and an attention mechanism. This method uses GRU and GCN to capture temporal and spatial correlations between data, while using the attention mechanism to enhance the model's expressiveness, enabling more accurate prediction of traffic information data for vehicles in connected vehicle systems.
[0046] Applicable scenarios:
[0047] The present invention is applicable to urban road networks, such as Figure 1 As shown. Based on the viewpoint of graph theory, the urban road structure is modeled. Roads can be regarded as nodes in the network, and the connection relationship between roads can be represented as edges. In this way, the topological structure of the urban road network can be described in the form of a graph. The present invention uses the graph G = (N s ,E s ) to represent the road network within a certain area, where N s is a node set, E s is an edge set. On this basis, define two matrices A=[a ij ] N×N and X = [x ij ] T×N To describe the characteristics of the road network. Here, N is the total number of nodes, that is, the number of roads in the area; T is the total time length. The matrix A is called the adjacency matrix of the graph G, which is used to represent the connectivity between the roads in the area. The element a in the matrix A is ij is binary and is defined as follows:
[0048]
[0049] The matrix X is called the characteristic matrix of graph G, which is used to represent the traffic information on each road at different times.
[0050] The traffic information prediction method based on the temporal graph convolutional network and attention mechanism includes the following specific steps:
[0051] like Figure 1 As shown, S1: Dataset acquisition and preprocessing;
[0052] S101: Obtain a data set that records the user's historical traffic information data and a data set that records road connectivity relationships; Step S101 is actually used. Figure 1 In the scenario shown, to more accurately predict a user's traffic information, it's necessary to simultaneously obtain a dataset that records road connectivity and a dataset that records the user's historical traffic information. However, when compiling historical data, sensor damage or other human factors may result in missing values and outliers. Mathematical methods are then used to supplement or correct these missing values to ensure the integrity and accuracy of the dataset.
[0053] S102: Using the adjacency-similarity algorithm to supplement or correct missing values and outliers in the data set; specifically, the following steps are included:
[0054] Step 1021: Use the interquartile range method to calculate the upper quartile Q3 and the lower quartile Q1 to define the outlier range: [Q1-1.5×IQR, Q3+1.5×IQR]. Points outside this range are considered outliers; identified outliers are marked as missing values, forming data gaps;
[0055] Step 1022: Calculate the similarity between samples and replace the missing value with the mean or median of the K points closest to the missing value.
[0056] The present invention designs an adjacency-similarity algorithm to handle missing values and outliers in a data set.
[0057] Taking the vehicle's speed as an example, consider a Figure 1 The urban road network shown in Figure 1 shows roads with historical data, where light circles represent roads with historical data, and dark circles represent roads without historical data. Because roads are interconnected, the speed of vehicles on Road A is affected by the speeds of vehicles on its connected roads. Using the adjacency-similarity algorithm, the speed of vehicles on Road A can be estimated using the speeds of vehicles on Roads B, C, D, E, F, and G.
[0058] exist Figure 1 In the figure, the missing value is the vehicle speed on road A from west to east. According to the road network structure described in the figure, vehicles traveling on road A in this direction may come from roads B, C, and D, and may also be heading towards roads E, F, and G. Therefore, the entry speed v is defined as in is the average of the vehicle speeds in the three directions of road B from north to south, road C from west to east, and road D from south to north; similarly, the exit speed v is defined outIt is the average of the vehicle speeds in the three directions of road E from south to north, road F from west to east, and road G from north to south. in and v out The calculation formula is as follows:
[0059]
[0060] Where, represents the speed of the vehicle traveling in the direction of dir on road i. in and v out Taking the average, we can get the estimated value of the vehicle speed on road A from west to east:
[0061]
[0062] The actual urban road network structure may be much larger than Figure 5 The structure described in is complex, but the adjacency-similarity algorithm is still applicable. Similarly, suppose that a vehicle traveling from west to east on road A may come from m different roads and may also go to n different roads. Let M and N represent the set of m roads and n roads respectively. Then the estimated speed of the vehicle traveling from west to east on road A is
[0063]
[0064] In the present invention, the traffic information data of users in the Internet of Vehicles (IoV) has strong periodicity and self-similarity, and therefore has a certain degree of temporal correlation. At the same time, due to the constraints of the road network structure, this data also has a certain degree of spatial correlation. Urban roads generally have complex topological structures, which to a certain extent determine the driving characteristics of vehicles, including speed and direction. Therefore, in order to predict the user's traffic information data for a period of time in the future, it is necessary not only to obtain a dataset that records the user's historical traffic information data, but also a dataset that records the road connectivity relationships. For missing values and outliers in the dataset, the present invention designs an adjacency-similarity algorithm to supplement or correct them to ensure the integrity and correctness of the dataset.
[0065] S2: Build the TGCN-AT neural network model;
[0066] A neural network model based on the temporal graph convolutional neural network (TGCN) and the attention mechanism (AT) is designed to capture the spatiotemporal correlation between data in the dataset. The temporal graph convolutional neural network (TGCN) consists of a gated recurrent unit (GRU) and a graph convolutional network (GCN). The gated recurrent unit (GRU) is used to capture the temporal dependency of data in the dataset, while the gated recurrent unit (GRU) and the graph convolutional network (GCN) are used to capture the spatial dependency of data in the dataset. The attention mechanism is used to extract key information from the input data.
[0067] In step 2, the gated recurrent unit (GRU) dynamically adjusts historical and current information by updating the gate and resetting the gate, gradually transfers the hidden state, and automatically extracts time-dependent patterns from the sequence data; ultimately, the time dependency of the data in the dataset is captured.
[0068] In step 2, the graph convolutional network GCN captures the spatial dependencies between nodes and their neighbors through the adjacency matrix of the graph structure, and uses the graph convolution layer to gradually propagate and update node features to learn the spatial dependencies of data in the node or graph representation dataset.
[0069] In step 2, the attention mechanism dynamically assigns higher weights to key information by calculating the relative importance of input features, helping the model focus on more important parts; and ultimately extracting key information from the input data.
[0070] In actual use of step S2 of the present invention, the recurrent neural network (RNN) can effectively capture the long-term dependencies in time series data. GRU is a common RNN variant for processing sequence data. Compared with the standard RNN, GRU introduces the concepts of update gate and reset gate. These gating mechanisms enable GRU to more effectively process the long-term dependencies between data and alleviate the problems of gradient disappearance and gradient explosion. The basic structure of the GRU unit is as follows: Figure 2 shown.
[0071] Assume the current time step is t and the input is x t , the hidden state of the previous time step is h t-1 , the hidden state of the current time step is h t , then the calculation formulas for GRU's update gate, reset gate, candidate memory, and hidden state of the current time step are:
[0072] z t =σ(W z ·[h t-1 ,x t ]+b z ) (6)
[0073] r t =σ(W r ·[h t-1 ,x t ]+b r ) (7)
[0074]
[0075] Where σ represents the sigmoid activation function, tanh represents the hyperbolic tangent activation function, ⊙ represents the element-by-element multiplication of the vector, W and b are the weight matrix and bias vector, respectively.
[0076] GRU can effectively process temporally dependent sequence data and can therefore be used for traffic information prediction. In addition to GRU, Long Short-Term Memory (LSTM) networks also have the ability to capture long-term dependencies between data. However, LSTMs have more network parameters, a more complex structure, and offer only modest performance improvements compared to GRUs. Therefore, this paper uses GRU to capture temporal dependencies between data.
[0077] In the Internet of Vehicles, the road structure will determine the traffic information of the vehicle to a certain extent. Therefore, correctly capturing and utilizing network spatial features is also particularly important for traffic information prediction. The traditional convolutional neural network can effectively capture spatial dependencies when processing two-dimensional data (such as images). However, its ability only exists in Euclidean space. For urban road networks with complex topological structures, it is necessary to use GCN that can process arbitrary graph structure data to obtain spatial dependencies between data; the basic structure of GCN is as follows: Figure 3 shown.
[0078] The propagation rule for each convolutional layer in GCN is:
[0079]
[0080] Where, To increase the adjacency matrix of self-loops, for The degree matrix of .
[0081] GCN can effectively capture the spatial dependency of data, and the output H of GCN at the tth time step t By inputting this information into the GRU, information can be propagated and updated in both time and space. This type of neural network is called a Time-Graph Convolutional Network (TGCN).
[0082] In deep learning, attention mechanisms are often used to extract key information from input data. The attention mechanism allows neural network models to dynamically assign weights when processing structured data, and different weights represent different levels of importance. Therefore, this mechanism can consciously focus on certain important data while ignoring other unimportant components. Adding the attention mechanism to the TGCN model can enhance the model's attention to important nodes and edges, thereby more accurately capturing key information in graph data, better analyzing complex graph structures, and thus improving the model's expressive power and predictive performance. The TGCN model based on the attention mechanism, hereinafter referred to as the TGCN-AT model, has the following basic structure: Figure 4 shown.
[0083] The output expression of the TGCN-AT model at the tth time step is:
[0084]
[0085] Where, α k is the attention weight of the kth time step, which is calculated by the attention mechanism. The calculation method used in this invention is the dot product attention calculation method:
[0086] α k =softmax(H k ·H t ) (12)
[0087] This model can not only effectively process long-term time series data, but also better analyze complex graph structures. In addition, the addition of the attention mechanism enhances the model's focus on important nodes and edges, enabling it to more accurately capture key information in the graph data, thereby improving the model's expressiveness and predictive performance.
[0088] S3: Train the TGCN-AT neural network model and save the trained TGCN-AT neural network model parameters for subsequent prediction;
[0089] Described step 3 comprises the following specific steps:
[0090] S301: First, the preprocessed dataset is divided into training and test sets, and then the loss function, optimizer, number of hidden units, learning rate, batch size, and number of training times are selected to balance the complexity and generalization ability of the model;
[0091] S302: During the training process, the TGCN-AT neural network model dynamically adjusts the weights of each node and edge through the attention mechanism, focusing on the features that significantly affect the prediction results, and improving the model's ability to capture the spatiotemporal dependencies between data; after training is completed, the TGCN-AT neural network model parameters are saved for subsequent predictions.
[0092] S4: Use the TGCN-AT neural network model to predict traffic information and evaluate the performance of the TGCN-AT neural network model based on the prediction results;
[0093] In step 4, the data in the test set is input into the trained TGCN-AT neural network model to predict traffic information data for a period of time in the future. Based on the prediction results, the prediction performance of the model is evaluated using the root mean square error and mean absolute error indicators, and the evaluated TGCN-AT neural network model is output.
[0094] The root mean square error RMSE in step 4 is:
[0095]
[0096] Mean Absolute Error (MAE):
[0097]
[0098] Accuracy:
[0099]
[0100] Where M and N are the number of time samples and the number of roads respectively; y ij and are the actual value and predicted value of the vehicle speed at the jth time node on the i-th road; Y and Represents y ij and The smaller the RMSE and MAE, the smaller the difference between the predicted value and the true value, the higher the prediction accuracy of the model, and the better the prediction performance of the neural network.
[0101] The present invention is in practical examples:
[0102] We used a real-world dataset to train and test TGCN-AT, TGCN, and GRU models, comparing their performance. The dataset records vehicle speeds on 156 main roads in Luohu District, Shenzhen, over a period of 15 minutes. The adjacency matrix in the dataset is 156×156, representing the connectivity between roads; the feature matrix is 2976×156, meaning it records data for a total of 31 days.
[0103] In the experiment, the vehicle speeds in the dataset were first normalized to the range [0, 1]. The first 80% of the data was then used to train the model, and the last 20% was used to test the model's predictive performance. The hyperparameters of the TGCN-AT neural network model primarily include the learning rate, batch size, number of training epochs, and number of hidden units. Based on historical experience, the learning rate was set to 0.001 and the number of training epochs was set to 1000. Considering the memory limitations of the hardware device and the generalization ability of the model, the batch size was set to 32. Too few hidden units may result in the model failing to capture the complex patterns and structure in the data, while too many may cause the model to overfit the training data and fail to generalize to other samples. Therefore, taking these factors into consideration, the number of hidden units was set to 100.
[0104] During model training, the optimization goal is to minimize the error between the predicted value and the true value. The loss function can be set as:
[0105]
[0106] Where, Y and are the true value and predicted value of vehicle speed, L reg is the L2 regularization term, and its mathematical expression is:
[0107]
[0108] Where, ω i is the model's weight parameter, and λ is a hyperparameter used to control the strength of regularization. L2 regularization penalizes the sum of squared weights to keep model parameters small, effectively preventing overfitting, improving the model's generalization ability, and optimizing the training process.
[0109] Figure 5 The prediction results of the TGCN-AT, TGCN, and GRU models are shown. It can be seen that because the GRU does not consider the spatial dependencies of the data, its prediction error is larger than that of the TGCN and TGCN-AT. Overall, the TGCN-AT achieves better prediction results than the GRU and TGCN. This is because the TGCN-AT improves the model's ability to capture global features by introducing an attention mechanism.
[0110] Figure 6The data shows how the loss function values of three neural network models change during training. The GRU's relatively simple structure makes it easier to train and optimize, resulting in a smaller loss function value early in training and maintaining a stable value as training progresses. The loss function values of both TGCN and TGCN-AT show a trend of decreasing first and then stabilizing. The difference between the two is that TGCN-AT converges faster. This is because the attention mechanism helps the model better capture important features of the input data while reducing the burden of processing redundant data. Furthermore, the attention mechanism dynamically adjusts attention weights to adapt to varying input data, making the model more adaptable. When trained sufficiently many times, the loss function value of the TGCN-AT neural network model is significantly smaller than that of the GRU and TGCN neural network models. This also demonstrates that the TGCN-AT neural network model better fits the training data, resulting in better prediction performance.
[0111] Figure 7 The following figure shows the evolution of the RMSE of the three neural network models during training. It can be seen that the RMSE of the GRU is the smallest at the beginning of training. This is because it has fewer network parameters, the simplest network structure, and can only capture the temporal correlation of the data. In contrast, the TGCN and TGCN-AT, which include graph convolutional layers and model spatial features, have relatively complex structures, resulting in larger RMSEs at the beginning of training. As training progresses, the RMSE of TGCN and TGCN-AT gradually decreases and eventually stabilizes. In this stable state, TGCN-AT has the smallest RMSE, followed by TGCN, and GRU has the largest. This demonstrates that accounting for spatial dependencies in data can improve the predictive performance of neural network models. Furthermore, because TGCN-AT incorporates an attention mechanism, it can more effectively capture key information in graph data, resulting in smaller prediction errors. The dataset was preprocessed before model training, and there were no outliers or abnormal values in the training set. Therefore, the MAE and RMSE generally follow the same trend. Only one of these is selected for analysis here.
[0112] Figure 8 The following figure shows the evolution of the prediction accuracy of the three neural networks during training. The prediction accuracy of TGCN and TGCN-AT gradually increases as training progresses, eventually surpassing that of GRU and reaching a stable value, which is consistent with the results of the previous error analysis. Figure 8 It still shows that considering spatiotemporal dependencies is very important for traffic information prediction. At the same time, the introduction of the attention mechanism can further reduce the prediction error of the model and improve the prediction accuracy of the model.
[0113] The present invention discloses a traffic information prediction method based on a time-graph convolutional neural network (TGCN) and an attention mechanism in a vehicle network system. The method can effectively capture the spatiotemporal dependency of historical traffic data, enhance the adaptability of the prediction model, and thus improve the prediction accuracy of the model. The innovation of this technical solution is mainly reflected in the following two aspects: First, when performing data preprocessing, an adjacency-similarity algorithm is designed to process missing values and outliers in the data set based on the topological structure of the urban road network; secondly, when constructing a traffic information prediction model, a gated recurrent unit (GRU) and a graph convolutional network (GCN) are used to capture the temporal correlation and spatial correlation of the data. In addition, an attention mechanism is added to the model to extract key information from the input data, so that the model can better analyze complex graph structures. Through the above method, this solution can predict traffic information data for a period of time in the future based on historical data, providing assistance for research in fields such as intelligent transportation.
[0114] The above simulation results demonstrate the effectiveness and feasibility of the traffic information prediction method based on temporal graph convolutional network and attention mechanism proposed in this invention, indicating that the proposed scheme has broad application prospects in the field of traffic information prediction.
[0115] The foregoing is merely a preferred embodiment of the present invention. It should be noted that those skilled in the art may make various improvements and modifications without departing from the principles of the present invention, and such improvements and modifications are also within the scope of protection of the present invention. Structures, devices, and operating methods not specifically described or explained herein shall, unless otherwise specified or limited, be implemented in accordance with conventional means in the art.
Claims
1. Traffic information prediction method based on temporal graph convolutional network and attention mechanism, characterized by: The following steps are involved: S1: Dataset acquisition and preprocessing; S101: Acquire a data set recording a user's historical traffic information data and a data set recording road connectivity relationships; S102: Adopting the neighbor-similarity algorithm to supplement or correct missing values and outliers in the data set; S2: Build the TGCN-AT neural network model; A neural network model based on the temporal graph convolutional neural network (TGCN) and the attention mechanism (AT) is designed to capture the spatiotemporal correlation between data in the dataset. The temporal graph convolutional neural network (TGCN) consists of a gated recurrent unit (GRU) and a graph convolutional network (GCN). The gated recurrent unit (GRU) is used to capture the temporal dependency of data in the dataset, while the gated recurrent unit (GRU) and the graph convolutional network (GCN) are used to capture the spatial dependency of data in the dataset. The attention mechanism is used to extract key information from the input data. S3: Train the TGCN-AT neural network model and save the trained TGCN-AT neural network model parameters for subsequent prediction; S4: Use the TGCN-AT neural network model to predict traffic information and evaluate the performance of the TGCN-AT neural network model based on the prediction results; S5: Use the evaluated TGCN-AT neural network model output in step 4 to perform predictive analysis on real-time traffic information.
2. The traffic information prediction method based on a temporal graph convolutional network and an attention mechanism according to claim 1, characterized in that: The adjacency-similarity algorithm is used to supplement or correct the step 1, including the following specific steps: Step 1021: Use the interquartile range method to calculate the upper quartile Q3 and the lower quartile Q1 to define the outlier range: [Q1-1.5×IQR, Q3+1.5×IQR]. Points outside this range are considered outliers; identified outliers are marked as missing values, forming data gaps; Step 1022: Calculate the similarity between samples and replace the missing value with the mean or median of the K points closest to the missing value.
3. The traffic information prediction method based on a temporal graph convolutional network and an attention mechanism according to claim 2, characterized in that: In step 2, the gated recurrent unit (GRU) dynamically adjusts historical and current information by updating the gate and resetting the gate, gradually transfers the hidden state, and automatically extracts time-dependent patterns from the sequence data; ultimately, the time dependency of the data in the dataset is captured.
4. The traffic information prediction method based on a temporal graph convolutional network and an attention mechanism according to claim 3 is characterized by: In step 2, the graph convolutional network GCN captures the spatial dependencies between nodes and their neighbors through the adjacency matrix of the graph structure, and uses the graph convolution layer to gradually propagate and update node features to learn the spatial dependencies of data in the node or graph representation dataset.
5. The traffic information prediction method based on a temporal graph convolutional network and an attention mechanism according to claim 4, characterized in that: In step 2, the attention mechanism calculates the relative importance of input features and dynamically assigns weights to key information, helping the model focus on important parts; ultimately, it extracts key information from the input data.
6. The traffic information prediction method based on a temporal graph convolutional network and an attention mechanism according to claim 5, characterized in that: Described step 3 comprises the following specific steps: S301: First, the preprocessed dataset is divided into training and test sets, and then the loss function, optimizer, number of hidden units, learning rate, batch size, and number of training times are selected to balance the complexity and generalization ability of the model; S302: During training, the TGCN-AT neural network model dynamically adjusts the weights of each node and edge through the attention mechanism, focusing on features that significantly influence the prediction results, improving the model's ability to capture the spatiotemporal dependencies between data. After training is completed, the TGCN-AT neural network model parameters are saved for subsequent predictions.
7. The traffic information prediction method based on a temporal graph convolutional network and an attention mechanism according to claim 6, characterized in that: In step 4, the data in the test set is input into the trained TGCN-AT neural network model to predict traffic information data for a period of time in the future. Based on the prediction results, the prediction performance of the model is evaluated using the root mean square error and mean absolute error indicators, and the evaluated TGCN-AT neural network model is output.
8. The traffic information prediction method based on a temporal graph convolutional network and an attention mechanism according to claim 7, characterized in that: The root mean square error RMSE in step 4 is: Mean Absolute Error (MAE): Accuracy: Where M and N are the number of time samples and the number of roads respectively; y ij and are the actual value and predicted value of the vehicle speed at the jth time node on the i-th road; Y and Represents y ij and The smaller the RMSE and MAE, the smaller the difference between the predicted value and the true value, the higher the prediction accuracy of the model, and the better the prediction performance of the neural network.