Urban traffic flow space-time distribution prediction method based on multistage road operation information
By introducing multi-level road operation information and attention mechanisms in traffic flow prediction, extracting spatiotemporal and spatial characteristics, and building multi-layer prediction modules, the problem of insufficient prediction accuracy of existing methods in complex road networks is solved, and more efficient and accurate traffic flow prediction is achieved.
Patent Information
- Application Number
- CN202510572550.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-06
- Publication Date
- 2025-06-03
AI Technical Summary
The existing traffic flow prediction methods are difficult to effectively integrate spatial and temporal characteristics, resulting in insufficient prediction accuracy in complex urban road networks, difficult to adapt to multi-level road structures and large-scale road networks, and difficult to take into account both computing efficiency and output accuracy.
The spatial and temporal distribution prediction method of urban traffic flow based on multi-level road operation information is adopted. Through traffic flow information preprocessing, the spatial convolution network module and the temporal loop network module are constructed using channel attention and spatial attention mechanisms to extract spatial and temporal characteristics, and regression prediction and residual regression prediction module are constructed to realize the spatial and temporal distribution prediction of traffic flow at grid areas and section levels.
It significantly improves the accuracy of traffic flow prediction and the adaptability of models, enhances the generalization ability of complex urban road networks, improves computing efficiency, and better captures the spatio-temporal characteristics of traffic flows. It is suitable for smart traffic management systems of different cities and road network scales.
Smart Images

Figure CN120088990A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of traffic flow prediction, and particularly to a method for predicting the spatio-temporal distribution of urban traffic flow based on multi-level road operation information. Background Art
[0002] With the rapid development of urban traffic systems, the urban road network structure has become increasingly complex. As a key technology for intelligent traffic management, the accuracy and efficiency requirements of traffic flow prediction show a diversified trend. Existing traffic flow prediction methods mainly include models based on statistics, models based on traditional machine learning, and models based on deep learning. Statistical models such as time series models, regression models, Kalman filters, etc. have a simple modeling process and are easy to implement, but their prediction ability is limited when facing high-dimensional dynamic systems such as urban traffic. Machine learning models such as support vector machines, K-nearest neighbor algorithms, random forests, etc. have certain feature modeling capabilities, but they have limitations in feature selection and expansion, and it is difficult to meet the requirements of real-time and accuracy in large-scale complex traffic scenarios. In contrast, deep learning methods, especially recurrent neural networks (RNNs), long short-term memory networks (LSTMs), gated recurrent units (GRUs), etc., have significant advantages in modeling non-linear time series relationships and have gradually become the mainstream direction of traffic flow prediction research.
[0003] However, single time modeling methods often ignore the significant features of traffic flow in the spatial dimension, such as differences in road grades and spatial dependencies between road segments, resulting in biased prediction results. To enhance the adaptability of the model to the complexity of the traffic system, some recent studies have attempted to combine technologies such as graph convolutional networks (GCNs) and graph neural networks (GNNs) to extract spatial features and fuse them with time features to improve prediction performance. However, these methods still face a series of problems, such as: insufficient model generality and difficulty in adapting to multi-level road structures; lack of an extraction mechanism for key channel and regional features, which affects the overall prediction accuracy; in addition, when performing long-term predictions under large-scale road networks, existing models are difficult to balance computational efficiency and output accuracy simultaneously. Therefore, there is an urgent need to construct a method for predicting urban traffic flow based on multi-level road operation information that can fuse spatio-temporal features and improve overall prediction performance to meet the multiple requirements of accuracy, efficiency, and real-time in intelligent traffic systems. Summary of the Invention
[0004] The purpose of the present invention is to provide a method for predicting the spatio-temporal distribution of urban traffic flow based on multi-level road operation information to solve the problems existing in the prior art.
[0005] To achieve the above purpose, the present invention provides the following technical solution: A method for predicting the spatio-temporal distribution of urban traffic flow based on multi-level road operation information, the method comprising: S1, preprocessing of traffic flow information; S2. Use the channel attention and spatial attention mechanisms to construct a spatial convolutional network module to extract spatial features; S3. Construct a time recurrent network module that captures long-term and short-term time-dependent features to extract temporal features; S4. Construct a connection layer module for regression prediction to achieve the prediction of the spatio-temporal distribution of traffic flow in grid areas; S5. Construct a traffic flow feature clustering and residual regression prediction module to achieve the prediction of the spatio-temporal distribution of traffic flow on each road section within the grid.
[0006] Preferably, the S1 includes: Define a grid matrix that covers the prediction area, and determine the associated road sections corresponding to each grid. The size of the grid is determined according to the actual urban situation. The matrix contains several rows and columns of grids. Based on the obtained geographical information, determine the different levels of road sections included in each grid, and respectively construct a set of road level sections under each grid. The road levels are divided into expressways, arterial roads, sub-arterial roads, and branch roads; Collect the traffic flow information of different levels of road sections within the scope of each grid at different time periods. Then, take the average value of the traffic flow information of all road sections of this level within each time period as the average traffic flow information of this level of road in this grid under this time period; Based on the traffic flow information calculated in the previous step, construct a three-dimensional traffic flow information matrix at each specific time period. The dimensions of this three-dimensional traffic flow information matrix include spatial position and road level, and its elements are traffic flow information after normalization processing. The normalization operation is to divide the original traffic flow information by a maximum value determined according to the actual traffic conditions, so as to obtain a traffic feature matrix under a unified dimension.
[0007] Preferably, the S1 further includes: Construct a time series of traffic flow information. Taking the selected time interval as the unit, form a sequence of three-dimensional traffic flow information matrices at multiple consecutive moments in time order for the input of subsequent prediction tasks. The length of this time series is determined by the actual prediction requirements; Based on the above time series, determine the prediction result of the traffic flow information at a future time point. Specifically, specify the span of the prediction time point, and combine the input time series to obtain a traffic flow information matrix at the required prediction time point, whose dimension is the same as that of a single input matrix.
[0008] Preferably, the S2 includes: Define a convolutional neural network module. For the predicted input time series, use the convolutional neural network to extract the spatial feature information at each moment to establish spatial dependence. The specific process is as follows: For the three-dimensional traffic flow information matrix at each moment in the time series, input it into multiple convolutional layers respectively. The data is passed layer by layer between the convolutional layers. The output of each convolutional layer is first normalized, then undergoes weighted calculation with a bias term and non-linear activation processing. The normalization process includes mean normalization and variance standardization of the input data to enhance the stability of model training. Finally, multiply by a scaling parameter and add an offset; Define a channel attention mechanism module. For the multiple channels included in the output of the convolutional layer, introduce a channel attention mechanism to identify the key channels that have a greater impact on the prediction accuracy. This mechanism first extracts global features for each channel through average pooling and max pooling, then passes the extracted features into a multi-layer perceptron network for weighted calculation, and finally generates a channel attention matrix. This attention matrix will act on the original channel output to strengthen the role of the key channels in the subsequent network and improve the overall prediction ability.
[0009] Preferably, the S2 further includes: Define a spatial attention mechanism module. For the matrix spatial positions retained in the output of the convolutional layer, introduce a spatial attention mechanism to identify the regions that have a key impact on the prediction effect. This mechanism first performs average pooling and max pooling on the feature matrix to form two compressed features in the spatial dimension, then connects the two and inputs them into a convolutional operation with a 5×5 convolutional kernel. After this process is processed by a non-linear activation function, a spatial attention matrix is generated. Finally, this matrix is weighted and fused with the original spatial features to enhance the expression ability of the key spatial regions; Update the time series of traffic flow information. Based on the spatial features that integrate the channel attention and spatial attention mechanisms output by the above convolutional module, combine them in chronological order into a new spatial feature time series, which is used as the input for traffic flow information modeling in the subsequent steps. The length of the newly generated time series is set according to the actual prediction requirements to ensure that historical features can be fully extracted to improve the prediction accuracy.
[0010] Preferably, the S3 includes: Construct a time recurrent network module based on the gated recurrent unit network to capture the long-term and short-term time dependence features existing in the time series. The gated recurrent unit effectively extracts the time dependence relationship through a gating mechanism. This mechanism mainly includes an update gate and a reset gate. The role of the update gate is to control the influence degree of the previous moment's state information on the current state, while the reset gate controls how much information in the previous state is passed to the current state. Through the above mechanism, the gated recurrent unit network can effectively capture the dependence relationship between each time node in the time series; In the specific module calculation process, first, based on the output of the convolutional neural network module at the current moment and the hidden state at the previous moment, the activation values of the update gate and the reset gate are calculated respectively; then, the outputs of these two gates are combined to calculate the candidate hidden state at the current moment, and finally, the final hidden state at the current moment is obtained by combining the weighted results of the previous hidden state and the candidate hidden state. In the above process, multiple weight matrices and bias terms to be trained are used, and the activation functions include the Sigmoid function and the hyperbolic tangent function.
[0011] Preferably, the S3 further includes: Construct a hidden state sequence, and output the hidden state according to the time information of each moment extracted, forming a complete hidden state sequence. This sequence serves as the basis for constructing the predicted value in the subsequent steps and is used to establish the mapping relationship between features and prediction targets. The length of this hidden state sequence corresponds to the input time series, and the hidden state at each moment is retained for the next prediction process.
[0012] Preferably, the S4 includes: Establish a fully connected layer to construct the regression relationship between the hidden state sequence and the output predicted value. This fully connected layer combines features and performs non-linear mapping on the hidden state sequence to establish the regression output structure of the prediction model. Specifically, it first performs weighted summation on the hidden state sequence and adds a bias term, then activates through the hyperbolic tangent function, and then performs screening through the neuron dropout mechanism. Finally, after weighted summation and bias correction in the second layer, the final predicted value is output; Among them, the output predicted value represents the traffic flow information at the predicted time point, the hidden state sequence represents the set of hidden states at each moment in the input time series, and the weighted matrix and bias term are the parameters to be trained in the connection layer; Construct a loss function. In order to minimize the error between the output predicted value and the actual true value during the model training process, a loss function needs to be defined to measure the gap between them and use this as the basis for model optimization. This model uses the mean square error as the evaluation index, that is, by taking the average of the squared differences between the predicted value and the true value at each spatial position and road grade as the overall prediction error. Through this loss function, the backpropagation of the prediction error can be realized, thereby continuously updating the model parameters and improving the prediction accuracy; Among them, the loss value represents the average deviation between the prediction result and the true value, the spatial number is used to identify different positions, the grade number is used to distinguish different road types, and the predicted value and the true value are the values at the corresponding positions in the traffic flow three-dimensional matrix.
[0013] Preferably, the S5 includes: Define a traffic flow feature calculation module. In response to the requirements of road traffic flow characteristics and clustering, introduce a traffic flow feature calculation method. For a specific road, the calculation method of its traffic flow feature sequence is as follows: Average the multiple pieces of collected traffic flow data at each time point on this road, and then form the traffic flow feature sequence at each time point on this road. Each value in this sequence represents the average traffic flow feature at the corresponding time point; Establish a traffic flow feature clustering module. For the section sets of different road grades, establish self-organizing mapping neural networks respectively, and cluster the sections according to the road traffic flow characteristics. This network determines the neuron with the smallest distance as the best matching unit of the current road by calculating the Euclidean distance between the traffic feature sequence of each road and the weight vectors of each neuron in the network. Then, update the weight vector corresponding to this neuron according to the input features. This update process is carried out based on the topological position relationship between neurons and the law of decreasing learning rate. Finally, the unit category matched by the updated neuron weights is the category to which this section belongs.
[0014] Preferably, the S5 further includes: Calculate the residual data set. For each road, calculate the difference between its original traffic flow data set and the traffic flow features respectively, that is, subtract the obtained traffic flow feature value from the original traffic flow information to obtain the traffic disturbance residual data set at each time point on this section. This residual represents the actual traffic fluctuation situation; Construct a residual prediction model. For different types of sections under different road grades, establish random forest models respectively to predict the residual values. The specific method is to use multiple decision tree models for training. Each model uses different subset samples and feature combinations to divide the data and output prediction results. Finally, take the average of the prediction results of all trees as the final output. During training, use the grid traffic flow information and time as input labels, and use the residual values obtained in the previous step as target values for modeling. During prediction, input the traffic information at the corresponding time point, and the predicted residual of the current section can be output.
[0015] From the above technical solutions, it can be seen that the present invention has the following beneficial effects: The urban traffic flow spatio-temporal distribution prediction method based on multi-level road operation information preprocesses traffic flow information, constructs a spatial convolution network module by using channel attention and spatial attention mechanisms to extract spatial features, constructs a time recurrent network module for capturing long-term and short-term time-dependent features to extract temporal features, constructs a connection layer module for regression prediction to realize the spatio-temporal distribution prediction of traffic flow in grid regions, constructs a traffic flow feature clustering and residual regression prediction module to realize the spatio-temporal distribution prediction of traffic flow on each road section within the grid, incorporates multi-level information such as expressways, arterial roads, sub-arterial roads and branch roads into the feature calculation and prediction modeling process, enhances the adaptability of the model in complex urban road networks, improves the generalization ability under different regions and different road network scales, can effectively model the key spatio-temporal relationships in high-dimensional heterogeneous traffic flow data, thus significantly improving the accuracy of prediction results. By constructing a residual prediction module to independently model and regression compensate the traffic disturbance part, it effectively enhances the robustness and response ability of the model to sudden congestion and abnormal traffic events, significantly reduces the model complexity while maintaining the prediction accuracy, reduces redundant calculations, improves the overall operation efficiency of the model, meets the application requirements of real-time traffic prediction, can flexibly adapt to the needs of different cities, different road network scales and different prediction granularities, and is applicable to various intelligent transportation management systems such as intelligent traffic scheduling, congestion warning, and green travel guidance. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] Figure 1 It is a flowchart of the method of the present invention; Figure 2 It is a comparison chart of model accuracies before and after introducing the attention mechanism; Figure 3 It is a spatio-temporal distribution characteristic chart of prediction speeds of different architectures. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0017] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.
[0018] As Figure 1 shown, the present invention provides a technical solution: an urban traffic flow spatio-temporal distribution prediction method based on multi-level road operation information, the method comprising: S1. Preprocessing of traffic flow information; S2. Using channel attention and spatial attention mechanisms to construct a spatial convolution network module to extract spatial features; S3. Constructing a time recurrent network module for capturing long-term and short-term time-dependent features to extract temporal features; S4. Construct a connection layer module for regression prediction to achieve the prediction of the spatio-temporal distribution of traffic flow in grid areas; S5. Construct a traffic flow feature clustering and residual regression prediction module to achieve the prediction of the spatio-temporal distribution of traffic flow on each road section within the grid.
[0019] Based on multi-source road operation information data, this method first preprocesses the original traffic flow data through S1, including operations such as missing value filling, outlier removal, and time series standardization, to ensure the effectiveness and consistency of the input data. Subsequently, in S2, a channel attention mechanism and a spatial attention mechanism are introduced, enabling the spatial convolutional network to automatically focus on the key correlation regions in traffic behavior between different road areas, thereby efficiently extracting the spatial features of different grid areas. In step S3, a time recurrent network module is constructed by combining models such as the gated recurrent unit (GRU) or long short-term memory network (LSTM) to capture the dynamic evolution characteristics of traffic flow in the short-term and long-term dimensions. In S4, the above spatial and temporal features are fused through a fully connected layer to construct a connection layer module and output the prediction results of the grid-level traffic flow in the future within the entire urban area. Finally, in S5, to further refine the prediction effect of each road section within the grid, clustering methods such as K-means and DBSCAN are used to perform clustering analysis on traffic features, and a residual regression prediction model is introduced to model and correct the residual part after clustering, thereby achieving a higher-precision traffic flow prediction at the road section level.
[0020] S1 includes defining a grid matrix covering the prediction area and determining the associated road sections corresponding to each grid. The size of the grid is determined according to the actual urban situation. The matrix contains several rows and columns of grids. Based on the obtained geographical information, different levels of road sections included in each grid are determined, and a set of road grade sections is constructed for each grid. The road grades are divided into expressways, arterial roads, sub-arterial roads, and branch roads; Collect the traffic flow information of different levels of road sections within each grid range at different time periods. Then, take the average value of the traffic flow information of all road sections of this level within each time period as the average traffic flow information of this level of road in this grid under this time period; Based on the traffic flow information calculated in the previous step, construct a three-dimensional traffic flow information matrix for each specific time period. The dimensions of this three-dimensional matrix include spatial position and road grade, and its elements are traffic flow information after normalization processing. The normalization operation is to divide the original traffic flow information by a maximum value determined according to the actual traffic conditions, thereby obtaining a traffic feature matrix under a unified dimension.
[0021] In this embodiment, a spatially structured grid is defined to cover the entire traffic prediction area. The grid division is reasonably set according to urban geographic information and road distribution to adapt to the traffic density differences in different urban areas. After obtaining the road segments corresponding to each grid, these segments are classified based on the road grade, specifically divided into expressways, arterial roads, sub-arterial roads, and branch roads, to construct a set of road grade segments for more hierarchical traffic analysis. During different time periods, traffic flow data of each road grade (such as traffic volume, average speed, congestion index, etc.) are collected respectively, and the average value of the flow of each grade segment is taken to eliminate the interference of a single abnormal segment and enhance the representativeness of the data. Subsequently, the multi-grade, multi-period, and multi-grid traffic flow information collected and calculated is organized into a three-dimensional matrix data structure including spatial position, road grade, and time series dimensions, and through normalization operations, different dimensions are unified to improve the stability and efficiency of subsequent model training and feature extraction. The reference maximum value for normalization can be determined by the maximum traffic flow or peak period indicators in historical traffic data to ensure the rationality and consistency of data conversion.
[0022] S1 also includes constructing a time series of traffic flow information. Taking the selected time interval as the unit, the three-dimensional traffic flow information matrices at multiple consecutive moments are arranged in chronological order to form a sequence for input to subsequent prediction tasks. The length of this time series is determined by the actual prediction requirements; Based on the above time series, determine the prediction result of traffic flow information at a future time point. Specifically, specify the span of the prediction time point, and combine it with the input time series to obtain the traffic flow information matrix at the required prediction time point, and its dimension is the same as that of a single input matrix.
[0023] In this embodiment, by introducing a time dimension on the basis of the existing three-dimensional traffic flow information matrix, a time series of traffic flow information is formed to enhance the ability to model time dynamic characteristics. Specifically, a suitable time interval (such as 5 minutes, 15 minutes, or 1 hour) is selected as the sampling unit, and the three-dimensional traffic flow matrices at consecutive moments (including spatial position, road grade, and normalized traffic indicators) are sorted in time to construct a time series data structure with a length of T. This series is used as an input sample into subsequent prediction models (such as LSTM or Transformer, etc.) to explore the dependencies and evolution laws between time series features. When making predictions, according to the specified time span (for example, predicting the traffic state 15 minutes or 30 minutes later), the model will output the three-dimensional traffic flow information matrix corresponding to the target prediction moment, and its structure is the same as that of any input matrix to ensure that the prediction results can be used for actual visualization display or control system scheduling. This method effectively realizes short-term or medium-term prediction of future traffic conditions through the time sliding window technique, combined with the traffic states at multiple historical moments.
[0024] S2 includes defining a convolutional neural network module. For the predicted input time series, the convolutional neural network is used to extract the spatial feature information at each moment to establish spatial dependence. The specific process is as follows: The three-dimensional traffic flow information matrix at each moment in the time series is respectively input into multiple convolutional layers, and the data is passed layer by layer between the convolutional layers. The output of each convolutional layer is first normalized, and then undergoes weighted calculation with a bias term and non-linear activation processing. The normalization process includes mean normalization and variance standardization of the input data to enhance the stability of model training, and finally multiplied by a scaling parameter and added with an offset; Define a channel attention mechanism module. For the multiple channels included in the output of the convolutional layer, introduce the channel attention mechanism to identify the key channels that have a greater impact on the prediction accuracy. This mechanism first extracts global features for each channel through average pooling and max pooling, and then passes the extracted features into a multi-layer perceptron network for weighted calculation, and finally generates a channel attention matrix. This attention matrix will act on the original channel output to strengthen the role of the key channels in the subsequent network and improve the overall prediction ability.
[0025] In this embodiment, a convolutional neural network (CNN) is designed to model the spatial structure in the input traffic flow time series data. For the three-dimensional traffic flow information matrix at each time step, it is independently input into the CNN structure and processed layer by layer through multiple convolutional layers to extract the spatial features at that moment. After each layer of convolutional operation, the output is first normalized, specifically including performing mean normalization and variance standardization operations on each pixel point to standardize the data distribution and improve the stability of subsequent training. The standardized data is linearly transformed with the weight matrix of the convolutional kernel and a bias term is added, and then processed through a non-linear activation function such as ReLU to form the feature map output of this layer. The entire CNN module is organized in a hierarchical manner to gradually abstract and refine the spatial features. After the CNN extracts the preliminary spatial features, a channel attention mechanism is introduced to further optimize the feature expression. This mechanism first performs average pooling and max pooling on each channel respectively to extract the global information features in the spatial dimension, and then connects the outputs of the two poolings and inputs them into a perceptron network composed of multiple fully connected layers to output the weights corresponding to the channels. Finally, the generated channel attention matrix is used to weight the original channel output, enhance the channel features strongly correlated with the prediction, and at the same time suppress irrelevant or interfering features, improving the discriminative ability and generalization effect of the model.
[0026] S2 also includes a defined spatial attention mechanism module. For the matrix spatial positions retained in the output of the convolutional layer, a spatial attention mechanism is introduced to identify the regions that have a key impact on the prediction effect. This mechanism first performs average pooling and max pooling on the feature matrix to form two compressed features in the spatial dimension, and then connects the two and inputs them into a convolutional operation with a 5×5 convolutional kernel. After being processed by a non-linear activation function, a spatial attention matrix is generated. Finally, this matrix is weighted and fused with the original spatial features to enhance the expression ability of the key spatial regions; Update the time series of traffic flow information. Based on the spatial features that integrate the channel attention and spatial attention mechanisms output by the above convolutional module, combine them in chronological order into a new spatial feature time series, which is used as the input for traffic flow information modeling in the subsequent steps. The length of the newly generated time series is set according to the actual prediction requirements to ensure that historical features can be fully extracted to improve the prediction accuracy.
[0027] Based on the existing channel attention mechanism, this implementation further introduces a spatial attention mechanism to enhance the model's ability to identify key spatial regions. Specifically, on each frame of the extracted spatial feature map, average pooling and max pooling operations are respectively performed to compress along the channel dimension to obtain two two-dimensional spatial representations. Subsequently, these two feature maps are concatenated along the channel dimension to form a feature map with two channels, and it is input into a convolutional layer with a 5×5 convolutional kernel for feature fusion. The output after convolutional processing is mapped by a non-linear activation function (such as Sigmoid) to generate a spatial attention matrix, which is used for element-wise multiplication fusion with the original spatial feature map, so that the features of the regions that have a greater impact on the prediction in space are strengthened, and the irrelevant regions are suppressed. The spatial feature map combined with the channel and spatial attention mechanisms is regarded as the final extraction result. Then, based on the processing results at different time steps, a new spatial feature time series is reconstructed in chronological order. This series is used as the input for subsequent time modeling steps (such as time series neural networks or prediction modules), retaining the important information in the spatial and channel dimensions while also enhancing the information expression in the time series dimension. The length of the newly generated time series is set according to the time window requirements of the prediction task to meet the needs of short-term or long-term prediction tasks.
[0028] S3 includes constructing a time recurrent network module based on the gated recurrent unit network to capture the long-term and short-term time-dependent features existing in the time series. The gated recurrent unit effectively extracts the time-dependent relationship through a gating mechanism, which mainly includes an update gate and a reset gate. The role of the update gate is to control the influence degree of the previous moment's state information on the current state, while the reset gate controls how much information in the previous state is passed to the current state. Through the above mechanism, the gated recurrent unit network can effectively capture the dependence relationship between each time node in the time series; In the specific module calculation process, first, based on the output of the convolutional neural network module at the current moment and the hidden state at the previous moment, the activation values of the update gate and the reset gate are calculated respectively; then the outputs of these two gates are combined to calculate the candidate hidden state at the current moment, and finally, by combining the weighted results of the previous hidden state and the candidate hidden state, the final hidden state at the current moment is obtained. In the above process, multiple weight matrices and bias terms to be trained are used, and the activation functions include the Sigmoid function and the hyperbolic tangent function.
[0029] In this embodiment, a time recurrent network module is constructed by introducing a gated recurrent unit (GRU), which is specifically used to model the evolution characteristics of traffic flow data in the time dimension. The GRU network dynamically models the long-term and short-term dependence information in the input time series through two key mechanisms: the update gate and the reset gate. The update gate determines how much information from the previous moment should be retained in the current hidden state, while the reset gate controls the degree of forgetting of the previous information, thereby enhancing the network's response ability to sudden traffic events and periodic patterns. During model execution, the GRU first receives the output from the spatial feature convolution module and the hidden state at the previous time step, inputs both into the corresponding weight matrices to calculate the activation values of the update gate and the reset gate (output of the Sigmoid function), then controls the fusion method of historical information and the current input according to these gating values, calculates the current candidate hidden state (activated by the Tanh function), and finally integrates the previous hidden state and the candidate state in a weighted manner to form the final hidden state output. The entire GRU structure continuously optimizes the weight and bias parameters through an end-to-end training method, enabling the model to gradually capture the changing rules of urban traffic flow on the time axis.
[0030] S3 also includes constructing a hidden state sequence. According to the time information extracted at each moment, the hidden state is output to form a complete hidden state sequence, which serves as the basis for constructing the predicted value in the subsequent steps and is used to establish the mapping relationship between the features and the prediction target. The length of this hidden state sequence corresponds to the input time sequence, and the hidden state at each moment is retained for the next prediction process.
[0031] In the time recurrent network module based on the gated recurrent unit (GRU), each input time step corresponds to a spatial feature map. In this module, the input sequence is processed sequentially, and the spatial features at each moment and the hidden state at the previous moment jointly determine the output hidden state at the current moment. Through continuous iteration, the model outputs a hidden state sequence with the same length as the input time series in the time dimension. Each hidden state represents a compressed expression of the historical information at that time step, integrating spatial features and time dependencies. The entire hidden state sequence thus constitutes a temporal feature trajectory, comprehensively recording the change process of the traffic flow state over time. This sequence not only plays a key role in the regression output of the final prediction point, but also provides a complete context input for constructing short-term predictions, multi-step predictions, or future trend estimations. The continuity of the hidden state ensures the coherence of the model in capturing the time dynamic process and enhances the expressive power and flexibility of the subsequent prediction model.
[0032] S4 includes establishing a fully connected layer to construct the regression relationship between the hidden state sequence and the output prediction value. This fully connected layer establishes the regression output structure of the prediction model by performing feature combination and non-linear mapping on the hidden state sequence. Specifically, it first performs weighted summation on the hidden state sequence and adds a bias term, then activates it through the hyperbolic tangent function, and then performs screening through the neuron dropout mechanism. Finally, after weighted summation and bias correction in the second layer, the final prediction value is output; Among them, the output prediction value represents the traffic flow information at the predicted time point, the hidden state sequence represents the set of hidden states at each moment in the input time series, and the weight matrix and bias term are the parameters to be trained in the connection layer; Construct a loss function. In order to minimize the error between the output prediction value and the actual true value during the model training process, it is necessary to define a loss function to measure the gap between them and use this as the basis for model optimization. This model uses the mean squared error as the evaluation index, that is, by squaring and then averaging the difference between the prediction value and the true value at each spatial position and road grade as the overall prediction error. Through this loss function, the backpropagation of the prediction error can be achieved, thereby continuously updating the model parameters and improving the prediction accuracy; Among them, the loss value represents the average deviation between the prediction result and the true value, the spatial number is used to identify different positions, the grade number is used to distinguish different road types, and both the prediction value and the true value are the values at the corresponding positions in the traffic flow three-dimensional matrix.
[0033] In this embodiment, the model uses a fully connected layer to map the hidden state sequence output by the GRU to the traffic flow prediction value at the target time point. In this process, each hidden state is first combined into an intermediate feature vector through a linear transformation (weighted summation plus bias term), and then the hyperbolic tangent function (tanh) is applied for non-linear activation to enhance the expressive power of the model. To prevent overfitting and improve generalization ability, the activation result is randomly discarded by neurons through the Dropout mechanism. Then, the weighted summation operation is performed again and the bias term is added to output the final prediction result. The output prediction value is a matrix with the same dimension as the original three-dimensional traffic flow matrix, and its elements represent the traffic flow estimation values at each spatial position and road level at the prediction time point. To supervise the training process, the model constructs a loss function with the mean squared error (MSE) as the core. The calculation method is to take the average of the squares of the differences between the prediction value and the corresponding true value. This loss function will be used in the error backpropagation stage to guide the optimizer to update the model parameters such as the weighted matrix and bias term of the connection layer, so as to continuously improve the prediction accuracy of the model on the validation set and the test set.
[0034] S5 includes defining a traffic flow feature calculation module. In response to the requirements of road traffic flow characteristics and clustering, a traffic flow feature calculation method is introduced. For a specific road, the calculation method of its traffic flow feature sequence is as follows: the multiple collected traffic flow data at each time point on this road are averaged respectively, and then the traffic flow feature sequence of this road in this time period is formed. Each value in this sequence represents the average traffic flow feature at the corresponding time point. A traffic flow feature clustering module is established. Self-organizing mapping neural networks are established for the section sets of different road grades respectively, and the sections are clustered according to the road traffic flow characteristics. This network determines the neuron with the smallest distance as the best matching unit of the current road by calculating the Euclidean distance between the traffic feature sequence of each road and the weight vectors of each neuron in the network. Then, the weight vector corresponding to this neuron is updated according to the input features. This update process is carried out according to the topological position relationship between neurons and the decreasing law of the learning rate. Finally, the unit category matched by the updated neuron weight is the category to which this section belongs.
[0035] In this embodiment, first, a traffic flow feature calculation module is constructed. By statistically processing multiple traffic flow data (such as flow, speed, density, etc.) collected at consecutive time points on a specific road, mainly using the mean processing method, the average of multiple sampling data at each time point is calculated to form a continuous traffic flow feature sequence. This sequence objectively reflects the traffic change trend of the road during the observation period and becomes the input basis for subsequent clustering analysis. Subsequently, self-organizing mapping neural networks are respectively constructed for road section sets of different levels. The SOM network takes the traffic flow feature sequence as the input. By calculating the Euclidean distance between this sequence and the weight vectors of each node (neuron) in the neural network, the best matching unit (BMU), that is, the neuron most similar to the input, is determined. After determining the BMU, the network adjusts its weight vector according to the topological structure and updates the weights of neighboring neurons. The update amplitude is dynamically adjusted according to the distance from the BMU and the learning rate decay strategy. After several rounds of training, the SOM network forms a classification structure with clustering ability. Different neuron regions represent different types of traffic behavior patterns, and finally, all input road sections can be assigned to corresponding categories according to their traffic flow characteristics.
[0036] S5 also includes calculating the residual data set. For each road, the difference between its original traffic flow data set and the traffic flow features is calculated respectively, that is, the original traffic flow information is subtracted from the obtained traffic flow feature value to obtain the traffic disturbance residual data set at each time point of this road section. This residual represents the actual traffic fluctuation situation. Construct a residual prediction model. For different types of road sections under different road grades, a random forest model is established respectively to predict the residual values. The specific method is to use multiple decision tree models for training. Each model uses different subset samples and feature combinations to divide the data and output the prediction results. Finally, the average of the prediction results of all trees is taken as the final output. During training, the grid traffic flow information and time are used as input labels, and the residual values obtained in the previous step are used as the target values for modeling. During prediction, the traffic information at the corresponding time point is input, and the predicted residual of the current road section can be output.
[0037] Based on traffic flow feature clustering, this embodiment further introduces a residual modeling mechanism to improve the prediction ability for local traffic disturbances and microscopic changes. First, calculate the residual data set, that is, for each road at each time point, subtract its original traffic flow value from the average feature value represented by the clustering to obtain a sequence of residual values. This residual reflects the deviation degree of the traffic flow relative to the feature model, reflecting the dynamic volatility and sudden disturbances in actual operation. Then, for different road grades (such as expressways, arterial roads, sub-arterial roads, and branch roads) and the set of roads within the clustering category, construct residual prediction models respectively. The selected model is a random forest, which consists of multiple decision trees and models the residual values through an ensemble learning method. Each tree is independently trained on different data subsets and uses different feature combinations to improve the generalization ability and anti-overfitting ability of the model. During training, the input is the grid traffic flow features containing information such as spatial location, road grade, and timestamp, and the target is the residual value at the corresponding time point; during prediction, the model accepts new input features and outputs the predicted disturbance residual. Finally, the residual prediction results will be merged with the clustering average value to restore the complete traffic flow prediction value at the section level, reflecting the fusion state of the macroscopic trend and microscopic disturbances, and improving the accuracy and fine-grained performance of the overall prediction system.
[0038] To solve the technical problems in the foregoing background art, Figure 1 FIG. is a schematic flow chart of the steps of a method for predicting the spatio-temporal distribution of urban long-term and large-scale traffic flow based on multi-level road operation information provided by an embodiment of the present disclosure. The method for predicting the spatio-temporal distribution of urban long-term and large-scale traffic flow based on multi-level road operation information will be introduced in detail below.
[0039] S1: Preprocess traffic flow information.
[0040] In the embodiment of the present invention, we need to perform long-term and large-scale predictions on the spatio-temporal distribution of traffic flow in a city. First, we need to select a certain city as the prediction location. Then, according to the characteristics of the city, divide the predictable range that can be covered into several grids according to the actual situation. Based on the geographical information within the grid, divide the grid road sections into different grades, namely expressways, arterial roads, sub-arterial roads, and branch roads. Each grade of road section has different traffic characteristics and traffic flow conditions. Then, we obtain a traffic flow database, which records data such as traffic volume and average vehicle speed of each road section at different time periods, match the traffic flow database to each grade of road section within the grid range, and calculate the grid traffic flow information. And use the grid traffic flow information to construct a traffic flow information matrix for a specific time period, fully mining the spatio-temporal distribution characteristics of traffic flow. Based on the prediction requirements of the spatio-temporal distribution of traffic flow, determine the traffic flow information matrix required to construct the traffic flow information event sequence, and then determine the traffic flow information matrix for predicting future time nodes.
[0041] In a possible implementation, the foregoing step S1 can be implemented in the following manner.
[0042] S11: Define the grid matrix And determine the grid associated road segments. According to the predicted urban characteristics, define a grid matrix that can cover the predicted range. The size of each grid is determined according to the actual situation, and a total of i rows j columns of grids are established. Based on the obtained geographical information, determine the road segments of each level within the range of each grid, and form a corresponding road level segment set, which can be expressed as: (1) (2) Wherein, is the grid matrix, is the grid of the i-th row and j-th column, is the grid the set of road segments with road level c within the range, is the grid the n-th road segment with road level c within the range, c = 1, 2, 3, 4, representing expressway, arterial road, sub-arterial road, and branch road respectively; S12: Calculate the grid traffic flow information. The traffic flow information includes, but is not limited to, data related to traffic volume and speed associated with road segments and time periods. Take the average of the traffic flow information of each level of road segments within the range of each grid for each time period, and regard it as the traffic flow information of the road of this level in the grid during this time period, which can be expressed as: , (3) Wherein, represents the traffic flow information, t is the time, in hours, is the traffic flow information of the road with road level c in the grid during the t time period, is the traffic flow information monitored by the n-th road segment with road level c in the grid at the t time; S13: Construct the traffic flow information matrix for a specific time period. According to the spatial numbers i, j and the road level c, construct the three-dimensional traffic flow information matrix at the specific time t. It is a three-dimensional matrix of i×j×c, and its elements are the corresponding traffic flow information after normalization, as follows: (4) Wherein, is the element value corresponding to the three-dimensional traffic flow information matrix at the t time at i, j, c, is the traffic flow information of the road with road level c in the grid during the t time period, is the upper limit value of traffic flow information, which is determined according to the actual traffic flow situation; S14: Construct a traffic flow information time series. Based on the traffic flow information matrix of a specific time period , combined with the actual traffic flow information prediction demand, determine the time interval length T for prediction, and predict the input time series can be expressed as: (5) where, is the predicted input time series, T is the time interval, which is determined according to the actual prediction demand, is the three-dimensional traffic flow information matrix at time t; S15: Determine the traffic flow information matrix corresponding to the prediction node. Corresponding to the predicted input time series , determine the length of the future time node to be predicted , then the traffic flow information matrix corresponding to the prediction node is .
[0043] S2: Use the channel attention and spatial attention mechanisms to construct a spatial convolution network module to extract spatial features.
[0044] The channel attention mechanism and the spatial attention mechanism are mechanisms used to enhance the neural network's perception and learning of input information. The channel attention mechanism is used to adjust the weights between different channels, enabling the network to pay more attention to the feature channels useful for the current task. The spatial attention mechanism can help the network focus on important regions in the spatial dimension and extract more accurate and effective spatial features. By integrating the channel attention and spatial attention mechanisms into the spatial convolution network module, the network can pay more attention to capturing and utilizing key features during the feature extraction process, thereby improving the network's performance in tasks such as object recognition and classification. This design idea of the spatial convolution network module combined with the attention mechanism helps the network extract spatial features more accurately when processing complex images and spatial data, and improves the generalization ability and effect of the model.
[0045] In a possible implementation manner, the foregoing step S2 can be implemented in the following way.
[0046] S21: Define a convolutional neural network module. For the predicted input time series , use the convolutional neural network CNN to extract the spatial characteristic information at each moment and establish spatial dependence. The specific process is that for each moment in the time series , they are respectively input into the convolutional layer, and the formula for data transfer between convolutional layers is: (6) (7) (8) Among them, is the output of the k-th layer convolution at time t, is the output of the (k - 1)-th layer convolution at time t, , is the weight parameter of to be trained, is the bias parameter of to be trained, is the ReLU activation function, is the normalization function, is the mean function, is the variance function, is the parameter to enhance stability, with a default value of 1e - 5, is the affine function to be trained, is the convolution; S22: Define the channel attention mechanism module. For the multiple channels generated after convolution, introduce the channel attention mechanism to determine the key channels that will affect the prediction accuracy, and enhance the weight of the information stored in the key channels in subsequent predictions. The module calculation formula is: (9) (10) (11) Among them, is the output of the convolutional neural network module at time t, is the corresponding attention matrix, is the Sigmoid activation function, is the weight parameter of the feedforward layer MLP of the multi-layer perception mechanism, which is updated during the training process, is the average pooling function, is the max pooling function, is the output of the convolutional neural network module at time t updated by the channel attention mechanism, is the convolution; is the Kronecker product; S23: Define the spatial attention mechanism module. For the matrix coordinates retained after convolution, introduce the spatial attention mechanism to determine the key regions that will affect the prediction accuracy, and enhance the weight of the information stored in these key regions in subsequent predictions. The module calculation formula is: (12) (13) Among them, is the output of the convolutional neural network module at time t after being updated by the channel attention mechanism, is the corresponding attention matrix, is the Sigmoid activation function, is the convolution operation using a 5×5 convolution kernel, and its parameters are updated during the training process, is the concatenation function, which is used to concatenate matrices in different dimensions, is the average pooling function, is the max pooling function, is the output of the convolutional neural network module at time t after being updated by the channel attention mechanism and the spatial attention mechanism, is the Kronecker product; S24: Update the traffic flow information time series. Based on the output information containing spatial features extracted by the convolutional module , update the traffic flow information time series for input to the next step. The time series after extracting spatial features can be expressed as: (14) where is the time series after extracting spatial features; T is the time interval, which is determined according to the actual prediction requirements, is the output of the convolutional neural network module at time t after being updated by the channel attention mechanism and the spatial attention mechanism.
[0047] S3: Construct a time recurrent network module to capture long-term and short-term time-dependent features and extract temporal features.
[0048] When dealing with time series data, capturing long-term and short-term time-dependent features is crucial for improving the prediction performance of the model. To achieve this goal, a time recurrent network module can be introduced to learn and extract the long-term and short-term dependency features in the time series data. The time recurrent network module usually adopts mechanisms such as the LSTM structure or the gated recurrent unit (GRU) to address issues such as gradient vanishing and gradient explosion in the time series data. By learning the dependency relationships between different time points in the time series data, the extraction of long-term and short-term temporal features is realized. The module accepts the current input and the hidden state of the previous time step as inputs at each time step to dynamically update the internal state, thereby modeling the time series data. By processing the time series data through multiple iterations, a new hidden state is generated at each time step. These hidden states contain the model's understanding and encoding of the sequence data, forming a representation of the time-dependent features at different time scales. Through continuous iterative learning, the module can effectively capture the correlation information between different time points in the data, thereby better understanding the dynamic change law of the time series data.
[0049] In a possible implementation, the foregoing step S3 can be implemented in the following manner.
[0050] S31: Construct a time recurrent network module based on the GRU network to capture the long short-term time dependence features in the time series. The GRU relies on a gating mechanism to extract the long short-term time dependence relationship, including an update gate and a reset gate. Specifically, the update gate is used to control the degree to which the state information at the previous moment affects the current state, and the reset gate is used to control how much information from the previous state is written into the next state. Through the above mechanism, the GRU network can effectively capture the dependence relationship of the state information between adjacent time nodes in the time series. The specific module process is as follows: (15) (16) (17) (18) (19) Among them, is the update gate at time t, is the reset gate at time t, is the candidate set of the hidden state at time t, is the hidden state at time t, , , are the weight matrices to be trained corresponding to the gate information respectively, , , are the weight matrices to be trained corresponding to the hidden states of the gates respectively, , , are the bias terms to be trained corresponding to the gates respectively, is the output of the convolutional neural network module at time t updated by the channel attention mechanism and the spatial attention mechanism, is the Hadamard product, is the Sigmoid activation function, is the tanh activation function; S32: Construct a hidden state sequence. Output the hidden state according to the time information of each moment extracted, and construct a hidden state sequence, which is prepared to establish an association relationship with the predicted value. The specific formula is: (20) Among them, is the hidden state sequence output for the time series , is the hidden state at time t.
[0051] S4: Construct a connection layer module for regression prediction to achieve the prediction of the spatio-temporal distribution of traffic flow in the grid area.
[0052] In the embodiment of the present invention, we establish a fully connected layer that relates the relationship between the hidden state sequence and the output prediction value, and reduces the overfitting phenomenon by processing the feature parameters and using the neuron dropout function and the activation function. In addition, we construct a loss function to measure the error between the model prediction value and the true value, and optimize the model parameters by minimizing the mean square error, thereby improving the prediction accuracy. These steps provide a framework for effectively processing time series data and optimizing model parameters, which helps to improve the prediction ability of the spatio-temporal distribution of traffic flow. This model may play an important role in fields such as smart city traffic management, and its practical applications and improvement directions can be further explored in the future.
[0053] In a possible implementation manner, the foregoing step S4 can be implemented in the following way.
[0054] S41: Establish a fully connected layer to achieve the regression relationship construction between the hidden state sequence and the output prediction value. Through the fully connected layer, the construction of the hidden regression relationship between the extracted feature parameters and the prediction value is realized. The specific formula is: (21) where is the output prediction value, is the hidden state sequence output for the time series , , are the weight matrices to be trained for the corresponding connection layers respectively, , are the weight matrices to be trained for the corresponding connection layers respectively, is the neuron dropout function used to reduce overfitting, is the tanh activation function; S42: Construct the loss function. In the process of model training, to reduce the error between the output prediction value and the actual value , it is necessary to establish the connection relationship between the two, compare the error values between the two, so as to realize the backpropagation of the error and continuously optimize the model parameters during training. This model uses MSE (mean square error) as an index to establish the loss function, and its formula is as follows: (21) where is the output prediction value and the true value The loss value between them, where i and j are spatial numbers, and c is the road grade. is a three-dimensional matrix The element value corresponding to i, j, c is a three-dimensional matrix The element value corresponding to i, j, c.
[0055] S5: Construct a traffic flow feature clustering and residual regression prediction module to realize the prediction of the spatio-temporal distribution of traffic flow on each road section within the grid.
[0056] The traffic flow feature calculation module and the traffic flow feature clustering module are two key modules proposed for the representation and clustering of road traffic flow. In the traffic flow feature calculation module, for a specific road, according to the collected traffic flow data, the traffic flow feature sequence of the road at different time points is calculated. In the traffic flow feature clustering module, a self-organizing mapping neural network is established to cluster the road sections of different road grades, and the road sections are classified according to the traffic flow features. The neural network determines the best matching unit by calculating the Euclidean distance between the traffic flow features and the neuron weight vectors. The neuron weights are iteratively updated until the network reaches stability, and finally the category to which the road section belongs is determined.
[0057] Then, in the calculation of the residual data set module, the residuals between the original traffic flow data and the traffic flow features are calculated for each road, which characterizes the traffic disturbance conditions occurring on the road sections. The calculation of the residual data set provides an important basis for the prediction of road section traffic flow. Finally, in the construction of the residual prediction model module, for the road sections of different clusters, a random forest model is established to predict the residuals. The mean value of the prediction results is calculated through multiple decision tree models, and the model is calibrated with the residuals as the output features, and finally the predicted residuals of the road sections are obtained. The coordinated action of these modules makes the prediction results of road section traffic flow more accurate and practical.
[0058] In a possible implementation manner, the foregoing step S5 can be implemented in the following way.
[0059] S51: Define a traffic flow feature calculation module. For the representation and clustering of road traffic flow, a traffic flow feature calculation module is introduced, and the traffic flow feature sequence of a specific road is calculated as follows: (22) Where is the traffic flow feature at time point and is the traffic flow feature at time point The th traffic flow data collected; S52: Establish a traffic flow feature clustering module. For the section sets of different road grades, establish self-organizing mapping neural networks respectively, and cluster the sections according to traffic flow features. The self-organizing mapping neural network calculates the Euclidean distance between the traffic flow features and the weight vectors of each neuron, and the neuron with the smallest distance is the best matching unit of this section. Iteratively update the neuron weights according to the traffic flow feature data matched by the neurons until the network reaches stability, and the final best matching unit is the category to which the section belongs. The above calculation process is shown in the following formula: (23) (24) (25) (26) Among them, is the weight vector of the neuron at the round, is the Euclidean distance between the traffic flow feature and the neuron, is the learning rate at the round; S53: Calculate the residual data set. For each road, calculate the difference between the original traffic flow data set and the traffic flow features to obtain a residual data set representing the traffic disturbances occurring on this section. The formula is as follows: (27) Among them, and are the i th residual and traffic flow data at the j moment of this section respectively; S54: Construct a residual prediction model. For the sections of different clusters under different road grades, establish random forest models to predict the residuals respectively. The random forest constructs multiple decision tree models that recursively split the data, and calculates the mean of the prediction results of all trees as the output. This model is calibrated with grid traffic flow information and time as input labels and residuals as output features. After calibration, the model takes the predicted grid traffic flow information and time as input to obtain the predicted residuals of the corresponding sections. The above process is shown as follows: (28) Among them, is the predicted residual, is the input vector formed by splicing grid traffic flow information and time, represents the set of randomly selected features and split points of the j th tree; S55: Calculate the predicted results of traffic flow on the road section. The predicted results of traffic flow on the road section are the direct sum of the predicted residuals and traffic flow characteristics at the corresponding time points, which can be expressed as: (29) Step S2 uses the channel attention and spatial attention mechanisms to construct a spatial convolutional network module to extract spatial features; the time recurrent network module that captures long-term and short-term time-dependent features constructed in step S3 extracts temporal features. Compare the model prediction accuracy test results before and after introducing the attention mechanism, and the results are shown in Table 1 and Figure 2 as shown. After introducing the attention mechanism, the relative error of the model is more concentrated around 0, the absolute value is smaller, and the loss during training and testing is also smaller. The efficiency and accuracy have been improved to varying degrees after introducing the attention mechanism.
[0060] Table 1 Comparison of model efficiency and accuracy before and after introducing the attention mechanism Parameter CNN-LSTM CNN-CBAM-LSTM Training time 35m 43s 24m 6s Training set loss 0.0028 0.0016 Test set loss 0.0025 0.0019 Mean absolute error 2.160% 0.999% The invention compares two network temporal feature extraction modules, LSTM (Long Short-Term Memory Network) and GRU (Gated Recurrent Unit). After training and comparison, it is found that both the CNN-CBAM-LSTM architecture and the CNN-CBAM-GRU architecture can better predict the high and peak hot spots of the grid speed. The prediction accuracy of the GRU network is slightly worse, but the efficiency is significantly better than that of the LSTM network. Therefore, the research finally plans to select the CNN-CBAM-GRU architecture for large-scale prediction.
[0061] Table 2 Comparison of efficiency and accuracy between LSTM and GRU modules Parameter CNN-LSTM CNN-CBAM-LSTM CNN-CBAM-GRU Training time 35m 43s 24m 6s 14m 56s Training set loss 0.0028 0.0016 0.0016 Test set loss 0.0025 0.0019 0.0019 Mean absolute error 2.160% 0.999% 1.094% Although the embodiments of the present invention have been shown and described, for those of ordinary skill in the art, it can be understood that various changes, modifications, substitutions, and variations can be made to these embodiments without departing from the principles and spirit of the present invention. The scope of the present invention is defined by the appended claims and their equivalents.
Claims
1. A method for predicting the spatiotemporal distribution of urban traffic flow based on multi-level road operation information, characterized in that: The method comprises: S1, traffic flow information preprocessing; S2. Use channel attention and spatial attention mechanisms to build a spatial convolutional network module to extract spatial features; S3, construct a time recurrent network module that captures long-term and short-term time dependency features and extracts temporal features; S4, construct a connection layer module for regression prediction to achieve the prediction of spatiotemporal distribution of traffic flow in the grid area; S5. Construct a traffic flow feature clustering and residual regression prediction module to realize the prediction of the spatiotemporal distribution of traffic flow in each section within the grid.
2. The method for predicting the spatiotemporal distribution of urban traffic flow based on multi-level road operation information according to claim 1 is characterized in that: The S1 includes: Define a grid matrix covering the prediction area, and determine the associated road sections corresponding to each grid. The size of the grid is determined according to the actual urban situation. The matrix contains a number of rows and columns of grids. Based on the acquired geographic information, determine the road sections of different levels included in each grid, and construct a set of road grade sections under each grid. The road grades are divided into expressways, trunk roads, secondary trunk roads and branch roads. The traffic flow information of different levels of road sections within each grid is collected in different time periods, and then the average traffic flow information of all sections of the level in each time period is taken as the average traffic flow information of the road of the level in the grid in the time period; Based on the traffic flow information calculated in the previous step, a three-dimensional traffic flow information matrix is constructed in each specific time period. The dimensions of the three-dimensional traffic flow information matrix include spatial position and road grade, and its elements are normalized traffic flow information. The normalization operation is to divide the original traffic flow information by a maximum value determined according to the actual traffic conditions, so as to obtain a traffic characteristic matrix under a unified dimension.
3. The method for predicting the spatiotemporal distribution of urban traffic flow based on multi-level road operation information according to claim 2 is characterized in that: The S1 further comprises: Construct a time series of traffic flow information. Take the selected time interval as the unit and combine the three-dimensional traffic flow information matrices of multiple consecutive moments into a sequence in chronological order for the input of subsequent prediction tasks. The length of the time series is determined by the actual prediction requirements. Based on the above time series, the traffic flow information prediction result at a certain time point in the future is determined. The specific method is to specify the span of the prediction time point, combine the input time series, and obtain the traffic flow information matrix at the required prediction time point, whose dimension is consistent with the single input matrix.
4. The method for predicting the spatiotemporal distribution of urban traffic flow based on multi-level road operation information according to claim 1 is characterized in that: The S2 includes: Define the convolutional neural network module. For the time series of the prediction input, use the convolutional neural network to extract the spatial characteristic information at each moment to establish spatial dependency. The specific process is as follows: the three-dimensional traffic flow information matrix at each moment in the time series is input into multiple convolutional layers respectively. The data is transmitted layer by layer between the convolutional layers. The output of each convolutional layer is first normalized, and then subjected to weight calculation and nonlinear activation processing with bias terms. The normalization process includes mean normalization and variance standardization of the input data to enhance the stability of the model training. Finally, it is multiplied by the scaling parameter and the offset is added. A channel attention mechanism module is defined. For the multiple channels contained in the output of the convolutional layer, a channel attention mechanism is introduced to identify the key channels that have a greater impact on the prediction accuracy. The mechanism first extracts global features from each channel through average pooling and maximum pooling, and then passes the extracted features into the multi-layer perception network for weight calculation. Finally, a channel attention matrix is generated. This attention matrix will act on the original channel output, strengthen the role of key channels in subsequent networks, and improve the overall prediction ability.
5. The method for predicting the spatiotemporal distribution of urban traffic flow based on multi-level road operation information according to claim 4 is characterized in that: The S2 further includes: Define the spatial attention mechanism module. For the spatial position of the matrix retained in the output of the convolution layer, introduce the spatial attention mechanism to identify the areas that have a key impact on the prediction effect. The mechanism first performs average pooling and maximum pooling on the feature matrix to form two compressed features in the spatial dimension, and then connects the two and inputs them into a convolution operation with a five-by-five convolution kernel. After this process is processed by a nonlinear activation function, a spatial attention matrix is generated. Finally, the matrix is weighted and fused with the original spatial features to enhance the expression ability of the key spatial area. Update the time series of traffic flow information. Based on the spatial features output by the above convolution module that integrate the channel attention and spatial attention mechanisms, combine them into a new spatial feature time series in chronological order, which will be used as the input for traffic flow information modeling in subsequent steps. The length of the newly generated time series is set according to the actual prediction needs to ensure that historical features can be fully extracted to improve prediction accuracy.
6. The method for predicting the spatiotemporal distribution of urban traffic flow based on multi-level road operation information according to claim 1, characterized in that: The S3 includes: A temporal recurrent network module based on a gated recurrent unit network is constructed to capture the long-term and short-term temporal dependency features in the time series. The gated recurrent unit realizes the effective extraction of temporal dependency through a gating mechanism. The mechanism mainly includes an update gate and a reset gate. The update gate controls the influence of the state information at the previous moment on the current state, while the reset gate controls how much information in the previous state is passed to the current state. Through the above mechanism, the gated recurrent unit network can effectively capture the dependency between each time node in the time series. In the specific module calculation process, first, according to the convolutional neural network module output at the current moment and the hidden state at the previous moment, the activation values of the update gate and the reset gate are calculated respectively; then the outputs of the two gates are combined to calculate the candidate hidden state at the current moment, and finally, the final hidden state at the current moment is obtained by combining the weighted results of the previous hidden state and the candidate hidden state. In the above process, multiple weight matrices and bias terms to be trained are used, and the activation functions include Sigmoid function and hyperbolic tangent function.
7. The method for predicting the spatiotemporal distribution of urban traffic flow based on multi-level road operation information according to claim 6 is characterized in that: The S3 further includes: Construct a hidden state sequence, output the hidden state according to the extracted time information of each moment, and form a complete hidden state sequence. This sequence serves as the basis for constructing the prediction value in the subsequent steps and is used to establish the mapping relationship between the features and the prediction target. The length of the hidden state sequence corresponds to the input time series, and the hidden state at each moment is retained for the next prediction processing.
8. The method for predicting the spatiotemporal distribution of urban traffic flow based on multi-level road operation information according to claim 1 is characterized in that: The S4 includes: Establish a fully connected layer to construct the regression relationship between the hidden state sequence and the output prediction value. The fully connected layer establishes the regression output structure of the prediction model by combining the features and nonlinear mapping of the hidden state sequence. Specifically, the hidden state sequence is first weighted and summed and a bias term is added. Then, it is activated by a hyperbolic tangent function, and then filtered by a neuron discarding mechanism. Finally, after the weighted summation and bias correction of the second layer, the final prediction value is output. Among them, the output prediction value represents the traffic flow information at the predicted time point, the hidden state sequence represents the set of hidden states at each moment in the input time series, and the weight matrix and bias term are the parameters to be trained in the connection layer; Construct a loss function. In order to minimize the error between the output prediction value and the actual value during the model training process, a loss function needs to be defined to measure the gap between them and use it as the basis for model optimization. This model uses the mean square error as the evaluation indicator, that is, the difference between the predicted value and the actual value at each spatial position and road level is squared and then averaged as the overall prediction error. Through this loss function, the back propagation of the prediction error can be realized, thereby continuously updating the model parameters and improving the prediction accuracy. Among them, the loss value represents the average deviation between the predicted result and the true value, the spatial number is used to identify different locations, the level number is used to distinguish different road types, and the predicted value and the true value are both the values of the three-dimensional traffic flow matrix at the corresponding positions.
9. The method for predicting the spatiotemporal distribution of urban traffic flow based on multi-level road operation information according to claim 1, characterized in that: The S5 includes: Define the traffic flow feature calculation module. In view of the needs of road traffic flow features and clustering, introduce the traffic flow feature calculation method. For a specific road, the traffic flow feature sequence is calculated as follows: average the multiple traffic flow data collected at each time point of the road, and then form the traffic flow feature sequence of the road at each time point. Each value of the sequence represents the average traffic flow feature at the corresponding time point. A traffic flow feature clustering module is established, and a self-organizing mapping neural network is established for each set of road sections of different road grades. The road sections are clustered according to the road traffic flow characteristics. The network calculates the Euclidean distance between the traffic feature sequence of each road and the weight vector of each neuron in the network, and determines the neuron with the smallest distance as the best matching unit for the current road. Then, the weight vector corresponding to the neuron is updated according to the input features. The updating process is based on the topological position relationship between neurons and the law of decreasing learning rate. Finally, the unit category matched by the updated neuron weight is the category to which the road section belongs.
10. The method for predicting the spatiotemporal distribution of urban traffic flow based on multi-level road operation information according to claim 9, characterized in that: The S5 further includes: Calculate the residual data set. For each road, calculate the difference between its original traffic flow data set and the traffic flow characteristics, that is, subtract the obtained traffic flow characteristic value from the original traffic flow information to obtain the residual data set of traffic disturbance at each time point of the road section. The residual represents the actual traffic fluctuation situation. A residual prediction model is constructed. For different types of road sections under different road grades, random forest models are established to predict residual values. The specific method is to use multiple decision tree models for training. Each model uses different subset samples and feature combinations to divide the data and output the prediction results. Finally, the prediction results of all trees are averaged as the final output. During training, grid traffic flow information and time are used as input labels, and the residual value obtained in the previous step is used as the target value for modeling. When predicting, the traffic information at the corresponding time point is input to output the predicted residual of the current section.
Citation Information
Patent Citations
Road network state prediction method based on capsule network and nested long / short-term memory neural network
CN109410575A
Traffic state index prediction method based on space-time factors
CN111210088A
Power distribution network short-term load prediction method based on deep neural network combination model
CN113393339A
Power load prediction method, device and terminal
CN113570105A
Cost prediction method and device based on self-correction fusion model
CN114066036A
Cited By
Traffic flow prediction method and device
CN120452209A
Induction signal phase duration prediction method based on TSpixel
CN120726830A
Green wave control method based on traffic flow prediction driving
CN121459605A
Urban carbon emission regression prediction method
CN121809781A
Large-scale urban road network traffic state prediction method based on graph neural network
CN122135561A