A short-term traffic flow prediction method and system based on multi-feature graph
By constructing multi-feature maps and using GCN and improved Transformer encoder for feature fusion, the comprehensive modeling problem of existing traffic flow prediction methods ignoring spatial characteristics and road conditions is solved, and more accurate and robust traffic flow prediction is achieved.
Patent Information
- Application Number
- CN202510093100.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-21
- Publication Date
- 2025-04-11
- Estimated Expiration
- 2045-01-21
AI Technical Summary
Existing traffic flow prediction methods cannot effectively capture nonlinear features in traffic flow data, ignore the spatial characteristics of the data, and lack comprehensive modeling of road conditions.
A short-term traffic flow prediction method based on multi-feature map is adopted to obtain data on traffic flow, occupancy and average speed, and a corresponding feature map is constructed, and feature aggregation and supervised learning training is used to fuse multiple feature data to build a multi-feature fusion traffic flow prediction model.
Comprehensive modeling of road conditions is achieved, the accuracy and robustness of traffic flow prediction is improved, and the temporal and spatial characteristics of traffic flow data can be better captured.
Smart Images

Figure CN119541217B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of traffic flow prediction, and relates to a short-term traffic flow prediction method and system based on multiple feature graphs. Background Art
[0002] Short-term traffic flow prediction is an important topic in the construction of intelligent transportation systems. It plays a vital role in many application scenarios such as road resource management, urban transportation network optimization, and traffic congestion relief. In real life, traffic flow will show a certain periodicity over time, such as the morning and evening rush hours in cities. In addition, traffic flow data is also uncertain. For example, people's travel will be affected by weather conditions, traffic accidents, road maintenance, holidays, and large-scale events. Research in recent years has shown that traffic flow data is also closely related to the spatial location of sensors on the map. For example, the traffic volume on roads in the main urban area of a city is larger than that on roads in the suburbs.
[0003] Early studies on traffic flow prediction were based on statistical methods, using linear combinations to fit the fluctuation characteristics of data to perform short-term traffic flow prediction. For example, short-term traffic flow prediction was achieved by combining the autoregression and moving average model (ARMA) and Kalman filtering. Short-term traffic flow prediction was achieved by using empirical mode decomposition (EMD) and ARMA. Although the above methods can quickly realize traffic flow modeling, they cannot effectively capture the nonlinear characteristics in traffic flow data and have low accuracy.
[0004] With the rapid development of machine learning technology, researchers have gradually tried to use machine learning algorithms to achieve traffic flow prediction tasks; among them, common methods include support vector regression (SVR), eXtreme Gradient Boosting (XGBoost), Long Short-Term Memory (LSTM), and Gated Recurrent Unit (GRU). Compared with LSTM and GRU models, the baseline gradient boosting algorithm (XGBoost) based on the ensemble learning framework does not require a large amount of training data, has fast data feature fitting, and high computational efficiency. In addition, the ensemble learning framework can combine multiple meta-classifiers to improve the overall generalization and accuracy of the model. Although the above studies have shown good performance in traffic flow prediction, they have failed to consider the spatial dimension characteristics of the data, and traffic flow data is also inseparable from the spatial location of the sensor.
[0005] In addition, some researchers have proposed to use the spatio-temporal graph neural network framework to predict traffic flow. Complex traffic flow data has both temporal and spatial characteristics. According to the temporal and spatial characteristics of traffic flow data, a graph topology is constructed according to the spatial position of the sensor. The data collected by the sensor is used as the node feature of the graph. Then, the graph neural network is used to aggregate the node features, and the sequence neural network is used to capture the fluctuation characteristics of the data over time. The spatio-temporal graph neural network framework (full name Spatio-Temporal Graph Neural Network, STGNN for short) is used to integrate the two characteristics of traffic flow data by integrating the temporal network and the spatial network to achieve the fusion of temporal and spatial characteristics and predict short-term traffic flow. Although the above method can effectively capture the spatio-temporal characteristics of traffic flow data, it only focuses on the traffic flow data and ignores the occupancy rate and average speed collected by the sensor. When a large "peak" appears in the occupancy data collected by the sensor, there may be a traffic jam on the road during this period, and at the same time, the average speed of vehicles on the road also has a significant "trough", and the traffic flow data in the corresponding period is significantly reduced. Therefore, the existing traffic flow prediction method lacks comprehensive learning of road traffic conditions.
[0006] In summary, statistical methods cannot effectively capture the nonlinear characteristics of traffic flow data, and traditional machine learning methods ignore the modeling of spatial characteristics of data. The current spatiotemporal graph framework can effectively capture the temporal and spatial characteristics of traffic flow data, but ignores the occupancy rate and average speed characteristics collected by sensors, and lacks comprehensive modeling of road conditions. Summary of the invention
[0007] In view of the problems existing in the prior art, the present invention provides a short-term traffic flow prediction method and system based on multi-feature graphs, which not only considers the learning of traffic flow characteristic data, but also introduces characteristic data of occupancy rate and average speed, fully learns the three characteristic data and builds the connection between the data, realizes comprehensive modeling of road conditions, and better realizes traffic flow prediction.
[0008] The present invention is achieved through the following technical solutions:
[0009] A short-term traffic flow prediction method based on multiple feature graphs, comprising:
[0010] Obtain data on traffic flow, occupancy rate and average speed, and construct a traffic flow characteristic graph, an occupancy rate characteristic graph and an average speed characteristic graph respectively;
[0011] Node feature information based on GCN aggregated traffic flow feature map, occupancy feature map and average speed feature map;
[0012] The improved Transformer encoder is used to perform supervised learning training on the node feature information of the aggregated occupancy feature map and the average speed feature map to obtain the occupancy feature vector and the average speed feature vector.
[0013] The node feature information of the aggregated traffic flow feature graph is interactively fused with the occupancy feature vector and the average speed feature vector to construct a multi-feature fusion traffic flow prediction model.
[0014] The multi-feature fusion traffic flow prediction model is trained, and short-term traffic flow prediction is performed based on the trained multi-feature fusion traffic flow prediction model.
[0015] Preferably, data on traffic flow, occupancy rate and average speed are obtained, and a traffic flow characteristic graph, an occupancy characteristic graph and an average speed characteristic graph are constructed respectively, specifically:
[0016] Traffic flow, occupancy and average speed data are collected through road sensors and the data are used as feature information of the graph respectively. The map location information of the road sensor is used as the skeleton of the graph, each road sensor is used as a node of the graph, and the relationship between roads on the map is used as the edge of the graph, so as to construct a traffic flow feature graph, an occupancy feature graph and an average speed feature graph respectively.
[0017] Preferably, the node feature information of the GCN-aggregated traffic flow feature graph, occupancy feature graph, and average speed feature graph is specifically as follows:
[0018] Through GCN, the data of traffic flow feature map, occupancy feature map and average speed feature map are respectively combined with the corresponding t Traffic flow data at time step, t Occupancy data for each time step and t The average speed data of each time step is aggregated to extract the node feature information of the traffic flow feature map, occupancy feature map and average speed feature map.
[0019] Preferably, the improvement of the Transformer encoder is as follows:
[0020] Use the TCN model to replace the Feed Forward layer of the Transformer encoder to improve the Transformer encoder;
[0021] Among them, the TCN model includes multiple residual modules, and each residual module includes dilated convolution and causal convolution.
[0022] Preferably, an improved Transformer encoder is used to perform supervised learning training on the node feature information of the aggregated occupancy feature map to obtain an occupancy feature vector, specifically:
[0023] The node feature information of the occupancy feature map is used as the input of the improved Transformer encoder. The node feature information of the occupancy feature map is encoded and converted based on the improved Transformer encoder through layer normalization and multi-head attention mechanism to obtain an occupancy feature vector. The occupancy feature vector is processed by a Softmax classifier to obtain a predicted value of the occupancy. The error between the predicted value and the true value of the occupancy is calculated using a log-likelihood function to obtain a loss value of the occupancy. Based on the loss value of the occupancy, the weights and biases of the improved Transformer encoder are repeatedly updated for supervised learning training until the loss value of the occupancy no longer decreases, and the occupancy feature vector after supervised learning training is output.
[0024] Among them, the loss value of occupancy rate is calculated by the following formula:
[0025]
[0026] In the formula, Mo is the total number of occupancy samples, For the i The true value of the occupancy samples, For the i The predicted value of occupancy samples, is the loss value of occupancy rate.
[0027] Preferably, an improved Transformer encoder is used to perform supervised learning training on the node feature information of the aggregated average speed feature graph to obtain an average speed feature vector, specifically:
[0028] The node feature information of the average speed feature map is used as the input of the improved Transformer encoder. The node feature information of the average speed feature map is encoded and converted based on the improved Transformer encoder through layer normalization and multi-head attention mechanism to obtain the average speed feature vector. The average speed feature vector is processed by the Softmax classifier to obtain the predicted value of the average speed. The error between the predicted value and the true value of the average speed is calculated using the log-likelihood function to obtain the loss value of the average speed. The weights and biases of the improved Transformer encoder are repeatedly updated based on the loss value of the average speed for supervised learning training until the loss value of the average speed no longer decreases, and the average speed feature vector after supervised learning training is output.
[0029] Among them, the loss value of the average speed is calculated by the following formula:
[0030]
[0031] In the formula, Ms is the total number of average speed samples, For the i The true value of the average speed samples, For the i The predicted value of the average speed samples, is the average speed loss value.
[0032] Preferably, the node feature information of the aggregated traffic flow feature graph is interactively fused with the occupancy feature vector and the average speed feature vector to construct a multi-feature fusion traffic flow prediction model, specifically:
[0033] The cross-attention mechanism is used to replace the self-attention mechanism in the improved Transformer encoder. The node feature information of the aggregated traffic flow feature graph is fused with the occupancy feature vector and the average speed feature vector after supervised training as the input of the cross-attention mechanism in the improved Transformer encoder. After splicing the fusion results, multi-feature fusion traffic flow data is extracted to construct a multi-feature fusion traffic flow prediction model.
[0034] Preferably, the multi-feature fusion traffic flow prediction model is trained, and short-term traffic flow prediction is performed based on the trained multi-feature fusion traffic flow prediction model, specifically as follows:
[0035] The loss value of occupancy rate, the loss value of average speed and the loss value of traffic flow are jointly trained by multi-task joint learning, and the error between the predicted value of short-term traffic flow of multi-feature fusion output by the multi-feature fusion traffic flow prediction model and the true value is calculated, so as to obtain the loss value of the multi-feature fusion traffic flow prediction model. According to the loss value of the multi-feature fusion traffic flow prediction model, the multi-feature fusion traffic flow prediction model is repeatedly trained until the loss value of the multi-feature fusion traffic flow prediction model no longer decreases, and the short-term traffic flow prediction result is output;
[0036] Among them, the loss value of traffic flow is specifically expressed as:
[0037]
[0038] In the formula, Mv is the number of traffic flow samples, For the i The true value of traffic flow samples, For the i The predicted value of traffic flow samples, is the loss value of traffic flow.
[0039] Preferably, the loss value of the multi-feature fusion traffic flow prediction model is calculated by the following formula:
[0040]
[0041] In the formula, is the loss value of the multi-feature fusion traffic flow prediction model, are the weights of training occupancy, average speed and traffic flow, is the loss value of occupancy, is the average speed loss, is the loss value of traffic flow.
[0042] A short-term traffic flow prediction system based on multiple feature graphs, comprising:
[0043] A feature map construction module is used to obtain data on traffic flow, occupancy rate and average speed, and to construct a traffic flow feature map, an occupancy rate feature map and an average speed feature map;
[0044] A node feature information aggregation module is used to aggregate the node feature information of the traffic flow feature map, occupancy feature map and average speed feature map based on GCN;
[0045] The occupancy feature supervised learning training module is used to use the improved Transformer encoder to perform supervised learning training on the node feature information of the aggregated occupancy feature map to obtain the occupancy feature vector;
[0046] The average speed supervised learning training module is used to use the improved Transformer encoder to perform supervised learning training on the node feature information of the aggregated average speed feature map to obtain the average speed feature vector;
[0047] The model building module is used to interactively fuse the node feature information of the aggregated traffic flow feature graph with the occupancy feature vector and the average speed feature vector to build a multi-feature fusion traffic flow prediction module;
[0048] The traffic flow prediction module is used to predict short-term traffic flow based on the trained multi-feature fusion traffic flow prediction model.
[0049] Compared with the prior art, the present invention has the following beneficial technical effects:
[0050] The present invention provides a short-term traffic flow prediction method based on a multi-feature graph, wherein three data simultaneously collected by road sensors, including traffic flow, occupancy rate and average speed, are used to construct occupancy rate feature graphs, average speed feature graphs and traffic flow feature graphs respectively, and a graph convolutional network (full name in English: Graph Convolutional Network, GCN for short) is used to aggregate node feature information of the three feature graphs, and an improved Transformer encoder is used to implement supervised learning training of occupancy rate features and average speed features, and the obtained feature vectors of occupancy rate and average speed are used to implement feature interactive fusion in a multi-feature fusion traffic flow prediction model, and occupancy rate and average speed features are used to assist the multi-feature fusion traffic flow prediction model to better capture traffic flow features and provide more accurate traffic flow prediction; at the same time, the traffic flow feature graph constructed by the present invention not only contains spatial information, but also contains time series information, and by using the improved Transformer encoder, the multi-feature fusion traffic flow prediction model can capture the dynamic characteristics of traffic flow data changing over time. The present invention uses GCN to aggregate node feature information in the traffic flow feature graph, which helps the model learn the spatial correlation of traffic flow data, that is, the mutual influence between different sensors. Since there is an intrinsic correlation between traffic flow, occupancy and average speed, in the multi-feature fusion traffic flow prediction model, the traffic flow feature map is interactively fused with the occupancy feature vector and the average speed feature vector. This fusion helps the model to more comprehensively understand and predict changes in traffic flow; the traffic flow feature map helps to improve the generalization ability of the model, enabling it to make effective predictions under different traffic conditions and environments.
[0051] Furthermore, the traffic flow characteristic graph of the present invention uses the traffic flow data collected by the road sensor as the node feature information of the graph, and compares it with the occupancy characteristic graph and the average speed characteristic graph. Figure 1Together, they form a multi-feature graph structure, which allows the model to simultaneously consider the temporal and spatial characteristics of traffic flow data. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] Figure 1 A short-term traffic flow prediction flow chart based on a multi-feature graph of the present invention;
[0053] Figure 2 This is a structural diagram of a multi-feature fusion traffic flow prediction model of an embodiment;
[0054] Figure 3 For example t Flowchart of multi-feature graph construction at time steps;
[0055] Figure 4 It is a TCN model structure diagram of an embodiment;
[0056] Figure 5 is a diagram of the Cross Attention structure of an embodiment;
[0057] Figure 6 The three feature prediction result diagrams of the sensor on the PeMSD04 data set of the embodiment; wherein, Figure (a) is the traffic flow, Figure (b) is the occupancy rate, and Figure (c) is the average speed;
[0058] Figure 7 These are three feature prediction result diagrams of sensors on the PeMSD08 data set of the embodiment; wherein, Figure (a) is the traffic flow, Figure (b) is the occupancy rate, and Figure (c) is the average speed. DETAILED DESCRIPTION
[0059] The present invention is further described in detail below in conjunction with specific embodiments, which are intended to explain the present invention rather than to limit it.
[0060] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0061] A short-term traffic flow prediction method based on multi-feature graphs, such as Figure 1 As shown, including
[0062] S1. Obtain data on traffic flow, occupancy rate and average speed, and construct a traffic flow characteristic graph, an occupancy characteristic graph and an average speed characteristic graph, respectively. Specifically:
[0063] Traffic flow, occupancy rate and average speed data are collected through road sensors, and the data of traffic flow, occupancy rate and average speed are used as feature information of the graph respectively, and the map location information of the road sensor is used as the skeleton of the graph; wherein each road sensor is used as a node of the graph, and the relationship between roads on the map is used as the edge of the graph, so as to construct the traffic flow feature graph, occupancy feature graph and average speed feature graph respectively.
[0064] Among them, Figure 3 As shown in the figure, the graph construction tool uses the Deep Graph Library (DGL) tool. The detailed calculation process of the three feature graph structures is as follows:
[0065]
[0066] in, E is the edge of the graph, V t express t Traffic flow data at time step, O t express t Occupancy data for the time step, S t express t Data on the average velocity of the time step; is the traffic flow characteristic graph structure, is the occupancy feature map structure, It is the average speed feature map structure.
[0067] S2, node feature information based on GCN aggregated traffic flow feature map, occupancy feature map and average speed feature map, specifically:
[0068] Through GCN, the data of traffic flow feature map, occupancy feature map and average speed feature map are respectively combined with the corresponding t Traffic flow data at time step, t Occupancy data for the time step and t The average speed data of each time step is aggregated to extract the node feature information of the traffic flow feature map, occupancy feature map and average speed feature map.
[0069] S3. Use the improved Transformer encoder to perform supervised learning training on the node feature information of the aggregated occupancy feature map and the average speed feature map to obtain the occupancy feature vector and the average speed feature vector; the Transformer encoder is a neural network structure based on the self-attention mechanism;
[0070] Furthermore, the Transformer encoder in S3 is improved as follows:
[0071] The Transformer encoder structure is widely used in various fields of deep learning. It can effectively learn sequence information and capture key features. Therefore, the Transformer encoder is used as the sequence supervised learning training of the node feature information of the occupancy feature map and the average speed feature map.
[0072] In order to further effectively capture the dependencies between long time steps in the sequence, the Temporal Convolutional Network (TCN) model is used to replace the FeedForward layer of the Transformer encoder to obtain an improved Transformer encoder.
[0073] In order to avoid the loss of data information, multiple residual modules are designed in the TCN model, and each residual block contains two causal convolutions and dilated convolutions;
[0074] In order to overcome the limited field of view of traditional convolution kernels, causal convolution and dilated convolution are designed in the TCN model. Causal convolution only considers the past information of the TCN model to prevent the leakage of future information, while dilated convolution uses interval sampling on the basis of causal convolution, which enables the TCN model to have a larger perception field of view and the ability to capture long-distance dependencies.
[0075] like Figure 4 As shown, this is the structural diagram of the TCN model, where d is the sampling interval; causal convolution ensures that the previous layer t The data of the time step is only shared with the next layer t The data at each time step is related to the previous data, and the dilated convolution samples the data at intervals to capture the long-distance dependencies between the data;
[0076] The core calculation principle of the TCN model is as follows:
[0077]
[0078] In the formula, y(x) is the output result of the convolutional layer, x is the input sequence, t is the time step, w(i) For the i The weight matrix of the convolution kernel at each position, r represents the expansion rate and sampling interval, k is the size of the convolution kernel, is the interval between the elements in the convolution kernel and the corresponding elements in the input sequence in the dilated convolution, Conv1D(x) Indicates input x Perform a one-dimensional convolution operation; y Represents the output of the convolutional layer, which is the input x The result after convolution operation and activation function processing; ReLU ( y(x) ) represents the output result of the convolutional layer y(x) Apply the ReLU activation function; ReLU stands for Rectified Linear Unit, which is a commonly used activation function.
[0079] Furthermore, in S3, an improved Transformer encoder is used to perform supervised learning training on the node feature information of the aggregated occupancy feature map to obtain the occupancy feature vector, which is specifically:
[0080] The node feature information of the occupancy feature map is used as the input of the improved Transformer encoder. The node feature information of the occupancy feature map is encoded and converted based on the improved Transformer encoder through layer normalization and multi-head attention mechanism to obtain an occupancy feature vector. The occupancy feature vector is processed by a Softmax classifier to obtain a predicted value of the occupancy. The error between the predicted value and the true value of the occupancy is calculated using a log-likelihood function to obtain a loss value of the occupancy. Based on the loss value of the occupancy, the weights and biases of the improved Transformer encoder are repeatedly updated for supervised learning training until the loss value of the occupancy no longer decreases, and the occupancy feature vector after supervised learning training is output.
[0081] Among them, the specific calculation formula of the loss value of occupancy rate is:
[0082]
[0083] In the formula, Mo is the total number of occupancy samples, For the i The true value of the occupancy samples, For the i The predicted value of occupancy samples, is the loss value of occupancy rate.
[0084] The Softmax classifier is a classification model based on the Softmax function and is suitable for multi-classification problems.
[0085] In one preferred implementation, when using an improved Transformer encoder to perform supervised learning training on the node feature information of the aggregated occupancy feature map, layer normalization (Layer Norm), graph convolutional network (GCN), temporal convolutional network (TCN) and multi-head attention mechanism (full name in English: Multi-Head Attention, MHA for short) are used to process the supervised learning training process of the node feature information of the occupancy feature map, specifically:
[0086] GCN processing: Input t Occupancy characteristic data for the time step , use graph convolutional network GCN to process occupancy feature map G o and t Occupancy characteristic data for the time step , and obtain the intermediate feature of occupancy g o ;
[0087] MHA processing: the occupancy intermediate feature g o Input to the multi-head attention mechanism MHA, which processes the intermediate features of occupancy g o Interact with itself and output the attention-weighted occupancy feature ;
[0088] Layer normalization: weighted occupancy features Convolution with the original graph outputs the intermediate feature of occupancy g o Add them together and then process them through Layer Norm to get the normalized occupancy feature ;
[0089] TCN processing: occupancy features after layer normalization Input into TCN to obtain the occupancy feature after time feature processing ;
[0090] The final layer is normalized: the output of the temporal convolutional network is normalized And the normalized occupancy feature Add them together and normalize them again to get the occupancy feature vector ;
[0091] Layer Norm is a layer normalization technique used to stabilize the training process and accelerate convergence. It normalizes each input sample by subtracting the mean and dividing by the standard deviation. The entire process is a deep learning model that combines graph structure features and time series features, aiming to extract and learn the spatiotemporal features of occupancy data for effective supervised learning training.
[0092] The specific calculation process is as follows:
[0093]
[0094] In the formula, for t Occupancy feature data for the time step, Represented as a multi-head attention mechanism, Represents the hidden vector of occupancy output, Layer Norm is layer normalization, n is the number of sensors, h is the dimension of the hidden layer, represents a real matrix space, n and h are integers representing the number of rows and columns of the matrix, is the set of real numbers;
[0095] Furthermore, the improved Transformer encoder in S3 is used to perform supervised learning training on the node feature information of the aggregated average speed feature map, specifically:
[0096] The node feature information of the average speed feature map is used as the input of the improved Transformer encoder. The node feature information of the average speed feature map is encoded and converted based on the improved Transformer encoder through layer normalization and multi-head attention mechanism to obtain the average speed feature vector. The average speed feature vector is processed by the Softmax classifier to obtain the predicted value of the average speed. The error between the predicted value and the true value of the average speed is calculated using the log-likelihood function to obtain the loss value of the average speed. The weights and biases of the improved Transformer encoder are repeatedly updated based on the loss value of the average speed for supervised learning training until the loss value of the average speed no longer decreases, and the average speed feature vector after supervised learning training is output.
[0097] Among them, the specific calculation formula of the average speed loss value is:
[0098]
[0099] In the formula, Ms is the total number of average speed samples, For the iThe true value of the average speed samples, For the i The predicted value of the average speed samples, is the average speed loss value.
[0100] In one preferred implementation, the process of supervised learning training of the average speed feature vector is specifically as follows:
[0101] GCN processing: Input t Average velocity characteristic data of the time step S t , use graph convolutional network GCN to process the average speed feature map G s and t Average velocity characteristic data of the time step S t , get the average speed intermediate feature g s ;
[0102] Improved Transformer encoder processing: average speed intermediate features g s The input is sent to the improved Transformer encoder, which uses layer normalization and multi-head attention mechanism to average speed intermediate features. g s Encode and transform to obtain the average speed feature vector S i .
[0103] Softmax function processing: Use the softmax function to process the average speed feature vector S i Processing is performed to obtain the probability distribution of each average speed feature vector sample ; The softmax function converts the average speed feature vector S i Each element of is converted into a probability value, so that the sum of the probability values of all elements is 1.
[0104] In this process, the Transformer encoder is responsible for capturing the sequence information and long-distance dependencies in the average speed feature vector, while the softmax function converts the output of the Transformer encoder into a probability distribution for classification tasks;
[0105] The average speed feature vector is trained through supervised learning, and the calculation process is as follows:
[0106]
[0107] Where:S t for t The average velocity characteristic data of the time step, G s is the average speed characteristic diagram, g s is the average speed intermediate characteristic, S i is the average velocity eigenvector, For the i The probability distribution of the average velocity feature vector samples;
[0108] S4. Perform feature interaction fusion between the node feature information of the aggregated traffic flow feature graph and the occupancy feature vector and the average speed feature vector to obtain multi-feature fusion traffic flow data and construct a multi-feature fusion traffic flow prediction model, specifically:
[0109] The cross attention mechanism is used to replace the self-attention mechanism in the improved Transformer encoder. The node feature information of the aggregated traffic flow feature graph is fused with the occupancy feature vector and the average speed feature vector after supervised training as the input of the cross attention mechanism. After splicing the fusion results, multi-feature fusion traffic flow data is extracted. Based on the multi-feature fusion traffic flow data, a multi-feature fusion traffic flow prediction model is constructed.
[0110] Among them, Cross Attention is used to replace the Self-Attention in the improved Transformer encoder, such as Figure 5 As shown, specifically:
[0111] The calculation principle of Cross Attention is similar to that of Self-Attention. Self-Attention uses the same data to calculate the Query value, Key value, and Value value respectively, while Cross Attention uses data A as the Query value and data B as the Key and Value values respectively, thereby realizing the relevant information query of data A on data B; data A represents the average speed feature vector S i , data B represents the occupancy feature vector ;
[0112] Among them, the detailed calculation process of Cross Attention is as follows:
[0113]
[0114]
[0115] Where: Represents the initial weight matrices of Query value, Key value and Value value respectively; is the calculated query-related hidden vector; is the dimension of the key vector; is the dimension of the key vector The square root of , used to scale the dot product; X a Represents data A, which serves as the basis for calculating the Query value; X b Represents data B, which serves as the basis for calculating Key and Value values; K b for Key vector; V b for Value vector; express Key vector K b The transpose of
[0116] Indicates that by X a and Query weight matrix The query vector obtained by multiplication;
[0117] Indicates that by X b and Key weight matrix The Key vector obtained by multiplication;
[0118] Indicates that by X b and Value weight matrix The Value vector obtained by multiplication;
[0119] Among them, the node feature information of the aggregated traffic flow feature graph is fused with the occupancy feature vector and the average speed feature vector after supervised training as the input of the cross attention mechanism. After the fusion results are spliced, the multi-feature fusion traffic flow data is extracted. Based on the multi-feature fusion traffic flow data, a multi-feature fusion traffic flow prediction model is constructed. The specific process is as follows:
[0120] Calculate occupancy features through Cross Attention: Input occupancy feature vector O iand node characteristic information of traffic flow characteristic graph V i ; The occupancy feature vector O i As Key value and Value value; the relationship between traffic flow characteristics and occupancy characteristics is integrated through the Cross Attention mechanism, the traffic flow information related to occupancy is extracted, and the occupancy characteristics of the cross attention output are calculated. ;
[0121] Calculate the average speed feature through Cross Attention: Input the average speed feature vector S i and node characteristic information of traffic flow characteristic graph V i ; The average velocity eigenvector S i As the query value; the relationship between traffic flow characteristics and average speed characteristics is integrated through the Cross Attention mechanism, the traffic flow information related to the average speed is extracted, and the average speed characteristics of the cross attention output are calculated ;
[0122] Concat: combine the occupancy features of the cross-attention output and the average speed characteristics of the cross-attention output The feature information of is combined through Concat to obtain the multi-feature fusion feature vector H v ; Concat is the abbreviation of concatenat, which means connection or series connection;
[0123] Layer normalization: The fusion feature vector H v Node feature information of the original traffic flow feature graph V i Add them together, and then normalize them layer by layer to get the multi-feature fusion feature vector after layer normalization. ; Layer normalization helps stabilize the training process and reduce internal covariate shift;
[0124] TCN processing: multi-feature fusion feature vector after layer normalization , input into TCN, and get the output of TCN, where TCN can capture the long-distance dependencies in time series data;
[0125] Final layer normalization: The output of TCN is combined with the multi-feature fusion feature vector after layer normalization. Add them together and normalize them again to get the output feature vector of multi-feature fusion.h v ; Output feature vector through multi-feature fusion h v , extract the multi-feature fusion traffic flow data processed by the cross attention mechanism and TCN, and then build a multi-feature fusion traffic flow prediction model;
[0126] The detailed calculation process is as follows:
[0127]
[0128] Where: Concat represents the concatenation operation of tensors, is layer normalization, Cross Attention is the cross attention mechanism, Occupancy features for cross-attention output; is the average speed feature of the cross-attention output; V i It is the node characteristic information of the traffic flow characteristic graph; O i is the occupancy feature vector, S i is the average velocity eigenvector, Hv is the multi-feature fusion feature vector, It is the multi-feature fusion feature vector after layer normalization; h v is the output feature vector of multi-feature fusion;
[0129] The output of the occupancy feature calculated by the Cross Attention mechanism represents the traffic flow feature V i and the occupancy feature vector O i The interactive information between is the output of the average speed feature calculated by the Cross Attention mechanism, which represents the traffic flow feature V i and the average velocity eigenvector S i The interactive information between Hv Contains the interactive information of occupancy rate characteristics, average speed characteristics and traffic flow characteristics; is the multi-feature fusion feature vector Hv and traffic flow characteristics V i combination of; h v After TCN processing and layer normalization again The result is expressed as the feature representation of traffic flow prediction with multi-feature fusion integrating time series information;
[0130] The entire calculation process realizes the deep fusion of three feature data, namely traffic flow, occupancy rate and average speed, through the cross-attention mechanism and temporal convolutional network, so as to improve the accuracy and robustness of traffic flow prediction of the multi-feature fusion traffic flow prediction model.
[0131] S5. Train the multi-feature fusion traffic flow prediction model, and use the trained multi-feature fusion traffic flow prediction model to predict short-term traffic flow, specifically:
[0132] The loss value of occupancy rate, the loss value of average speed and the loss value of traffic flow are jointly trained by multi-task joint learning, and the error between the predicted value of short-term traffic flow of multi-feature fusion output by the multi-feature fusion traffic flow prediction model and the true value is calculated, so as to obtain the loss value of the multi-feature fusion traffic flow prediction model. According to the loss value of the multi-feature fusion traffic flow prediction model, the multi-feature fusion traffic flow prediction model is repeatedly trained until the loss value of the multi-feature fusion traffic flow prediction model no longer decreases, and the short-term traffic flow prediction result is output;
[0133] The calculation process of the loss value of the multi-feature fusion traffic flow prediction model is as follows:
[0134]
[0135] In the formula, is the loss value of the multi-feature fusion traffic flow prediction model, are the weights of training occupancy, average speed and traffic flow, is the loss value of the occupancy feature vector, is the loss value of the average velocity feature vector, is the loss value of traffic flow characteristics;
[0136] Among them, the loss value of traffic flow , specifically expressed as:
[0137]
[0138] In the formula, Mv is the number of traffic flow samples, For the i The true value of traffic flow samples, For the i The predicted value of traffic flow samples, is the loss value of traffic flow.
[0139] A short-term traffic flow prediction system based on multi-feature graphs, such as Figure 2 As shown, including
[0140] A feature map construction module is used to obtain data on traffic flow, occupancy rate and average speed, and to construct a traffic flow feature map, an occupancy rate feature map and an average speed feature map;
[0141] A node feature information aggregation module is used to aggregate the node feature information of the traffic flow feature map, occupancy feature map and average speed feature map based on GCN;
[0142] The occupancy feature supervised learning training module is used to use the improved Transformer encoder to perform supervised learning training on the node feature information of the aggregated occupancy feature map to obtain the occupancy feature vector;
[0143] The average speed supervised learning training module is used to use the improved Transformer encoder to perform supervised learning training on the node feature information of the aggregated average speed feature map to obtain the average speed feature vector;
[0144] A multi-feature fusion traffic flow prediction model construction module is used to interactively fuse the node feature information of the aggregated traffic flow feature graph with the occupancy feature vector and the average speed feature vector to construct a multi-feature fusion traffic flow prediction module;
[0145] The multi-feature fusion traffic flow prediction module is used to predict short-term traffic flow based on the trained multi-feature fusion traffic flow prediction model.
[0146] In order to verify the performance of the multi-feature fusion traffic flow prediction model in traffic flow prediction, the experiment uses PeMSD04 and PeMSD08 as benchmark data sets. The PeMSD04 data set comes from the public data collected by the traffic monitoring system in California, recording the traffic flow data of four regions in the state, including 16,992 time steps and 307 sensors, each sensor can collect three feature data: traffic flow, occupancy rate and average speed. The PeMSD08 data set also comes from the traffic monitoring system in California, recording the traffic flow data of 8 regions in the state. The data set includes 17,856 time steps of 170 sensors, and each sensor includes three features: traffic flow, occupancy rate and average speed. The present invention divides the data set into training set, test set and validation set in a ratio of 6:2:2 for experiment.
[0147] Traffic flow prediction is a spatiotemporal series prediction task. Therefore, the mean absolute error (MAE), root mean square error (RMSE) and mean absolute percentage error (MAPE) are used to measure the traffic flow prediction performance of the multi-feature fusion traffic flow prediction model.
[0148] The details of the baseline model used in the experiment are as follows:
[0149] (1) GRU (Gated Recurrent Unit) model: The GRU model is used to achieve traffic flow prediction;
[0150] (2) DCRNN (Dilated Convolutional Recurrent Neural Network) model: Improved on the RNN model, combined with diffuse causal convolution to capture long-distance dependencies;
[0151] (3) ASTGCN (Attention Based Spatial-Temporal Graph Convolutional Network) model: A convolutional neural network based on the attention mechanism learns the spatial features of data;
[0152] (4) STGOD (Spatial-Temporal Graph-based OrdinaryDifferential Equation Network) model: improves the GCN model structure to expand the model's perception of spatiotemporal features;
[0153] (5) AGCRN (Adaptive Graph Convolutional Recurrent Network) model: Designs an adaptive graph convolution module to selectively learn traffic flow data;
[0154] (6) STSGC (Spatial-Temporal Synchronous Graph Convolution Network) model: It combines graph convolutional neural network and one-dimensional temporal convolution to learn the local spatiotemporal features of traffic data respectively;
[0155] (7) STFGNN (Spatial-Temporal Fusion Graph Neural Network) model: constructs multiple spatiotemporal graphs for traffic flow data and learns spatiotemporal features through graph fusion;
[0156] (8) STG-NCDE (Spatial-Temporal Graph Neural Controlled Differential Equations) model: It uses two independent neural network structures to learn the temporal and spatial characteristics of data respectively.
[0157] (9) STCGAT (Spatial-Temporal Causal Graph Attention Network) model: Improved spatiotemporal graph convolutional network that adaptively learns local and global features of data.
[0158] In order to verify the overall performance of the multi-feature fusion traffic flow prediction model on two public datasets, the comparative experimental results are shown in Table 1. From the comparative analysis in Table 1, it can be seen that the multi-feature fusion traffic flow prediction model achieved 18.27%, 30.45% and 11.62% in the three evaluation indicators of MAE, RMSE and MAPE on the PeMSD04 dataset, and achieved 16.65%, 25.38% and 10.25% in the three evaluation indicators of MAE, RMSE and MAPE on the PeMSD08 dataset. The overall performance of the multi-feature fusion traffic flow prediction model is significantly better than the baseline model. Among the baseline models, the STCGAT model has the best performance. The MAE, RMSE and MAPE of the STCGAT model on the PeMSD04 dataset are reduced by 1.23%, 1.16% and 1.16% respectively, while the MAE, RMSE and MAPE on the PeMSD04 dataset are reduced by 2.11%, 1.73% and 1.76% respectively. The reason is that the STCGAT model can adaptively learn the local and global features of traffic flow data, but the model only considers the learning of traffic flow data features, while ignoring the vehicle occupancy rate and average speed data collected by sensors, lacking comprehensive modeling of road traffic condition information. The multi-feature fusion traffic flow prediction model of the present invention not only considers the learning of traffic flow feature data, but also introduces the feature data of occupancy rate and average speed, fully learning the three feature data and building the connection between the data to better realize traffic flow prediction.
[0159] Table 1 shows the comparative experimental results (unit: %)
[0160]
[0161] In order to demonstrate the prediction performance of the multi-feature fusion traffic flow prediction model, three feature data predictions were performed on two data sets. The experimental results are as follows: Figure 6 and Figure 7 As shown in the figure, from the observation analysis, it can be seen that there is a certain correlation between the three characteristics of traffic flow, occupancy rate and average speed. When the traffic volume on the road begins to increase, the occupancy rate on the road will have a significant upward trend. At the same time, the average speed of the vehicle also has a significant downward trend. This shows that the three feature data collected by the road sensors of the multi-feature fusion traffic flow prediction model can better realize the comprehensive modeling of road conditions.
[0162] The above description is only a preferred embodiment of the present invention and does not limit the present invention in any form. Any ordinary technician in the industry can smoothly implement the present invention as shown in the drawings and described above. However, any equivalent changes, modifications and evolutions made by technicians familiar with the profession without departing from the scope of the technical solution of the present invention using the technical content disclosed above are all equivalent embodiments of the present invention. At the same time, any equivalent changes, modifications and evolutions made to the above embodiments based on the essential technology of the present invention are still within the protection scope of the technical solution of the present invention.
Claims
1. A short-term traffic flow prediction method based on multi-feature graphs, characterized in that: include: Obtain data on traffic flow, occupancy rate and average speed, and construct a traffic flow characteristic graph, an occupancy rate characteristic graph and an average speed characteristic graph respectively; Node feature information based on GCN aggregated traffic flow feature map, occupancy feature map and average speed feature map; The improved Transformer encoder is used to perform supervised learning training on the node feature information of the aggregated occupancy feature map and the average speed feature map to obtain the occupancy feature vector and the average speed feature vector. The node feature information of the aggregated traffic flow feature graph is interactively fused with the occupancy feature vector and the average speed feature vector to construct a multi-feature fusion traffic flow prediction model. Train the multi-feature fusion traffic flow prediction model, and make short-term traffic flow prediction based on the trained multi-feature fusion traffic flow prediction model; Obtain the data of traffic flow, occupancy rate and average speed, and construct the traffic flow characteristic graph, occupancy rate characteristic graph and average speed characteristic graph respectively, as follows: Traffic flow, occupancy and average speed data are collected through road sensors and the data are used as feature information of the graph respectively. The map location information of the road sensor is used as the skeleton of the graph, each road sensor is used as a node of the graph, and the relationship between roads on the map is used as the edge of the graph, so as to construct a traffic flow feature graph, an occupancy feature graph and an average speed feature graph respectively.
2. The short-term traffic flow prediction method based on multi-feature graph according to claim 1 is characterized in that: The node feature information based on the GCN aggregated traffic flow feature map, occupancy feature map and average speed feature map is as follows: Through GCN, the data of traffic flow feature map, occupancy feature map and average speed feature map are respectively combined with the corresponding t Traffic flow data at time step, t Occupancy data for the time step and t The average speed data of each time step is aggregated to extract the node feature information of the traffic flow feature map, occupancy feature map and average speed feature map.
3. The short-term traffic flow prediction method based on multi-feature graph according to claim 1 is characterized in that: The improvement of Transformer encoder is as follows: Use the TCN model to replace the Feed Forward layer of the Transformer encoder to improve the Transformer encoder; Among them, the TCN model includes multiple residual modules, and each residual module includes dilated convolution and causal convolution.
4. The short-term traffic flow prediction method based on multi-feature graph according to claim 1 is characterized in that: The improved Transformer encoder is used to perform supervised learning training on the node feature information of the aggregated occupancy feature map to obtain the occupancy feature vector, which is: The node feature information of the occupancy feature map is used as the input of the improved Transformer encoder. The node feature information of the occupancy feature map is encoded and converted based on the improved Transformer encoder through layer normalization and multi-head attention mechanism to obtain an occupancy feature vector. The occupancy feature vector is processed by a Softmax classifier to obtain a predicted value of the occupancy. The error between the predicted value and the true value of the occupancy is calculated using a log-likelihood function to obtain a loss value of the occupancy. Based on the loss value of the occupancy, the weights and biases of the improved Transformer encoder are repeatedly updated for supervised learning training until the loss value of the occupancy no longer decreases, and the occupancy feature vector after supervised learning training is output. Among them, the loss value of occupancy rate is calculated by the following formula: In the formula, Mo is the total number of occupancy samples, For the i The true value of the occupancy samples, For the i The predicted value of occupancy samples, is the loss value of occupancy rate.
5. The short-term traffic flow prediction method based on multi-feature graph according to claim 4 is characterized in that: The improved Transformer encoder is used to perform supervised learning training on the node feature information of the aggregated average speed feature map to obtain the average speed feature vector, which is: The node feature information of the average speed feature map is used as the input of the improved Transformer encoder. The node feature information of the average speed feature map is encoded and converted based on the improved Transformer encoder through layer normalization and multi-head attention mechanism to obtain the average speed feature vector. The average speed feature vector is processed by the Softmax classifier to obtain the predicted value of the average speed. The error between the predicted value and the true value of the average speed is calculated using the log-likelihood function to obtain the loss value of the average speed. The weights and biases of the improved Transformer encoder are repeatedly updated based on the loss value of the average speed for supervised learning training until the loss value of the average speed no longer decreases, and the average speed feature vector after supervised learning training is output. Among them, the loss value of the average speed is calculated by the following formula: In the formula, Ms is the total number of average speed samples, For the i The true value of the average speed samples, For the i The predicted value of the average speed samples, is the average speed loss value.
6. The short-term traffic flow prediction method based on multi-feature graph according to claim 5 is characterized in that: The node feature information of the aggregated traffic flow feature graph is interactively fused with the occupancy feature vector and the average speed feature vector to construct a multi-feature fusion traffic flow prediction model, specifically: The cross-attention mechanism is used to replace the self-attention mechanism in the improved Transformer encoder. The node feature information of the aggregated traffic flow feature graph is fused with the occupancy feature vector and the average speed feature vector after supervised training as the input of the cross-attention mechanism in the improved Transformer encoder. After splicing the fusion results, multi-feature fusion traffic flow data is extracted to construct a multi-feature fusion traffic flow prediction model.
7. The short-term traffic flow prediction method based on multi-feature graph according to claim 6 is characterized in that: The multi-feature fusion traffic flow prediction model is trained, and short-term traffic flow prediction is performed based on the trained multi-feature fusion traffic flow prediction model. Specifically: The loss value of occupancy rate, the loss value of average speed and the loss value of traffic flow are jointly trained by multi-task joint learning, and the error between the predicted value of short-term traffic flow of multi-feature fusion output by the multi-feature fusion traffic flow prediction model and the true value is calculated, so as to obtain the loss value of the multi-feature fusion traffic flow prediction model. According to the loss value of the multi-feature fusion traffic flow prediction model, the multi-feature fusion traffic flow prediction model is repeatedly trained until the loss value of the multi-feature fusion traffic flow prediction model no longer decreases, and the short-term traffic flow prediction result is output; Among them, the loss value of traffic flow is specifically expressed as: In the formula, Mv is the number of traffic flow samples, For the i The true value of traffic flow samples, For the i The predicted value of traffic flow samples, is the loss value of traffic flow.
8. The short-term traffic flow prediction method based on multi-feature graph according to claim 7 is characterized in that: The loss value of the multi-feature fusion traffic flow prediction model is calculated as follows: In the formula, is the loss value of the multi-feature fusion traffic flow prediction model, are the weights of training occupancy, average speed and traffic flow, respectively. is the loss value of occupancy, is the average speed loss, is the loss value of traffic flow.
9. A short-term traffic flow prediction system based on a multi-feature graph, based on a short-term traffic flow prediction method based on a multi-feature graph according to any one of claims 1 to 8, characterized in that: include: A feature map construction module is used to obtain data on traffic flow, occupancy rate and average speed, and to construct a traffic flow feature map, an occupancy rate feature map and an average speed feature map; A node feature information aggregation module is used to aggregate the node feature information of the traffic flow feature map, occupancy feature map and average speed feature map based on GCN; The occupancy feature supervised learning training module is used to use the improved Transformer encoder to perform supervised learning training on the node feature information of the aggregated occupancy feature map to obtain the occupancy feature vector; The average speed supervised learning training module is used to use the improved Transformer encoder to perform supervised learning training on the node feature information of the aggregated average speed feature map to obtain the average speed feature vector; The model building module is used to interactively fuse the node feature information of the aggregated traffic flow feature graph with the occupancy feature vector and the average speed feature vector to build a multi-feature fusion traffic flow prediction module; The traffic flow prediction module is used to predict short-term traffic flow based on the trained multi-feature fusion traffic flow prediction model.
Citation Information
Patent Citations
Multi-element traffic flow prediction method based on graph network
CN114743374A