Traffic flow prediction method and traffic flow prediction system
By introducing a delay-aware converter based on mileage matrix in traffic flow prediction, the problem of low traffic flow prediction accuracy at overpass stations is solved, and higher prediction accuracy and better adaptability are achieved.
Patent Information
- Application Number
- CN202410813731.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-21
- Publication Date
- 2025-04-29
- Estimated Expiration
- 2044-06-21
AI Technical Summary
The prior art has low accuracy in traffic flow prediction at sites, especially interchange sites, and it is difficult to effectively capture complex traffic patterns and spatial relationships.
A traffic flow prediction method based on a mileage matrix is proposed. By acquiring historical traffic flow data and spatial position data, preprocessing and feature extraction, the delay-aware feature extraction model is constructed by fusing the mileage matrix, delay-aware feature data is obtained, and prediction is made through convolution.
It significantly improves the traffic flow prediction accuracy in interchange scenarios, can effectively capture complex traffic flow dynamics, enhances the generalization ability and adaptability of the model, and ensures computing efficiency.
Smart Images

Figure CN118673273B_ABST
Abstract
Description
Background Art
[0002] Traffic flow prediction is an indispensable part of traffic management and intelligent transportation systems. The accurate traffic flow prediction information it provides helps traffic managers to predict congestion and emergency times, and helps to relieve congestion and control highway ramps. As a kind of time series data, early studies used variable autoregression model (VAR) and autoregressive difference moving average model (ARIMA) to capture the periodicity and seasonality of traffic data and achieve short-term prediction of data. With the successful application of deep learning technology in many fields, its potential in traffic flow prediction has been explored by more and more research. In particular, deep learning methods based on recurrent neural network (RNN), convolutional neural network (CNN), graph neural network (GNN) and attention mechanism have shown unique advantages in processing traffic data. Recurrent neural network (RNN) has become a common tool for traffic flow prediction due to its natural advantages in processing time series data. RNN captures the dependencies in time series through recurrent connections, enabling the model to remember and use historical information to predict future traffic. However, RNN has limitations in dealing with long-term dependency problems, but it is still effective in short-term traffic flow prediction. Although originally designed for image processing, convolutional neural networks (CNNs) also show excellent performance in processing time series data due to their powerful spatial feature extraction capabilities. In traffic flow prediction, CNN effectively captures the spatial characteristics of traffic data by identifying traffic distribution patterns between different locations. This is particularly important for understanding traffic changes in urban traffic networks. Graph neural networks (GNNs) and graph convolutional networks (GCNs) are designed for graph-structured data, and they can learn directly on the graph structure of traffic networks. By analyzing the interactions between road nodes, GNNs and GCNs are particularly valuable in traffic flow prediction, and can accurately capture the propagation and change patterns of traffic flow throughout the network. With the widespread application of attention mechanisms in natural language processing and computer vision, their application in traffic flow prediction has also gradually increased. The attention mechanism enhances the modeling ability of temporal dependency and spatial correlation of traffic flow data by giving the model the ability to focus on the most important parts of the data, thereby improving the prediction accuracy.
[0003] Interchanges have complex road topology and station spatial relationships, as well as special and complex traffic patterns. Existing methods that only target general highway scenarios are difficult to achieve high-precision predictions when directly applied to highway interchange data. Summary of the invention
[0004] In order to solve the above-mentioned problem in the prior art, namely, the problem of low accuracy of traffic flow prediction at sites (especially interchange sites), the present disclosure proposes a traffic flow prediction method based on a delay-aware converter of a mileage matrix.
[0005] According to a first aspect of the present disclosure, a traffic flow prediction method is provided, which includes: obtaining historical traffic flow data and spatial location data of a station to be predicted; preprocessing and feature extraction of the historical traffic flow data and spatial location data to obtain processed data and feature data; fusing the mileage matrix of the station to be predicted to construct a delay-aware feature extraction model; based on the processed data and feature data, obtaining delay interaction feature data through the delay-aware feature extraction model; and convolving the delay interaction feature data to obtain the traffic flow of the station to be predicted in the next time window.
[0006] According to an embodiment of the present disclosure, a delay-aware feature extraction model is trained using training data in processed data, and the delay-aware extraction model may include: an input coding layer, for encoding input data to output coded data; a temporal attention layer, for obtaining time series feature data based on the coded data output by the input coding layer; a cross-correlation layer; for obtaining first component feature data and second component feature data based on the output coded data and the time series feature data, each of the first component feature data and the second component feature data reflecting the delayed traffic pattern and spatial characteristics between each station; a fusion attention layer, a fusion attention mechanism for fusing the first component feature data, the second component feature data and the time series feature data to obtain delay interaction feature data.
[0007] According to an embodiment of the present disclosure, the step of obtaining delay interaction feature data through a delay-aware feature extraction model based on processing data and feature data may include: performing a linear transformation on at least a portion of the data in the processing data and feature data other than training data to obtain high-level temporal feature data, first feature data, and second feature data, the first feature data and the second feature data respectively corresponding to different components in at least a portion of the data; processing the high-level temporal feature data using a temporal attention algorithm to obtain hidden coding data; performing a delay-aware cross-correlation operation on the sum of the hidden coding data and the first feature data to obtain first component feature data; performing a delay-aware cross-correlation operation on the sum of the hidden coding data and the second feature data to obtain second component feature data; and fusing the first component feature data, the second component feature data, and the hidden coding data using a fusion attention mechanism to obtain delay interaction feature data.
[0008] According to an embodiment of the present disclosure, the formula of the internal conversion function of the fusion attention mechanism to fuse the first component feature data, the second component feature data and the hidden coding data can be expressed as:
[0009] E f =Z tem +Z season +Ztrend
[0010]
[0011] Among them, Z season , Z trend , Z tem Respectively represent the first component feature data, the second component feature data and the hidden code data, Q f , K f , V f The superposition result E of the first component feature data, the second component feature data and the hidden coding data is represented by f The Q value, K value and V value in the attention mechanism obtained by linear transformation, Z f represents the delayed interaction feature data after fusion, D head represents the dimension of the attention head, Softmax and Mask represent the normalization function and mask function respectively, and FFN represents a simple feedforward neural network.
[0012] According to an embodiment of the present disclosure, the step of obtaining historical traffic flow data and spatial location data of the site to be predicted may include: obtaining traffic flow data of each node at each time in the road network diagram including the site to be predicted and constructing the road network diagram, and the spatial location data includes the absolute mileage data of the site to be predicted.
[0013] According to an embodiment of the present disclosure, the step of preprocessing and feature extracting historical traffic flow data and spatial location data to obtain processed data and feature data may include at least one of the following steps: denoising, normalizing and linear interpolation completion of historical traffic flow data; calculating the average value of the traffic flow per unit time of each station based on the historical traffic flow data, and then using the DTW algorithm to calculate the distance between each pair of nodes to construct a DTW distance matrix between nodes; based on the mileage information of the station to be predicted, calculating the mileage distance between the station to be predicted and other stations to construct a spatial adjacency matrix, and introducing a mask for distinguishing the types of stations; designing a temporal coding dictionary containing weekly coding and daily coding to effectively capture daily periodic features and weekly periodic features from historical traffic flow data; decomposing the historical traffic flow data into first component data and second component data different from the first component data.
[0014] According to an embodiment of the present disclosure, in the process of obtaining delay interaction feature data, delay-aware cross-correlation operations are respectively performed using first feature data obtained based on first component data and second feature data obtained based on second component data to obtain different component feature data reflecting the delayed traffic patterns and spatial characteristics between various sites, wherein the site to be predicted is an overpass site to be predicted.
[0015] According to a second aspect of the present disclosure, a traffic flow prediction system is provided, which includes: a data acquisition module, which acquires historical traffic flow data and spatial position data of a site to be predicted; a data preprocessing module, which preprocesses and extracts features from the historical traffic flow data and spatial position data to obtain processed data and feature data; a mileage matrix fusion module, which fuses the mileage matrix of the site to be predicted to construct a delay-aware feature extraction model; a delay-aware feature extraction module, which acquires delay interaction feature data through the delay-aware feature extraction model based on the processed data and feature data; and a prediction module, which convolves the delay interaction feature data to obtain the traffic flow of the site to be predicted in the next time window.
[0016] According to a third aspect of the present disclosure, a computer-readable storage medium is provided, which stores a computer program or code. When the computer program or code is loaded and executed by a processor, it prompts the processor to execute the above-mentioned traffic flow prediction method.
[0017] According to a fourth aspect of the present disclosure, a computing device is provided, comprising a processor and a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program or code, and when the computer program or code is loaded and executed by the processor, the processor is prompted to execute the above-mentioned traffic flow prediction method.
[0018] Beneficial Effects
[0019] The traffic flow prediction method disclosed in the present invention performs well in various scenarios, and can especially improve the prediction effect of interchange scenarios.
[0020] The traffic flow prediction method disclosed in this paper performs significantly better than traditional methods and other advanced models in the prediction of interchange scenarios, especially in the data set with dense complex interchange scenarios. This shows that the traffic flow prediction method disclosed in this paper can effectively capture the complex traffic flow dynamics in the interchange scenario and greatly improve the accuracy of traffic flow prediction in the interchange scenario.
[0021] According to the embodiments of the present disclosure, the key role of the delayed cross-correlation module is verified through ablation experiments, demonstrating the powerful generalization ability and adaptability of the traffic flow prediction method of the present disclosure.
[0022] While ensuring prediction accuracy, the traffic flow prediction method disclosed in the present invention also takes into account computational efficiency, making it suitable for real-time or near real-time traffic flow prediction applications.
[0023] Furthermore, the traffic flow prediction method disclosed in the present invention demonstrates its advanced nature and practical value in the field of traffic flow prediction in terms of flexibility in parameter adjustment, comparative advantages over existing technologies, and in-depth insights provided through visual analysis. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] Other features, objects and advantages of the present application will become more apparent by reading the detailed description of non-limiting embodiments made with reference to the following drawings.
[0025] Figure 1 is a flow chart of a traffic flow prediction method according to an embodiment of the present disclosure;
[0026] Figure 2 is a flowchart of the steps of acquiring delayed interaction feature data according to an embodiment of the present disclosure;
[0027] Figure 3 is a flow chart of preprocessing and feature extraction steps according to an embodiment of the present disclosure;
[0028] Figure 4 is a structural diagram of a delay-aware feature extraction model according to an embodiment of the present disclosure;
[0029] Figure 5 is a delayed cross-correlation structure diagram according to an embodiment of the present disclosure;
[0030] Figure 6 is a diagram of a cross-delayed aggregation structure according to an embodiment of the present disclosure;
[0031] Figure 7 A traffic flow prediction system according to an embodiment of the present disclosure. DETAILED DESCRIPTION
[0032] The following detailed description is provided to help gain a comprehensive understanding of the methods, devices and / or systems described herein. However, the order of operations described herein is only an example and is not limited to those orders set forth herein, but may be equivalently replaced or changed except for operations that must occur or be performed in a specific order. In addition, for greater clarity and simplicity, the description of content known in the art will be omitted or simplified.
[0033] Unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as those generally understood by a person of ordinary skill in the art to which the present disclosure belongs after understanding the present disclosure. Unless explicitly defined as such herein, terms (such as those defined in a general dictionary) should be interpreted as having a meaning consistent with their meaning in the context of the relevant art and the present disclosure, and should not be interpreted in an idealized or overly formal manner.
[0034] Unless otherwise specified, the same reference numerals generally refer to the same elements (e.g., components, steps, and methods). Reference numerals described in the previous embodiments may be omitted if they appear again in the subsequent embodiments. In addition, the technical features described in different or the same embodiments may be combined in any manner, as long as the combined embodiments or technical solutions are complete and can solve the technical problems of the present application or achieve the technical effects described or not described in the present disclosure but can be determined based on the above complete technical solutions. The terms used in the present disclosure are explained below.
[0035] It should be noted that, in the absence of conflicts between the various embodiments, these embodiments and their features may be combined with each other.
[0036] Aiming at the difficulty of traffic flow prediction at sites (especially interchange sites), the present disclosure proposes a delay-aware converter based on mileage matrix. Specifically, high-precision prediction of site traffic flow can be achieved through input feature encoding module, time attention module, delay-aware cross-correlation module and convolution prediction module, which will be described below in conjunction with the specific embodiments of the present disclosure.
[0037] Figure 1 is a flow chart of a traffic flow prediction method according to an embodiment of the present disclosure, Figure 2 is a flowchart of the steps of acquiring delayed interaction feature data according to an embodiment of the present disclosure, Figure 3 is a flowchart of the preprocessing and feature extraction steps according to an embodiment of the present disclosure, Figure 4 is a structural diagram of a delay-aware feature extraction model according to an embodiment of the present disclosure, Figure 5 is a delayed cross-correlation structure diagram according to an embodiment of the present disclosure, Figure 6 is a diagram of a cross-delay aggregation structure according to an embodiment of the present disclosure.
[0038] Reference Figure 1 , the traffic flow prediction method according to an embodiment of the present disclosure may include step S110, step S120, step S130, step S140 and step S150.
[0039] In step S110, the historical traffic flow data and spatial location data of the site to be predicted are obtained. The step of obtaining the historical traffic flow data and spatial location data of the site to be predicted includes: obtaining the traffic flow data of each node in the road network diagram including the site to be predicted at each time and constructing the road network diagram, and the spatial location data includes the absolute mileage data of the site to be predicted (that is, the mileage data from the site to be predicted to other sites). The historical traffic flow data here may include vehicle flow data, vehicle speed, etc. The historical traffic flow data and spatial location data can be obtained from the transportation department.
[0040] The road network graph here may refer to a road network graph including the site to be predicted.
[0041] Specifically, the road network graph can be represented as Includes nodes, edges, and an adjacency matrix that represents spatial relationships.
[0042] The node definition is as follows: node collection The road network includes all the locations, stations or nodes that can be monitored, and each node or station corresponds to a traffic flow sensor. For example, in a specific embodiment, if the predetermined road network includes 1350 traffic flow sensors, then It includes 1350 nodes (or sites), at least one of which may be an interchange site, and each node represents a monitoring point on the road.
[0043] Edge definition: The edge set ε represents the physical connection relationship or logical relationship between nodes. In practical applications, edges can be defined based on the actual connection of roads (such as direct road connection) or the correlation of traffic flow (such as the similarity of traffic flow). For example, if the sensors of two nodes monitor adjacent road segments, there is an edge between the two nodes.
[0044] The adjacency matrix is defined as follows: Describes the edge set The connection relationship between the nodes. The elements in the matrix Indicates the connection strength between node i and node j. The connection strength can be a binary value (such as 0 for no connection and 1 for connection) or a weight value (such as Euclidean distance, mileage distance, traffic flow similarity DTW, etc.).
[0045] For each node i in the road network, at each time t, the traffic flow data can be obtained through sensors Wherein, C represents the dimension of the data, such as traffic volume, vehicle speed, etc. As an example, C can be 1. When C=1, It only contains traffic flow information or traffic flow data, but this is just an example, and C can be 2, 3, etc., that is, the acquired traffic flow data can be multi-dimensional data including traffic flow data, vehicle speed, etc.
[0046] Taking C = 1 as an example, traffic flow data can be represented in matrix form. For example, the traffic flow data of all nodes at time t can be represented as the matrix Among them, N is the total number of nodes. The matrix collects the traffic flow data of all nodes in the road network at a certain moment, providing basic data for subsequent spatiotemporal feature extraction and traffic flow prediction.
[0047] In step S120, the historical traffic flow data and the spatial location data are preprocessed and feature extracted to obtain processed data and feature data.
[0048] Sample data can be preprocessed and feature engineered to obtain high-quality training data and hidden features that are more convenient for model learning.
[0049] Reference Figure 3 The step of preprocessing and feature extracting the historical traffic flow data and the spatial location data to obtain processed data and feature data may include at least one of step S121, step S122, step S123, step S124 and step S125.
[0050] In step S121, the historical traffic flow data is denoised, normalized, and linearly interpolated.
[0051] Denoising the historical traffic data can remove outliers, perform some low-pass filtering, and normalize the data to obtain a sample distribution that is easy to learn. As an example, linear interpolation can be used to fill in missing values in the data to ensure the continuity and integrity of the data.
[0052] The normalized transformation formula may be the following formula (1).
[0053]
[0054] In Formula 1, min and max represent the maximum and minimum values of a batch of traffic flow data, respectively, and γ represents the scaling factor.
[0055] In step S122, the average value of the traffic flow per unit time of each station is calculated based on the historical traffic flow data, and then the distance between each pair of nodes is calculated using the DTW algorithm to construct a DTW distance matrix between the nodes.
[0056] As an example, the average value of the traffic flow per unit time (e.g., per day) of each station can be calculated based on the above processed data, and then the distance between each pair of nodes can be calculated using the dynamic time warping (DTW) algorithm to construct a DTW distance matrix between nodes:
[0057] In step S123, based on the mileage information of the site to be predicted, the mileage distance between the site to be predicted and other sites is calculated to construct a spatial adjacency matrix, and a mask for distinguishing the types of sites is introduced. In addition, the interaction mask of the model can be generated by using the mileage matrix of the site. The interaction mask is mainly used to describe the spatial position relationship between the sites. In addition, the type mask is also used to identify and classify different types of nodes.
[0058] As an example, the mileage information of the site to be predicted here may be a mileage matrix of the site to be predicted or may be obtained from the mileage matrix.
[0059] As an example, we can construct an adjacency matrix and and type mask M t . It can be constructed by calculating the mileage distance between nodes. Each element Represents the mileage distance between node i and node j. This representation method can better capture the spatial relationship of nodes in the road network, especially in complex overpass scenarios.
[0060] is a semantic adjacency matrix calculated based on Dynamic Time Warping (DTW), It reflects the dynamic semantic distance between nodes. In this way, it is possible to capture the similarity of traffic flow patterns between nodes even if they are not directly connected in space.
[0061] Type mask M t Used to distinguish different types of nodes (such as overpasses and straight roads) and to enhance the differences between node types in subsequent model processing. When two sites are of the same type, the value of the corresponding mask element is 1. When the types of the two sites are different, the value of the corresponding mask element is 0.
[0062] In step S124, a temporal coding dictionary including weekly coding and daily coding is designed to effectively capture daily periodic features and weekly periodic features from historical traffic flow data.
[0063] As an example, a time-series coding dictionary can be designed to capture and characterize the daily and weekly periodic features in traffic flow data. The dictionary here can be divided into two parts: weekly coding and daily coding, corresponding to the periodic patterns of each day of the week and the periodic patterns of each time point in the day, respectively. The weekly coding represents the seven days of the week, while the daily coding is divided into 288 time periods (one data point every 5 minutes) every day. Through this coding method, the periodic information of time can be added to the input traffic flow data to improve the model's ability to identify and predict traffic flow changes.
[0064] In step S125, the historical traffic flow data is decomposed into first component data and second component data different from the first component data.
[0065] As an example, STL (a time series analysis method) can be used to decompose traffic flow data into two different component data, for example, seasonal component data and trend component data, such as Figure 2 X shown season , X trendHere, it is divided according to seasonal components and trend line components. This is just an example. It can also be divided by month, etc.
[0066] STL decomposition can use the Loess method to smooth the time series and separate the seasonal (cyclical) and trend (long-term change) components, providing the model with a fine-grained understanding of the different components of the time series.
[0067] As the trend component data X trend Example of , where appropriate Loess smoothing parameters (e.g., window width) can be selected; Apply Loess smoothing to the original sequence X t To estimate the trend component X trend . As the seasonal component data X season Example, which can remove the trend component from the original sequence and calculate the detrended sequence X detrend =X t -X trend , then for the detrended series X detrend Apply Loess smoothing, taking into account a fixed period (such as a week or a day), to estimate the seasonal component X season .
[0068] The above is merely an example of decomposing traffic flow data into two different component data. Other separation methods may also be used to obtain two or more different component data.
[0069] In step S130, the mileage matrix of the site to be predicted is integrated to construct a delay-aware feature extraction model.
[0070] The mileage matrix of the site to be predicted here can be determined based on the mileage data between the site to be predicted and other sites in the same road network. The delay-aware extraction model may include an input encoding layer, a cross-correlation layer, and a fusion attention layer, and may also include a temporal attention layer.
[0071] The input coding layer can be used to encode the input data to output the coded data, and the time attention layer can obtain the time series feature data based on the coded data output by the input coding layer. For example, the time series feature data can be obtained based on the coded data output by the input coding layer through the time attention mechanism. The cross-correlation layer can obtain the first component feature data and the second component feature data based on the output coded data and the time series feature data, where each of the first component feature data and the second component feature data reflects the delayed traffic mode and spatial characteristics between each station.
[0072] The first component feature data is different from the second component feature data, and the first component feature data and the second component feature data may be feature data extracted based on different components.
[0073] The traffic flow prediction method according to the embodiment of the present disclosure may further include the steps of data segmentation and sorting. Specifically, the processed data may be segmented and the data set may be sorted. Specifically, the following operations may be performed: the processed data is segmented according to the size of the historical time window to form a data set of length T H time series samples to capture the time-dependent characteristics of traffic flow.
[0074] As an example, 12 is generally selected as the window size, and the data point interval is 5 minutes, so the historical time window is 1 hour; the split time series samples are randomly divided into training sets, validation sets, and test sets according to a predetermined ratio (generally a ratio of 7:3) to support model training, validation, and performance evaluation. The training set and validation set can be used for model training and validation, and the test set can be used for traffic flow prediction.
[0075] In step S140, based on the processed data and the feature data, delay interaction feature data is acquired through a delay-aware feature extraction model.
[0076] Based on the processing data and the feature data, the step of acquiring the delay interaction feature data through the delay perception feature extraction model may include step S141, step S142, step S143, step S144 and step S145.
[0077] In step S141, a linear transformation is performed on at least a portion of the data in the processed data and feature data other than the training data to obtain high-level temporal feature data, first feature data and second feature data, wherein the first feature data and the second feature data respectively correspond to different components in at least a portion of the data.
[0078] Reference Figure 2 The input coding layer can transform at least part of the data, projecting the low-dimensional time dimension and space dimension features into the high-dimensional space through learnable parameters, making the features easier to learn and aggregate. The internal conversion formula is expressed as the following formula (2).
[0079]
[0080] Among them, E tem Represents high-level temporal feature data, ω and b(ω t ,ω s , b t , b s ) represent the learnable weights and bias parameters in the linear layer or linear transformation, E adj Represents the encoding of the adjacency matrix, E season 、E trendcan represent the spatial high-level features of the fused mileage matrix after trend decomposition, which can be obtained by convolving the trend component and the seasonal component (for example, one-dimensional convolution). represents the adjacency matrix and can be obtained as described above, E w , E d They respectively represent the daily periodic features and weekly periodic features in the traffic flow data (ie, feature data represented in matrix form).
[0081] In step S142, the high-level temporal feature data is processed using a temporal attention algorithm to obtain hidden coded data.
[0082] As an example, a hidden encoding that reflects the temporal traffic pattern between nodes can be obtained through the temporal self-attention mechanism.
[0083] First, based on the input high-level time feature data E tem Compute the temporal attention Q tem , K tem and V tem , which can be calculated specifically by the following formula (3).
[0084] Q tem =E tem W Q , K tem =E tem W K , V tem =E tem W V (3)
[0085] Among them, W Q , W K , W V is a learnable parameter matrix. Next, the self-attention Attn in the time dimension is calculated by the following formula (4): tem :
[0086]
[0087] Then based on the temporal attention Attn tem Calculate the hidden coded data, the specific calculation method is as described in the following formula (5):
[0088] Z tem =FFN(Softmax(Attn tem )V tem ) (5)
[0089] Among them, D head represents the dimension of the attention head, Z temrepresents hidden coded data that incorporates temporal dependencies, and FFN is a simple feed-forward neural network consisting of linear layers and normalization layers.
[0090] In step S143, a delayed perceptual cross-correlation operation is performed on the sum of the hidden coded data and the first feature data to obtain the first component feature data Z season .
[0091] In step S144, a delayed perceptual cross-correlation operation is performed on the sum of the hidden coded data and the second feature data to obtain the second component feature data Z trend .
[0092] Reference Figure 4 and Figure 5 , hidden coded data Z tem With the first characteristic data E spas The sum is input to the seasonal delay-aware cross-correlation layer, and the hidden encoding data Z tem With the second characteristic data E spat The sum is input into the trend delay-aware cross-correlation layer. The delay-aware cross-correlation module including the seasonal delay-aware cross-correlation layer and the trend delay-aware cross-correlation layer is used to detect the delay interaction pattern between sites, realizing feature interaction across time and space at the same time.
[0093] Specifically, in order to facilitate the efficient implementation of cross-correlation, the cross-spectral density P can be calculated by converting it to the frequency domain through fast Fourier transform (FFT). Q K is calculated as shown in the following formula (6).
[0094]
[0095] Where win represents the window function, which is used to reduce the leakage effect caused by non-periodicity. spa , K spa , V spa Respectively represent the hidden coded data Z tem With the first characteristic data E spas The sum and hidden coded data Z tem With the second characteristic data E spat The sum of the Q value, K value, and V value in the attention mechanism obtained by a simple linear layer.
[0096] Then, refer to Figure 4 and Figure 5 , the cross-correlation sequence R can be obtained by inverse FFT (iFFT) operation QK (t), the specific calculation method is shown in the following formula (7).
[0097]
[0098] The above cross-correlation sequence reflects the delayed correlation between sequences, providing the model with the ability to capture the interactive traffic patterns between nodes. Through the cross-correlation sequence, the information of the k (k<<N) nodes with the highest correlation with node i can be identified and aggregated to enhance the spatiotemporal characteristics of traffic flow prediction.
[0099] This process involves the following key calculations, identification of node correlation and delay: First, based on the mutual correlation values between nodes, select the k node indexes (ind1, ind2, ..., ind k ). Then, according to the cross-correlation value R of the corresponding k nodes QK , determine the position where the cross-correlation value is the largest, and thus obtain the corresponding delay (τ1,…,τ k ), the specific conversion formula is shown in the following formula (8).
[0100] ind1, ind2, ..., ind k =argTopK(|R QK |)
[0101]
[0102] Reference Figure 5 and Figure 6 The delay-aware aggregation process is as follows: for the k nodes that are highly correlated with node i, cyclic shift processing is performed according to their respective delays τ, and then their feature vectors V spa Perform delay-aware aggregation. By applying the softmax function to these cross-correlation values, the weights (a i,1 , a i,2 , …, a i,k ), and accordingly perform weighted summation on the features of k nodes to generate a delay-aware sequence. The specific conversion formulas are shown in the following equations (9) and (10).
[0103]
[0104] Among them, a i,k Represents the weight between node aggregations; Roll(V i , τ m ) represents the timing of the V value of node i m Cyclic shift of season and Z trend represents the encoding result of the delayed cross-correlation layer, that is, the first component feature data Z season and the second component characteristic data Z trend , FFN represents a simple feed-forward neural network.
[0105] That is to say, in the process of obtaining delay interaction feature data, the first feature data obtained based on the first component data and the second feature data obtained based on the second component data can be used to perform delay-aware cross-correlation operations respectively to obtain different component feature data reflecting the delay traffic patterns and spatial characteristics between each station.
[0106] In step S145, the fusion attention mechanism fuses the first component feature data, the second component feature data and the hidden coding data to obtain delayed interaction feature data.
[0107] The formula of the internal conversion function of the fusion attention mechanism to fuse the first component feature data, the second component feature data and the hidden coding data is expressed as the following formula (11) and formula (12):
[0108] E f =Z tem +Z season +Z trend (11)
[0109]
[0110] Among them, Z season , Z trend , Z tem Respectively represent the first component feature data, the second component feature data and the hidden code data, Q f , K f , V f The superposition result E of the first component feature data, the second component feature data and the hidden coding data is represented by f The Q value, K value and V value in the attention mechanism obtained by linear transformation, Z f represents the delayed interaction feature data after fusion, D head represents the dimension of the attention head, Softmax and Mask represent the normalization function and mask function respectively, and FFN represents a simple feedforward neural network.
[0111] In step S150, the delayed interaction feature data is convolved to obtain the traffic flow of the site to be predicted in the next time window.
[0112] The convolution here can be a two-dimensional convolution, and the convolution calculation method can be shown in the following formula (13).
[0113] X pred =Conv2d(Z f ) (13)
[0114] Among them, X predIt represents the prediction of traffic flow in the next time window. Conv2d represents a two-dimensional convolution operation, and its internal parameters mainly include the weights of the learnable convolution operator.
[0115] During the training process of the above model, the mean square error (MSE) loss function is used to optimize the model parameters and reduce the gap between the predicted value and the actual traffic flow data. The loss function helps to quantify the error between the model predicted value and the actual observed value, and guides the parameter update during the model training process to improve the prediction accuracy. However, this is just an example, and the root mean square error (RMSE) and mean absolute error (MAE) can also be used as relevant performance indicators for evaluating the model.
[0116] In summary, first, the input encoding layer is used to extract information from low-dimensional semantic information to high-dimensional space; then the temporal attention layer is used to reveal the potential characteristics of traffic flow changing over time, and then the delay-aware cross-correlation layer is used to identify the delayed traffic pattern and spatial characteristics between interchange sites; finally, the fusion attention layer is used to integrate the features of the spatiotemporal module to complete the prediction of traffic flow. Therefore, by extracting the historical traffic flow data of the site to be predicted to hide the spatiotemporal relationship features, future traffic flow data can be predicted. Figure 7 The traffic flow prediction system of the present disclosure is described.
[0117] Figure 7 A traffic flow prediction system according to an embodiment of the present disclosure.
[0118] Reference Figure 7 According to an embodiment of the present disclosure, the traffic flow prediction system 700 may include a data acquisition module 710, a data preprocessing module 720, a mileage matrix fusion module 730, a delay-aware feature extraction module 740, and a prediction module 750. As an example, the data acquisition module 710, the data preprocessing module 720, the mileage matrix fusion module 730, the delay-aware feature extraction module 740, and the prediction module 750 may be implemented by software and / or hardware.
[0119] The data acquisition module 710 can acquire historical traffic flow data and spatial location data of the site to be predicted, and can acquire these data from the transportation department or the like.
[0120] The data preprocessing module 720 may preprocess and extract features from the historical traffic flow data and spatial location data to obtain processed data and feature data.
[0121] The data preprocessing module 720 can perform a linear transformation on at least a portion of the data in the processed data and feature data other than the training data to obtain high-level temporal feature data, first feature data and second feature data, wherein the first feature data and the second feature data respectively correspond to different components in at least a portion of the data, and use a temporal attention algorithm to process the high-level temporal feature data to obtain hidden coding data; perform a delay-aware cross-correlation operation on the sum of the hidden coding data and the first feature data to obtain first component feature data; perform a delay-aware cross-correlation operation on the sum of the hidden coding data and the second feature data to obtain second component feature data; use a fusion attention mechanism to fuse the first component feature data, the second component feature data and the hidden coding data to obtain delayed interaction feature data, and so on.
[0122] The mileage matrix fusion module 730 can fuse the mileage matrices of the sites to be predicted to construct a delay-aware feature extraction model. The mileage matrix fusion module 730 can fuse the mileage matrices to construct a delay-aware feature extraction model, and can train the delay-aware feature extraction model using a training data set in the processed data.
[0123] The delay-aware feature extraction module 740 can obtain delay interaction feature data through a delay-aware feature extraction model based on the processed data and feature data. The specific method for obtaining the delay interaction feature data is as shown above and will not be repeated here.
[0124] The prediction module 750 may convolve the delayed interaction feature data to obtain the traffic flow of the station to be predicted in the next time window. The data of the next time window may be the average traffic flow data every five minutes in the next hour.
[0125] The delay-aware feature extraction module can use the first feature data obtained based on the first component data and the second feature data obtained based on the second component data to perform delay-aware cross-correlation operations to obtain different component feature data reflecting the delayed traffic patterns and spatial characteristics between various stations.
[0126] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process and related instructions of the system described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0127] It should be noted that the traffic flow prediction method of the delay-aware converter based on the mileage matrix provided in the above embodiment is only illustrated by the division of the above functional modules. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the modules or steps in the embodiments of the present disclosure can be decomposed or combined. For example, the modules in the above embodiments can be combined into one module, or further divided into multiple sub-modules to complete all or part of the functions described above. The names of the modules and steps involved in the embodiments of the present invention are only for distinguishing the modules or steps, and are not regarded as improper limitations on the present disclosure.
[0128] According to an embodiment of the present disclosure, a storage device may store a series of program codes. When these codes are read and executed by a corresponding processing unit or processor, a traffic flow prediction method can be executed, which follows the principle of a delay-aware converter based on a mileage matrix as shown above. The design of these program codes specifically enables the processing unit to complete a series of steps including but not limited to data collection and preprocessing, the construction of a prediction model, and the use of the model to predict traffic flow.
[0129] According to an embodiment of the present disclosure, a computer-readable storage medium stores a computer program or code. When the computer program or code is loaded and executed by a processor, the processor is prompted to execute the above-mentioned traffic flow prediction method.
[0130] The computing device according to the embodiment of the present disclosure includes a processor and a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program or code, and when the computer program or code is loaded and executed by the processor, the processor is prompted to execute the above-mentioned traffic flow prediction method. In addition, the computing device not only improves the accuracy and efficiency of traffic flow prediction by adopting advanced data analysis algorithms and spatial information processing technology, but is also particularly suitable for solving complex overpass traffic flow prediction problems.
[0131] Specifically, the processing device can efficiently collect various types of traffic flow-related data by implementing a highly optimized data collection program; its preprocessing program can clean and standardize the collected data to ensure data quality; the constructed prediction model can accurately capture the spatiotemporal characteristics of traffic flow, and accurately predict future traffic conditions by learning historical data patterns. The automation and intelligence of this series of processes greatly enhances the reliability and practicality of the device in practical applications.
[0132] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process and related instructions of the storage device and processing device described above can refer to the corresponding process in the aforementioned method embodiment and will not be repeated here.
[0133] The instructions stored in the computer-readable storage medium can be executed in an environment deployed in a computer device such as a client, a host, an agent device, a server, etc. It should be noted that the instructions can also be used to perform additional steps in addition to the above steps or perform more specific processing when performing the above steps. The contents of these additional steps and further processing have been described in detail in reference to Figures 1 to 7 It is mentioned in the description of related systems and methods, so it will not be repeated here to avoid repetition.
[0134] It should be noted that the traffic flow prediction method according to the exemplary embodiment of the present disclosure can completely rely on the operation of computer programs or instructions to realize the corresponding functions, that is, each device corresponds to each step in the functional architecture of the computer program, so that the entire system is called through a special software package (for example, lib library) to realize the corresponding functions.
[0135] On the other hand, when the systems, units or modules shown in the drawings are implemented in software, firmware, middleware or microcode, the program code or code segments for performing the corresponding operations can be stored in a computer-readable medium such as a storage medium, so that at least one processor or at least one computing device can perform the corresponding operations by reading and running the corresponding program code or code segments. In addition, the computer-readable medium or storage medium can cause the processor to execute the above-mentioned traffic flow prediction method when the computer program is executed by the processor.
[0136] Examples of computer-readable storage media include read-only memory (ROM), random-access programmable read-only memory (PROM), electrically erasable programmable read-only memory (EEPROM), random-access memory (RAM), dynamic random-access memory (DRAM), static random-access memory (SRAM), flash memory, nonvolatile memory, CD-ROM, CD-R, CD+R, CD-RW, CD+RW, DVD-ROM, DVD-R, DVD+R, DVD-RW, DVD+RW, DVD-RAM, BD-ROM, BD-R, BD-R LTH, BD-RE, Blu-ray or optical disk storage, hard disk drive (HDD), solid state drive (SSD), card storage (such as, multimedia card, secure digital (SD) card or extreme digital (XD) card), magnetic tape, floppy disk, magneto-optical data storage device, optical data storage device, hard disk, solid state disk and any other device, any other device is configured to store computer programs and any associated data, data files and data structures in a non-transitory manner and provide computer programs and any associated data, data files and data structures to a processor or computer so that the processor or computer can execute the computer program. The computer program in the above-mentioned computer-readable storage medium can be run in an environment deployed in a computer device such as a client, a host, an agent device, a server, etc. In addition, in one example, the computer program and any associated data, data files and data structures are distributed on a networked computer system, so that the computer program and any associated data, data files and data structures are stored, accessed and executed in a distributed manner by one or more processors or computers.
[0137] The traffic flow prediction method according to the embodiment of the present disclosure performs well in various scenarios, and can especially improve the prediction effect of the interchange scenario.
[0138] The traffic flow prediction method according to the embodiment of the present disclosure performs significantly better than traditional methods and other advanced models in the prediction of the overpass scene, especially in the data set with dense complex overpass scenes. This shows that the traffic flow prediction method of the present disclosure can effectively capture the complex traffic flow dynamics in the overpass scene, greatly improving the accuracy of traffic flow prediction in the overpass scene.
[0139] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A traffic flow prediction method, characterized in that: The traffic flow prediction method comprises: Obtain historical traffic flow data and spatial location data of the site to be predicted; Preprocessing and feature extracting the historical traffic flow data and the spatial location data to obtain processed data and feature data; A delay-aware feature extraction model is constructed by integrating the mileage matrix of the station to be predicted, wherein the mileage matrix of the station to be predicted is determined based on mileage data between the station to be predicted and other stations in the same road network; Based on the processing data and the feature data, delay interaction feature data is obtained through a delay-aware feature extraction model; Convolving the delayed interaction feature data to obtain the traffic flow of the site to be predicted in the next time window, Wherein, the delay-aware feature extraction model includes: An input encoding layer, used for encoding input data to output encoded data; A temporal attention layer, which obtains time series feature data based on the encoded data output by the input encoding layer; A cross-correlation layer, obtaining first component feature data and second component feature data based on the output coded data and the time series feature data, each of the first component feature data and the second component feature data reflecting a delayed traffic pattern and a spatial characteristic between respective stations; A fusion attention layer, a fusion attention mechanism fuses the first component feature data, the second component feature data and the time series feature data to obtain delayed interaction feature data.
2. The traffic flow prediction method according to claim 1, characterized in that: The delay-aware feature extraction model is trained using training data in the processed data.
3. The traffic flow prediction method according to claim 1 or 2, characterized in that: Based on the processing data and the feature data, the steps of obtaining the delay interaction feature data through the delay-aware feature extraction model include: Performing a linear transformation on at least a portion of the data in the processed data and feature data other than the training data to obtain high-level temporal feature data, first feature data, and second feature data, wherein the first feature data and the second feature data correspond to different components in the at least a portion of the data, respectively; Processing the high-level temporal feature data using a temporal attention algorithm to obtain hidden encoding data; Performing a delayed perceptual cross-correlation operation on the sum of the hidden coded data and the first feature data to obtain first component feature data; Performing a delayed perceptual cross-correlation operation on the sum of the hidden coded data and the second feature data to obtain second component feature data; The fusion attention mechanism fuses the first component feature data, the second component feature data and the hidden coding data to obtain the delayed interaction feature data.
4. The traffic flow prediction method according to claim 3, characterized in that: The formula of the internal conversion function of the fusion attention mechanism to fuse the first component feature data, the second component feature data and the hidden encoding data is expressed as: E f =Z tem +Z season +Z trend Among them, Z season , Z trend , Z tem represent the first component feature data, the second component feature data and the hidden code data respectively, Q f , K f , V f represents the superposition result E of the first component feature data, the second component feature data and the hidden code data f The Q value, K value and V value in the attention mechanism obtained by linear transformation, Z f represents the delayed interaction feature data after fusion, D head represents the dimension of the attention head, Softmax and Mask represent the normalization function and mask function respectively, and FFN represents a simple feedforward neural network.
5. The traffic flow prediction method according to claim 1, characterized in that: The steps of obtaining the historical traffic flow data and spatial location data of the site to be predicted include: The traffic flow data of each node at each time in the road network diagram including the site to be predicted is obtained, and a road network diagram is constructed, wherein the spatial position data includes the absolute mileage data of the site to be predicted.
6. The traffic flow prediction method according to claim 1, characterized in that: The step of preprocessing and feature extracting the historical traffic flow data and the spatial location data to obtain processed data and feature data comprises at least one of the following steps: De-noising, normalizing and linearly interpolating the historical traffic flow data; Based on the historical traffic flow data, the average value of the traffic flow per unit time of each station is calculated, and then the distance between each pair of nodes is calculated using the DTW algorithm to construct a DTW distance matrix between the nodes; Based on the mileage information of the site to be predicted, the mileage distance between the site to be predicted and other sites is calculated to construct a spatial adjacency matrix, and a mask for distinguishing the types of sites is introduced; Designing a time coding dictionary including weekly coding and daily coding to effectively capture daily periodicity characteristics and weekly periodicity characteristics from the historical traffic flow data; The historical traffic flow data is decomposed into first component data and second component data different from the first component data.
7. The traffic flow prediction method according to claim 6, characterized in that: In the process of obtaining delay interaction feature data, delay-aware cross-correlation operations are performed respectively using the first feature data obtained based on the first component data and the second feature data obtained based on the second component data to obtain different component feature data reflecting the delayed traffic patterns and spatial characteristics between each station, wherein the station to be predicted is an interchange station to be predicted.
8. A traffic flow prediction system, characterized in that: The traffic flow prediction system comprises: A data acquisition module is used to obtain historical traffic flow data and spatial location data of the site to be predicted; A data preprocessing module, which preprocesses and extracts features from the historical traffic flow data and the spatial location data to obtain processed data and feature data; A mileage matrix fusion module, which fuses the mileage matrix of the station to be predicted to construct a delay-aware feature extraction model, wherein the mileage matrix of the station to be predicted is determined based on the mileage data between the station to be predicted and other stations in the same road network; A delay-aware feature extraction module, which obtains delay interaction feature data through a delay-aware feature extraction model based on the processed data and feature data; The prediction module performs convolution on the delayed interaction feature data to obtain the traffic flow of the station to be predicted in the next time window. Wherein, the delay-aware feature extraction model includes: An input encoding layer, used for encoding input data to output encoded data; A temporal attention layer, which obtains time series feature data based on the encoded data output by the input encoding layer; A cross-correlation layer, obtaining first component feature data and second component feature data based on the output coded data and the time series feature data, each of the first component feature data and the second component feature data reflecting a delayed traffic pattern and a spatial characteristic between respective stations; A fusion attention layer, a fusion attention mechanism fuses the first component feature data, the second component feature data and the time series feature data to obtain delayed interaction feature data.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program or code, which, when loaded and executed by a processor, causes the processor to execute the traffic flow prediction method according to any one of claims 1 to 7.
10. A computing device, characterized in that: The computing device includes a processor and a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program or code, and when the computer program or the code is loaded and executed by the processor, the processor is prompted to execute the traffic flow prediction method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Method and device for vehicle risk judgment based on historical mileages
CN105512453A
Traffic flow prediction method of recurrent neural network based on embedded attention mechanism
CN112257918A