Traffic flow prediction method based on graph neural network
By introducing adaptive decoupling, time-frequency domain bidirectional graph convolution and multi-scale recursive neural network modules in traffic flow prediction, the problem of difficult to capture complex patterns of spatiotemporal data in the prior art is solved, and the prediction accuracy and stability are significantly improved.
Patent Information
- Application Number
- CN202510062522.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-15
- Publication Date
- 2025-04-25
AI Technical Summary
Existing traffic flow prediction methods are difficult to effectively capture complex patterns and multi-dimensional features in spatiotemporal data, resulting in low prediction accuracy. Especially when processing large-scale traffic flow data, it is difficult to adapt to complex traffic fluctuations.
A traffic flow prediction method based on graph neural network is proposed. The original data is divided into diffusion signals and inherent signals through the adaptive decoupling module. The time-frequency domain bidirectional graph convolution module captures the frequency characteristics and spatial topology structure in the signal, and the multi-scale recursive neural network module performs long-term prediction.
It significantly improves the accuracy and stability of traffic flow prediction, can effectively capture complex spatio-temporal patterns and multi-dimensional features, significantly reduces prediction errors, and improves the accuracy of downstream tasks.
Smart Images

Figure CN119889054A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of intelligent transportation technology, and in particular to a traffic flow prediction method based on a graph neural network. Background Art
[0002] With the rapid economic development and accelerated urbanization process in my country, the number of motor vehicle registrations and ownership has continued to grow. This growth has led to problems such as road congestion, environmental pollution and frequent traffic accidents, affecting people's daily travel and posing huge challenges to urban traffic management. In this context, intelligent transportation systems (ITS) have emerged. Through information technology, data analysis and automated control, they monitor and optimize traffic flow in real time to improve urban traffic efficiency and road utilization. Traffic flow prediction is one of the core contents of intelligent transportation systems. It predicts traffic conditions at a certain moment in the future by analyzing historical traffic data. Accurate traffic flow prediction can provide reliable decision-making support for traffic management departments and help to reasonably allocate and dispatch traffic resources. Traffic managers can plan roads and traffic control in advance based on traffic flow prediction results to alleviate congestion. Navigation systems can also provide reasonable route planning based on prediction results to avoid traffic jams and accident sections, thereby improving travel efficiency. In addition, accurate traffic flow prediction is also of great significance to the sustainable development of urban transportation. It not only improves road utilization efficiency and reduces energy consumption and emissions, but also enables timely emergency dispatch and route optimization when emergencies (such as traffic accidents, bad weather, etc.) occur, reducing accidents and traffic interference. With the rapid development of technologies such as artificial intelligence, the Internet of Things, and big data, traffic flow forecasting has gradually transformed from traditional statistical methods to intelligent algorithms based on deep learning, machine learning, and other methods, and the prediction accuracy has been continuously improved. In the future, with the accumulation of traffic data and technological advances, traffic flow forecasting will become more accurate, providing strong support for urban traffic management and decision-making, promoting the further development of intelligent transportation systems, optimizing urban traffic structures, improving traffic efficiency, and improving residents' travel experience, ultimately promoting the construction of smart cities and sustainable transportation systems.
[0003] Including prediction models based on classical statistics and data-driven prediction models. The former mainly uses limited data to regress and optimize parameters of traffic flow, while the latter uses intelligent computing methods to explore the evolution trend of historical data. Among them, deep learning models such as LSTM, GRU and CNN are widely used in traffic prediction. Although these models have achieved certain success, considering the complexity and dynamics of the traffic system, future research still needs to continue to work hard to improve prediction accuracy, real-time and robustness.
[0004] The above studies have achieved good results in the field of heart rate classification, but there are still some problems:
[0005] 1. When dealing with the spatiotemporal correlation of traffic flow, a fixed decoupling idea is adopted, which lacks adaptability to the dynamic changes of historical data of the traffic system, resulting in limited prediction accuracy.
[0006] 2. Traditional spatiotemporal graph convolution usually uses the superposition of spatiotemporal convolution and spatial convolution to extract temporal dependency and spatial dependency, but traffic flow is periodic data, so the frequency characteristics of traffic data cannot be extracted well, affecting the prediction accuracy.
[0007] 3. Existing studies cannot fully capture the long-term dependencies in traffic flow when dealing with the temporal dependencies of traffic flow, especially when dealing with traffic data with complex dynamic characteristics, which limits the performance of traffic prediction models. BRIEF DESCRIPTION OF THE DRAWINGS
[0008] The accompanying drawings herein are incorporated in and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the description, serve to explain the principles of the present disclosure;
[0009] Figure 1 This is a flow chart of a traffic flow prediction method based on a graph neural network provided by the present invention:
[0010] Figure 2 This is a schematic diagram of the traffic flow prediction method based on graph neural network provided by the present invention:
[0011] Figure 3 This is a flow chart of the adaptive learning unit provided by the present invention.
[0012] Figure 4 This is the Fourier graph convolution principle diagram provided by the present invention.
[0013] Figure 5 Schematic diagram of a multi-scale recursive neural network provided by the present invention
[0014] Figure 6 This is a K-fold verification experiment result diagram provided by the present invention. Summary of the invention
[0015] In order to overcome the problems existing in the related art, the disclosed embodiment of the present invention provides a traffic flow prediction method based on graph neural network.
[0016] The technical solution is as follows: A traffic flow prediction method based on a graph neural network includes:
[0017] S1, adaptively decouples the original data set and uses a data-driven method to separate the original data into diffusion signals and intrinsic signals.
[0018] S2, based on the data decoupled by the adaptive decoupling module, constructs a bidirectional transformation network in the time-frequency domain, uses the frequency domain to capture the frequency characteristics of traffic information, combines Fourier transform with graph neural network to predict the diffusion signal, and performs linear transformation to generate the predicted hidden state.
[0019] S3, separates the diffusion signal from the original signal, generates the inherent signal in the traffic information, and uses a multi-scale recurrent neural network model to predict the inherent signal, which can predict the signal in the long time series.
[0020] In step S1, the decoupling framework first maps the original signal to the latent space through a linear transformation, and divides the signal into a diffuse signal and a solid signal in the latent space, where the diffuse signal represents the vehicle that captures the diffusion of other sensors, and the solid signal represents the vehicle that is independent of other sensors.
[0021] In step S1, the specific steps of establishing the adaptive decoupling model are:
[0022] In the first step, an adaptive decoupling unit is established to assign weights to the original signal as the diffusion signal input.
[0023] In the second step, the back propagation of the diffusion signal is separated from the original data and used as the input of the intrinsic signal. In the third step, the back propagation of the intrinsic signal is separated again and used as the input of the next layer of model.
[0024] In the first step, the expression of the adaptive learning unit is:
[0025]
[0026] X dif =L⊙X l
[0027] Where σ represents the activation function, W1 and W2 are learnable weight matrices, || represents the vector concatenation operation, and X is the adaptive matrix. dif As input to the diffusion model
[0028] In the second step, the expression of the inherent signal is:
[0029]
[0030] In the formula, X l represents the input of the lth layer, where X 0 =X. represents the diffusion signal, X inh represents the intrinsic signal, and σ represents the activation function.
[0031] In the third step, the expression of the input of the next layer of the model is:
[0032]
[0033] In the formula, X l+1 Represents the input signal of the next layer of the model, retaining the residual signal that cannot be decomposed in the previous layer.
[0034] In step S2, the specific steps of the established Fourier graph convolution model are: constructing a local feature matrix, constructing a local diffusion matrix, constructing an adaptive diffusion matrix, and building a Fourier graph convolution network.
[0035] The expression for constructing the local feature matrix is:
[0036]
[0037] Among them, W k is a learnable weight parameter matrix, σ represents the ReLU activation function, and the introduction of nonlinear mapping can enhance the expressive power of the model. is the diffusion signal characteristic of node t.
[0038] The expression for constructing the local diffusion matrix is:
[0039]
[0040] Among them, P k (k=1,…,K s ) is a K-order transfer matrix, which represents the influence of diffusion between nodes. N is the unit matrix, ensuring that the node itself does not participate in the diffusion calculation. Traffic information has two propagation directions: forward propagation P f =A / rowsum(A), back propagation P b =A T / rowsum(A T ). Therefore (P local ) k [i,j] represents the influence of node j on node i in the local space-time range.
[0041] The expression for constructing the adaptive diffusion matrix is:
[0042] P apt =softmax(σ(E d (E u ) T ))
[0043] Among them, P apt For P f and P b Supplement the missing parts.
[0044] The expression for building a Fourier graph convolutional network described is:
[0045]
[0046] Among them, F and F -1 represents Fourier transform and inverse Fourier transform, They represent the forward propagation matrix, backward propagation matrix and adaptive matrix respectively. After the node signal is introduced into the frequency domain through Fourier transform, the features are extracted in the frequency domain.
[0047] In step S3, the specific steps of the established Fourier graph convolution model are: constructing a multi-scale recursive neural network, introducing position encoding, and introducing multi-head attention allocation weights.
[0048] The expression for constructing a multi-scale recursive neural network is:
[0049] z t =σ(W z ·[h t-1 ,x t ]+b z )
[0050] r t =σ(W r ·[h t-1 ,x t ]+b r )
[0051]
[0052] H1=GRU1(X)
[0053] H2=GRU2(H1)
[0054] Among them, σsigmoid activation function, * represents element multiplication, W z ,W r ,W and b z ,b r ,b is the learnable weight matrix and bias vector. In the multi-scale recurrent neural network, the second layer of GRU takes the output of the first layer as input.
[0055] The introduced position coding expression is:
[0056]
[0057] X′=X+PE
[0058] Where pos is the position, i is the dimension index, and d is the feature dimension. The encoded matrix PE is added to the input data.
[0059] The expression for introducing multi-head attention allocation weights is:
[0060] Q=X′W Q ,K=X′W K ,V=X′W V
[0061]
[0062] MultiHead(Q,K,V)=Concat(head1,...,head h )W O
[0063] Among them, W Q ,W K ,W V ,W O is the weight matrix, d k is the dimension of the key vector, and h is the number of attention heads. The above formula is used to calculate the attention score, and then the results are concatenated and projected.
[0064] Another object of the present invention is to provide a traffic flow prediction system based on a graph neural network, the system implements the traffic flow prediction method of the prediction graph neural network, and the system comprises:
[0065] Adaptive decoupling module: Adaptively decouple the original data set and use a data-driven approach to separate the original data into diffusion signals and intrinsic signals.
[0066] Bidirectional graph convolution module in time and frequency domain: Based on the data decoupled by the adaptive decoupling module, a bidirectional transformation network in time and frequency domain is constructed. The frequency domain is used to capture the frequency characteristics of traffic information. The Fourier transform is combined with the graph neural network to predict the diffusion signal, and a linear transformation is performed to generate the predicted hidden state.
[0067] Multi-scale recursive neural network module: It separates the diffusion signal from the original signal, generates the inherent signal in the traffic information, and uses the multi-scale recursive neural network model to predict the inherent signal, which can predict the signal in the long time series.
[0068] In summary, the beneficial effects of the present invention are as follows:
[0069] Current research faces several key issues in traffic flow prediction, especially how to effectively capture the complex patterns and multi-dimensional features in spatiotemporal data. Traditional methods usually find it difficult to fully explore the diffusion characteristics and inherent laws of signals when processing long time series data and spatial topological information, resulting in low prediction accuracy, especially when processing large-scale traffic flow data, and it is difficult to adapt to complex traffic flow fluctuation patterns. In response to these challenges, this paper proposes an innovative traffic flow prediction method based on an adaptive decoupling module, a bidirectional graph convolution module in the time-frequency domain, and a multi-scale recurrent neural network module. This method can effectively decouple and fuse spatiotemporal signals to improve the accuracy of prediction. Adaptive decoupling module: This module decouples the original data into diffusion signals and inherent signals through a data-driven approach. This decoupling process can more clearly distinguish local fluctuations and long-term trends in traffic flow, providing more accurate input for subsequent prediction modules. Bidirectional graph convolution module in the time-frequency domain: On the decoupled data, a bidirectional transform network in the time-frequency domain is used to capture the frequency domain characteristics of the signal through Fourier transform, and the spatial correlation is modeled in combination with the graph neural network. This module can not only accurately predict diffusion signals, but also improve the model's understanding of the topological structure of the traffic network, thereby improving the prediction accuracy. Multi-scale recurrent neural network module: This module models the inherent signal and uses a multi-scale recurrent neural network to predict the long-term trend. It can effectively capture the dependencies of long time series, thereby providing more accurate long-term prediction results. Experimental results show that the proposed method performs well on the PEMS-BAY and METR-LA datasets and can significantly improve the prediction accuracy. The specific indicators are: on the PEMS-BAY dataset, the RMSE value is 2.62 / 3.53 / 4.32, the MAE is 1.26 / 1.56 / 1.89, and the MAPE is 2.60 / 3.50 / 4.40; on the METR-LA dataset, the RMSE value is 4.97 / 5.96 / 7.03, the MAE is 2.58 / 2.91 / 3.36, and the MAPE is 6.60 / 7.99 / 9.678. Compared with traditional methods, the algorithm proposed in this paper has obvious advantages in spatiotemporal data modeling and long time series prediction.
[0070] Experiments show that compared with other mainstream traffic flow prediction algorithms, the method proposed in the present invention has lower prediction error and higher accuracy. By introducing an adaptive decoupling module, a bidirectional graph convolution module in the time-frequency domain, and a multi-scale recursive neural network module, the present invention can effectively improve the accuracy of traffic flow prediction, provide more accurate prediction support for intelligent transportation systems, and help traffic managers make more accurate decisions and optimize traffic flow. Especially when dealing with complex spatiotemporal data and long-term prediction tasks, this method can significantly improve the stability and reliability of the prediction, ensure the effectiveness of data in downstream tasks (such as traffic congestion prediction, traffic management scheduling, etc.), and thus improve the overall efficiency of the system.
[0071] Compared with traditional traffic flow prediction methods, the model proposed in this paper significantly improves the long-term prediction ability of traffic flow by adaptively decoupling data, transforming the time-frequency domain, and modeling multi-scale time series. The experimental results on the PEMS-BAY and METR-LA datasets show that the algorithm can effectively improve the prediction accuracy while filling the missing data. Specifically, on the PEMS-BAY dataset, the RMSE value is 2.62 / 3.53 / 4.32, the MAE is 1.26 / 1.56 / 1.89, and the MAPE is 2.60 / 3.50 / 4.40; on the METR-LA dataset, the RMSE value is 4.97 / 5.96 / 7.03, the MAE is 2.58 / 2.91 / 3.36, and the MAPE is 6.60 / 7.99 / 9.678. These results show that compared with the prior art, the present invention can effectively reduce the prediction error and provide more reliable prediction results.
[0072] Traditional traffic flow prediction methods mainly rely on traditional time series modeling and spatial modeling techniques, but these methods often ignore the multi-scale spatiotemporal characteristics of traffic data, resulting in low prediction accuracy. Some existing methods, such as statistical models based on autoregressive models and moving average methods, have poor performance when processing large-scale data sets and are difficult to effectively model the nonlinear change trend of traffic flow. To overcome these problems, this paper introduces an adaptive decoupling module, which decomposes traffic flow data into diffusion signals and intrinsic signals in a data-driven manner, providing more accurate input for the processing of bidirectional graph convolutional networks in the time-frequency domain.
[0073] The bidirectional graph convolution module in the time-frequency domain can effectively capture the frequency domain characteristics and spatial correlations in the data by combining the advantages of Fourier transform and graph neural network. Compared with traditional methods, the use of graph convolutional networks better models the propagation law of traffic flow in spatial topology, thereby significantly improving the prediction accuracy of the model. The multi-scale recursive neural network module further enhances the model's time series modeling capabilities, especially in long-time series prediction tasks, and can effectively capture long-term temporal dependencies.
[0074] By introducing these innovative modules, the present invention overcomes the shortcomings of traditional methods in spatiotemporal data modeling, greatly improves the accuracy and stability of traffic flow prediction, and provides strong support for real-time prediction and decision-making of intelligent transportation systems. Experimental results show that this method can significantly reduce prediction errors, improve the classification accuracy of downstream tasks, promote the development of intelligent transportation systems, and provide a new idea for solving complex traffic flow prediction problems. DETAILED DESCRIPTION
[0075] The technical solutions in the embodiments of the present invention will be described clearly and completely below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments.
[0076] The components of the embodiments of the present invention generally described and shown in the drawings herein may be arranged and designed in a variety of different configurations. Therefore, the following detailed description of the embodiments of the present invention provided in the drawings is not intended to limit the scope of the claimed invention, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0077] Hereinafter, the terms "including", "having" and their cognates, which may be used in various embodiments of the present invention, are intended only to indicate specific features, numbers, steps, operations, elements, components or combinations of the foregoing items, and should not be understood as first excluding the existence of one or more other features, numbers, steps, operations, elements, components or combinations of the foregoing items or adding the possibility of one or more features, numbers, steps, operations, elements, components or combinations of the foregoing items.
[0078] Furthermore, the terms “first”, “second”, “third”, etc. are merely used for distinguishing descriptions and are not to be understood as indicating or implying relative importance.
[0079] Unless otherwise defined, all terms (including technical terms and scientific terms) used herein have the same meanings as those generally understood by those skilled in the art to which the various embodiments of the present invention belong. The terms (such as those defined in generally used dictionaries) will be interpreted as having the same meanings as the contextual meanings in the relevant technical field and will not be interpreted as having idealized meanings or overly formal meanings unless clearly defined in the various embodiments of the present invention.
[0080] The innovation of the present invention is that the graph neural network is proposed to effectively improve the accuracy and stability of traffic flow prediction by introducing an adaptive decoupling module, a bidirectional graph convolution module in the time-frequency domain, and a multi-scale recursive neural network module. The original data is decoupled by the adaptive decoupling module, and the traffic flow signal is successfully decomposed into a diffusion signal and an inherent signal, which solves the problem that traditional methods cannot accurately process complex spatiotemporal data. The bidirectional graph convolution module in the time-frequency domain further combines Fourier transform with the graph neural network to accurately capture the frequency domain characteristics and spatial topological structure in the traffic flow data, reducing the traditional method's neglect of frequency and time series characteristics in traffic flow prediction. In addition, the multi-scale recursive neural network module effectively improves the prediction ability of long time series signals, ensuring the accuracy of long-term predictions.
[0081] Exemplarily, the present invention proposes a new spatiotemporal data modeling architecture, which can not only separate the complex spatiotemporal patterns in traffic flow through an adaptive decoupling module, but also greatly improve the prediction accuracy by combining frequency domain features and the spatial modeling capabilities of graph convolution networks through a bidirectional graph convolution module in the time and frequency domain. On this basis, the multi-scale recursive neural network module effectively improves the ability to capture long-term dependencies and enhances the long-term prediction ability of the model. Compared with traditional methods, the present invention innovatively improves the understanding and prediction of complex traffic flow patterns through the synergy of multiple modules, reduces prediction errors and improves the accuracy of downstream tasks.
[0082] The proposed graph neural convolutional network outperforms other mainstream traffic flow prediction methods in terms of performance, especially when processing large-scale spatiotemporal data, showing lower mean square error (RMSE) and higher prediction accuracy. By combining adaptive decoupling with bidirectional graph convolution in the time-frequency domain, this method can effectively improve the accuracy of traffic flow prediction, provide strong support for real-time prediction and decision-making of intelligent transportation systems, and promote the optimization and upgrading of traffic management systems.
[0083] Embodiment 1, as Figure 1 As shown, the graph neural network-based traffic flow prediction algorithm provided by an embodiment of the present invention introduces a bidirectional transformation in the time-frequency domain, which can capture the periodic characteristics of traffic signals in the frequency domain, greatly improving the accuracy of traffic information.
[0084] S1, adaptively decouples the original data set and uses a data-driven method to separate the original data into diffusion signals and intrinsic signals.
[0085] S2, based on the data decoupled by the adaptive decoupling module, constructs a bidirectional transformation network in the time-frequency domain, uses the frequency domain to capture the frequency characteristics of traffic information, combines Fourier transform with graph neural network to predict the diffusion signal, and performs linear transformation to generate the predicted hidden state.
[0086] S3, separates the diffusion signal from the original signal, generates the inherent signal in the traffic information, and uses a multi-scale recurrent neural network model to predict the inherent signal, which can predict the signal in the long time series.
[0087] Figure 2 This is the principle of the traffic flow prediction method based on graph neural network provided by the embodiment of the present invention. The present invention provides a traffic flow prediction algorithm based on graph neural network, including:
[0088] Adaptive decoupling module: Adaptively decouple the original data set and use a data-driven approach to separate the original data into diffusion signals and intrinsic signals.
[0089] Bidirectional graph convolution module in time and frequency domain: Based on the data decoupled by the adaptive decoupling module, a bidirectional transformation network in time and frequency domain is constructed. The frequency domain is used to capture the frequency characteristics of traffic information. The Fourier transform is combined with the graph neural network to predict the diffusion signal, and a linear transformation is performed to generate the predicted hidden state.
[0090] Multi-scale recursive neural network module: It separates the diffusion signal from the original signal, generates the inherent signal in the traffic information, and uses the multi-scale recursive neural network model to predict the inherent signal, which can predict the signal in the long time series.
[0091] Example 2, as another implementation of the present invention, the operation process of the traffic flow prediction method based on graph neural network provided in the embodiment of the present invention includes:
[0092] I. System initialization and configuration:
[0093] (I.1) Import libraries and tools: including `aprgparse`, `time`, `torch`, `pickle`, `pandas`, `yaml`, `setproctitle`, etc.
[0094] (I.2) Define the main function main(): (I.2.1) Parse command line arguments. (I.2.2) Set different variables based on the arguments. (I.2.3) Set hyperparameters during training. (I.2.4) Read the training dataset. (I.2.5) Read the test dataset. (I2.6) Create a model object. (I.2.7) Build the model. (I.2.8) Train the model. (I.2.9) Make predictions on the training dataset. (I.2.10) Make predictions on the test dataset.
[0095] The parameters added are as follows:
[0096] mode: model running mode (test, resume, scratch)
[0097] resume_epoch: From which training mode to start training, the default is 0
[0098] Device: specifies the computing device used for training, set cuda: 0
[0099] load_pkl: If True, it means to load the serialized data loader, otherwise generate the data loader.
[0100] Data_dir: data file path, datasets / METR_LA means loading the METR_LA dataset
[0101] adj_data_dir: adjacency matrix path, storing graph structure information, indicating the relationship between traffic sensors in the dataset
[0102] adj_type: adjacency matrix type, which captures the dynamic relationship of traffic flow through different transfer matrices.
[0103] batch_size: The number of samples in each training batch, the default is 32.
[0104] num_feat: The number of input features.
[0105] num_hidden: The size of the hidden layer in the model, the default is 32.
[0106] node_hidden: Node sensor hidden layer size, set to 10.
[0107] time_emb_dim: time embedding dimension, set to 10.
[0108] Dropout: used to avoid overfitting and set to 0.1
[0109] seq_length: The sequence length is set to 12
[0110] k_t: time convolution step, set to 3, used to process time dimension convolution
[0111] k_s: spatial convolution step size, set to 2, used to process spatial dimension convolution.
[0112] gap: The interval in the time series, set to 3, indicating that different time steps are selected in the model.
[0113] lrate: The learning rate is set to 0.002, which is used for the optimizer’s learning rate and determines the step size of the parameter update.
[0114] wdecay: weight decay, L2 regularization, set to 1.0e-5 to prevent overfitting.
[0115] eps: used for numerical stability of the optimizer, set to 1.0e-8 to ensure that no errors occur during the calculation.
[0116] epochs: total number of training rounds
[0117] patience: Number of rounds to stop early.
[0118] (I.3) Initialize the CUDA environment.
[0119] II. Data processing:
[0120] (II.1) Data loading: First, use the load_dataset function to load the data. This function reads the dataset file stored in the specified path and loads the input (x) and output (y) data of the training set, validation set, and test set according to the mode (train, val, test).
[0121] (II.2) Data normalization: Maximum and minimum normalization is a commonly used normalization method, which scales the value of each feature to a specified interval (usually [0,1]). The formula is as follows:
[0122]
[0123] In the formula, x scale is the data value after normalization, x scale In the interval [0,1]; max(d j ),min(d j ) are the maximum and minimum values of the j-th dimension attribute, respectively, x ij The data are not normalized.
[0124] (II.3) Data loading and batch processing: The DataLoader class is used to batch the loaded data so that the data can be fed in batches when training the model. The data loading class first checks whether the batch can divide the number of samples in the data. If not, it will pad (by copying the last sample data) to ensure the consistency of the batch size. In this way, DataLoader will divide the data into several small batches for training according to the given batch size. At the same time, you can choose whether to randomly shuffle the data (shuffle = True) to ensure the diversity of training.
[0125] III. Building and training neural network models:
[0126] (III.1) Model design. Specifically including:
[0127] To address the problem of traffic flow prediction accuracy, this paper proposes a method based on graph neural network, which proposes adaptive decoupling, bidirectional transformation in time-frequency domain and multi-scale recursive neural network.
[0128] The expression of the adaptive learning unit is:
[0129]
[0130] X dif =L⊙X l
[0131] Where σ represents the activation function, W1 and W2 are learnable weight matrices, || represents the vector concatenation operation, and X is the adaptive matrix. dif As input to the diffusion model
[0132] The expression of the inherent signal is:
[0133]
[0134] In the formula, X l represents the input of the lth layer, where X 0 =X. represents the diffusion signal, X inh represents the intrinsic signal, and σ represents the activation function.
[0135] The expression of the input of the next layer of the model is:
[0136]
[0137] In the formula, X l+1 Represents the input signal of the next layer of the model, retaining the residual signal that cannot be decomposed in the previous layer.
[0138] In step S2, the specific steps of the established Fourier graph convolution model are: constructing a local feature matrix, constructing a local diffusion matrix, constructing an adaptive diffusion matrix, and building a Fourier graph convolution network.
[0139] The expression for constructing the local feature matrix is:
[0140]
[0141] Among them, W k is a learnable weight parameter matrix, σ represents the ReLU activation function, and the introduction of nonlinear mapping can enhance the expressive power of the model. is the diffusion signal characteristic of node t.
[0142] The expression for constructing the local diffusion matrix is:
[0143]
[0144] Among them, P k (k=1,…,K s ) is a K-order transfer matrix, which represents the influence of diffusion between nodes. N is the unit matrix, ensuring that the node itself does not participate in the diffusion calculation. Traffic information has two propagation directions: forward propagation P f =A / rowsum(A), back propagation P b =A T / rowsum(AT ). Therefore (P local ) k [i,j] represents the influence of node j on node i in the local space-time range.
[0145] The expression for constructing the adaptive diffusion matrix is:
[0146] P apt =softmax(σ(E d (E u ) T ))
[0147] Among them, P apt For P f and P b Supplement the missing parts.
[0148] The expression for building a Fourier graph convolutional network described is:
[0149]
[0150] Among them, F and F -1 represents Fourier transform and inverse Fourier transform, They represent the forward propagation matrix, backward propagation matrix and adaptive matrix respectively. After the node signal is introduced into the frequency domain through Fourier transform, the features are extracted in the frequency domain.
[0151] In step S3, the specific steps of the established Fourier graph convolution model are: constructing a multi-scale recursive neural network, introducing position encoding, and introducing multi-head attention allocation weights.
[0152] The expression for constructing a multi-scale recursive neural network is:
[0153] z t =σ(W z ·[h t-1 ,x t ]+b z )
[0154] r t =σ(W r ·[h t-1 ,x t ]+b r )
[0155]
[0156] H1=GRU1(X)
[0157] H2=GRU2(H1)
[0158] Among them, σsigmoid activation function, * represents element multiplication, W z ,W r ,W and b z ,b r ,b is the learnable weight matrix and bias vector. In the multi-scale recurrent neural network, the second layer of GRU takes the output of the first layer as input.
[0159] The introduced position coding expression is:
[0160]
[0161] X′=X+PE
[0162] Where pos is the position, i is the dimension index, and d is the feature dimension. The encoded matrix PE is added to the input data.
[0163] The expression for introducing multi-head attention allocation weights is:
[0164] Q=X′W Q ,K=X′W K ,V=X′W V
[0165]
[0166] MultiHead(Q,K,V)=Concat(head1,...,head h )W O
[0167] Among them, W Q ,W K ,W V ,W O is the weight matrix, d k is the dimension of the key vector, and h is the number of attention heads. The above formula is used to calculate the attention score, and then the results are concatenated and projected.
[0168] (III.2) Model training:
[0169] a. Use torch.manual_seed() to initialize the random seed to ensure the same results each time you run the code. Next, load and preprocess the training and test datasets to ensure that the data format meets the model input requirements.
[0170] b. Use the argparse tool to receive command line arguments and define the hyperparameters of the model.
[0171] c. Define a class that inherits from torch.nn.Module to implement the neural network architecture for traffic flow prediction.
[0172] The optimizer in d.torch.optim and set the learning rate and momentum.
[0173] e. Use for epoch in range(num_epochs) to iterate for training. In each iteration, the training data is passed into the model and the model parameters are updated by calculating the loss function. Use loss.backward() and optimizer.step() to perform backpropagation and parameter updates. In order to prevent overfitting, regularization and early stopping mechanisms are added during the training process.
[0174] f. Model evaluation: During and after training, the test data set is used for evaluation, and various evaluation indicators such as root mean square error (RMSE), accuracy, misclassification rate (PFC), AUC value are calculated, and the ROC curve is drawn to evaluate the predictive performance of the model.
[0175] g. Use torch.save(model.state_dict(),"model.pth") to save the trained model, and use model.load_state_dict(torch.load("model.pth")) to load the model for subsequent prediction or further training.
[0176] h. During the training and evaluation process, record the loss value, evaluation index, training time and other information of each training, and conduct a detailed analysis of the performance of the model on different data sets to compare the advantages and disadvantages of the models under different configurations.
[0177] IV. Performance Evaluation and Results Recording:
[0178] (IV.1) Evaluation metrics calculation: mean absolute error (MAE), root mean square error (RMSE) and mean absolute percentage error (MAPE).
[0179] (IV.11) The root mean square error (MAE) is calculated as follows:
[0180]
[0181] Among them, y i is the true value, is the model's prediction, and n is the number of samples. MAE measures the average absolute difference between the predicted value and the true value. It calculates the difference between each predicted value and the true value (regardless of the sign) and takes the average to get a measure of the overall error. The advantages of MAE are that it is easy to understand and less sensitive to outliers. It does not amplify large errors (unlike RMSE), so it evaluates the performance of the model on all samples more fairly.
[0182] (IV.12) The root mean square error RMSE is calculated as follows:
[0183]
[0184] Among them, y i is the true value, is the model's prediction, and n is the number of samples. RMSE is a metric obtained by squaring each prediction error, taking the average, and then taking the square root. Since squaring will amplify large errors, RMSE is particularly sensitive to large errors (outliers). RMSE can reflect the impact of large errors on the overall model evaluation, so it is usually used in situations where the penalty for large errors is more stringent.
[0185] (IV.13) The root mean square error MAPE calculation formula is as follows:
[0186]
[0187] Among them, y i is the true value, is the predicted value of the model, and n is the number of samples. MAPE is calculated by calculating the absolute error of each sample as a percentage of the true value, and then averaging the percentage errors of all samples. MAPE can directly reflect the relative size of the model prediction error, usually expressed as a percentage, and has good interpretability. The smaller its value, the closer the model's prediction is to the true value.
[0188] (IV.2) Best model selection: Select the best model based on indicators such as test accuracy.
[0189] (IV.4) Result saving: Save the training and testing results.
[0190] V. System optimization and adjustment include:
[0191] Parameter tuning: Adjust the network structure and training parameters based on the performance results.
[0192] Code optimization: Optimize code to improve efficiency.
[0193] It can be seen from the above embodiments that based on the limitations of traditional methods for traffic flow prediction, this study proposes a new method that combines deep learning and graph neural networks, aiming to more accurately predict complex urban traffic flow. Compared with traditional time series prediction methods, this method does not rely on explicit assumptions, and can automatically learn the spatiotemporal characteristics of traffic flow data to generate more representative prediction results. By combining graph convolutional neural networks (GCN) and recurrent neural networks (RNN), this method can effectively capture the spatial dependency and temporal evolution of traffic flow. This traffic flow prediction method based on deep learning and graph neural networks overcomes the shortcomings of traditional methods in modeling ability and generalization, and provides a more accurate and efficient data processing method for traffic management and smart city systems.
[0194] Based on the shortcomings of traditional methods in terms of low traffic flow prediction accuracy and inability to fully utilize the urban road network structure, this study proposes a new method that combines graph convolution and multi-scale recurrent neural network. This method solves the problem that traditional methods cannot effectively integrate spatial structure and time evolution information when processing complex traffic flow data by constructing a spatiotemporal graph of traffic flow and combining multi-scale time-frequency domain analysis. After experimental verification, this method shows low error and high prediction accuracy in traffic flow prediction tasks, significantly improves the model's prediction ability in dynamic traffic environments, and effectively enhances the decision-making support capabilities of intelligent transportation systems. This innovative method not only solves the problem of insufficient modeling of complex spatiotemporal dependencies in traditional prediction methods, but also provides new ideas and directions for future traffic flow prediction research.
[0195] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0196] To further illustrate the effects of the embodiments of the present invention, the following experiments are conducted: a comparison experiment of different methods on the METR-LA dataset, a comparison experiment of different methods on the PEMS-BAY dataset, and a k-fold verification test.
[0197] The present invention selects a typical model for traffic flow prediction as a comparison.
[0198] HA; A simple time series forecasting method that calculates the average of data from past time periods to predict future values. Suitable for baseline forecasting of time series data. Often used to compare the performance of more complex models.
[0199] FC-LSTM: A long short-term memory (LSTM) network for processing long-term dependencies in sequence data. The fully connected layer of the network connects the LSTM hidden state to the output layer for time series prediction. It can capture long-term dependencies in time series and adapt to complex time series data.
[0200] DCRNN: It combines diffusion convolution and recurrent neural network (RNN) to model the dependencies between nodes through the diffusion process, which is suitable for time series prediction on graph structured data. It can process time series of graph structured data and capture complex spatiotemporal dependencies.
[0201] STSGCN: It combines the graph convolutional network (GCN) and the temporal convolutional network (TCN) to process the spatial and temporal dependencies in spatiotemporal data through synchronous graph convolution. It can process spatial and temporal dependencies at the same time and is suitable for complex spatiotemporal data.
[0202] MTGNN: Uses graph neural network (GNN) to model the dependencies between multivariate time series data and dynamically generates graph structures through graph learning methods. It can dynamically learn the dependencies between data, has strong adaptability and good performance.
[0203] ASTGCN: Combining graph convolutional networks and attention mechanisms, it improves the modeling ability of spatiotemporal dependencies through spatial and temporal attention mechanisms. The attention mechanism is used to enhance the ability to capture spatiotemporal relationships and effectively model long-term dependencies.
[0204] (1) Comparative experiments of different methods are conducted on the METR-LA dataset.
[0205] Table 1 Experimental values of different methods on METR-LA
[0206]
[0207] (2) Comparative experiments of different methods are conducted on the PEMS-BAY dataset.
[0208] Table 2 Experiments of different methods on PEMS-BAY
[0209]
[0210] (3) k-fold verification experiment
[0211] In order to evaluate the universality and prediction performance of the proposed traffic prediction model, the present invention adopts the K-fold cross-validation method in the experimental part, such as Figure 6The present invention selects different K values (K = 5, 10, 15, 20, 25) for verification to ensure the stability and generalization ability of the model under different data partitions. Cross-validation can effectively reduce the model's dependence on a specific data set and provide a more objective evaluation of the model's performance. In the K-fold validation, the present invention randomly divides the data set into K subsets, uses K-1 subsets for training each time, and uses the remaining 1 subset for testing. After K cycles, each subset is used as a test set, and the average value of the K experimental results is finally taken as the performance indicator of the model. The experimental results are shown in the figure. Under different K values, the performance of the model varies. We analyzed the three indicators of MAE, MAPE and RMSE: In all experiments, MAE, MAPE and RMSE when K = 15 all reached the lowest values, indicating that the model has the best prediction performance under this K value. In other words, when K = 15, the model can provide the prediction results with the smallest error and stability. With the change of K value, the three error indicators show certain fluctuations, but they all maintain a low error level near K = 15. This shows that the model can maintain good stability and generalization ability within the appropriate range of K values. K-fold validation effectively reduces the accidental impact of data partitioning through multiple splits and tests, and improves the credibility of the results. When the K value is too small (such as K = 5), the training data is not enough to fully train the model; when the K value is too large (such as K = 25), the test data is too small, resulting in insufficient evaluation of the model on the test data. Therefore, a K value that is too large or too small will affect the generalization ability of the model. In summary, the results of the K-fold cross-validation experiment prove that our traffic prediction model has good universality and stable prediction performance under different data partitions, especially when K = 15, the model has the best performance. This provides an effective reference for model selection and parameter adjustment in practical applications.
[0212] Experimental results: Higher accuracy: The results are shown in Tables 1 and 2. Among the compared framework models, the model framework proposed by the present invention has better performance than the comparison models. At the same time, the model studied in this article can better analyze the periodicity of traffic data, which is due to the bidirectional transformation of the time-frequency domain in this model. And the adaptive learning unit and multi-scale recursive neural network also improve the overall performance of the model. Overall, the model shows good convergence and prediction accuracy on both training and validation data sets, verifying the effectiveness of the model in processing traffic data prediction tasks. The verification loss and accuracy are both within a reasonable range, indicating that the model has good generalization ability.
[0213] Solved the problem that traditional methods cannot fully capture the spatiotemporal dependency and complexity of traffic flow: Traditional models often rely only on single time series data, ignoring the spatial correlation between different road sections, resulting in limited model prediction effect. By introducing graph convolutional neural network (GCN) and multi-scale time series modeling, this study effectively solved this problem, enabling the model to simultaneously learn the spatial dependency and temporal evolution of traffic flow, thereby improving prediction accuracy and solving the spatiotemporal complexity problem in traffic flow data.
[0214] It should be understood that the various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, a plurality of steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0215] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "examples", "specific examples", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0216] Although the embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the claims and their equivalents.
[0217] The above is a specific description of the preferred implementation of the present invention, but the present invention is not limited to the described embodiments. Those skilled in the art may make various equivalent modifications or substitutions without violating the spirit of the present invention. These equivalent modifications or substitutions are all included in the scope defined by the claims of this application.
Claims
1. A traffic flow prediction method based on graph neural network, characterized in that: The following steps are involved: S1: Adaptively decouple the original data set and use a data-driven method to separate the original data into diffusion signals and intrinsic signals; S2: Based on the data decoupled by the adaptive decoupling module, a bidirectional transformation network in the time-frequency domain is constructed. The frequency domain is used to capture the frequency characteristics of traffic information. The Fourier transform is combined with the graph neural network to predict the diffusion signal, and a linear transformation is performed to generate the predicted hidden state. S3: The diffusion signal is separated from the original signal to generate the inherent signal in the traffic information. The multi-scale recurrent neural network model is used to predict the inherent signal, which can predict the signal in the long time series.
2. The traffic flow prediction method based on graph neural network according to claim 1 is characterized in that: The adaptive decoupling described in S1 includes the following steps: The original signal is mapped to the latent space through linear transformation, and the signal is divided into diffuse signal and intrinsic signal in the latent space, where the diffuse signal represents the vehicle that captures the diffusion of other sensors, and the intrinsic signal represents the vehicle that is independent of other sensors.
3. The traffic flow prediction method based on graph neural network according to claim 1 is characterized in that: The adaptive decoupling of the original data set comprises the following steps: S11: Establish an adaptive decoupling unit to assign weights to the original signal as a diffusion signal input; S12: stripping the back propagation of the diffusion signal from the original data as the input of the intrinsic signal; S13: The backward propagation of the intrinsic signal is stripped off again and used as the input of the next layer model.
4. The traffic flow prediction method based on graph neural network according to claim 3 is characterized in that: The expression of the adaptive decoupling unit in step S11 is: X dif =L⊙X l Where σ represents the activation function, W1 and W2 are learnable weight matrices, || represents the vector concatenation operation, and X is the adaptive matrix. dif As input to the diffusion model.
5. The traffic flow prediction method based on graph neural network according to claim 3 is characterized in that: The expression of the inherent signal in step S12 is: Where, X l represents the input of the lth layer, where X 0 =X. represents the diffusion signal, X inh represents the intrinsic signal, and σ represents the activation function. The input expression of the next layer model described in step S13 is: Where, X l+1 Represents the input signal of the next layer of the model, retaining the residual signal that cannot be decomposed in the previous layer.
6. The traffic flow prediction method based on graph neural network according to claim 1 is characterized in that: The specific steps of the Fourier graph convolution model established by S2 are: constructing a local feature matrix, constructing a local diffusion matrix, constructing an adaptive diffusion matrix, and building a Fourier graph convolution network.
7. The traffic flow prediction method based on graph neural network according to claim 6 is characterized in that: The expression for constructing the local feature matrix is: Among them, W k is a learnable weight parameter matrix, σ represents the ReLU activation function, and the introduction of nonlinear mapping can enhance the expressive power of the model. is the diffusion signal characteristic of node t. The expression for constructing the local diffusion matrix is: Among them, P k (k=1,…,K s ) is a K-order transfer matrix, which represents the influence of diffusion between nodes. N is the unit matrix, ensuring that the node itself does not participate in the diffusion calculation. Traffic information has two propagation directions: forward propagation P f =A / rowsum(A), back propagation P b =A T / rowsum(A T ). Therefore (P local ) k [i,j] represents the influence of node j on node i in the local space-time range. The expression for constructing the adaptive diffusion matrix is: P apt =softmax(σ(E d (AND u ) T )) Among them, P apt For P f and P b Supplement the missing parts. The expression for building a Fourier graph convolutional network described is: Among them, F and F -1 represents Fourier transform and inverse Fourier transform, They represent the forward propagation matrix, backward propagation matrix and adaptive matrix respectively. After the node signal is introduced into the frequency domain through Fourier transform, the features are extracted in the frequency domain.
8. The traffic flow prediction method based on graph neural network according to claim 1 is characterized in that: The specific steps of the Fourier graph convolution model established by S3 are: constructing a multi-scale recursive neural network, introducing position encoding, and introducing multi-head attention allocation weights.
9. The traffic flow prediction method based on graph neural network according to claim 8 is characterized in that: The expression for constructing a multi-scale recursive neural network is: z t =σ(W z ·[h t-1 ,x t ]+b z ) r t =σ(W r ·[h t-1 ,x t ]+b r ) H1=GRU1(X) H2=GRU2(H1) Among them, σ is the id activation function, * represents element multiplication, W z ,W r ,W and b z ,b r ,b is the learnable weight matrix and bias vector. In the multi-scale recurrent neural network, the second layer of GRU takes the output of the first layer as input. The introduced position coding expression is: X′=X+PE Where pos is the position, i is the dimension index, and d is the feature dimension. The encoded matrix PE is added to the input data. The expression for introducing multi-head attention allocation weights is: Q=X′W Q ,K=X′W K ,V=X′W V MultiHead(Q,K,V)=Concat(head1,...,head h )W O Among them, W Q ,W K ,W V ,W O is the weight matrix, d k is the dimension of the key vector, and h is the number of attention heads. The above formula is used to calculate the attention score, and then the results are concatenated and projected.
10. A traffic flow prediction system based on graph neural network, characterized in that: The system implements the traffic flow prediction method based on graph neural network as described in any one of claims 1 to 9, and the system includes: Adaptive decoupling module: Adaptively decouples the original data set and uses a data-driven approach to separate the original data into diffusion signals and intrinsic signals; Bidirectional graph convolution module in time-frequency domain: Based on the data decoupled by the adaptive decoupling module, a bidirectional transformation network in time-frequency domain is constructed. The frequency domain is used to capture the frequency characteristics of traffic information. Fourier transform is combined with graph neural network to predict the diffusion signal, and linear transformation is performed to generate the predicted hidden state. Multi-scale recursive neural network module: It separates the diffusion signal from the original signal, generates the inherent signal in the traffic information, and uses the multi-scale recursive neural network model to predict the inherent signal, which can predict the signal in the long time series.
Citation Information
Cited By
Traffic flow prediction method based on time-frequency domain joint modeling
CN121354346A