A method and device for short-term traffic flow prediction based on deep learning method

By using the U-TFMamba model in traffic flow prediction, combined with UNet and TFMamba modules, the problems of insufficient traffic flow prediction accuracy and long training time in the existing technology are solved, and accurate prediction of traffic flow and speed in the short term is achieved. , improving the accuracy and reliability of prediction.

CN118538036BActive Publication Date: 2024-09-27SICHUAN INTELLIGENT TRANSPORTATION SYST MANAGEMENT CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411014310.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-26
Publication Date
2024-09-27
Estimated Expiration
2044-07-26

AI Technical Summary

Technical Problem

Existing traffic flow prediction models suffer from problems such as insufficient accuracy, high input data requirements, and long training time. It is especially difficult to effectively use real-time data for short-term predictions, making it difficult to solve the dynamic congestion problem.

Method used

The U-TFMamba model based on deep learning is used, combined with UNet and TFMamba modules, to optimize data preprocessing and model training through clustered data selection and virtual node center network, reducing input data requirements and training time, and improving prediction accuracy.

Benefits of technology

It achieves accurate prediction of traffic flow and average speed in the short term, improves the accuracy and reliability of traffic flow prediction, provides more effective decision support, and reduces model training time and input data requirements.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118538036B
    Figure CN118538036B
Patent Text Reader

Abstract

The present invention relates to the field of traffic information analysis, and in particular to a method and device for short-term traffic flow prediction based on deep learning methods. The present invention establishes a short-term traffic flow prediction method based on deep learning based on a newly constructed U‑TFMamba model. The model uses the UNet model as a framework and creatively adds an optimized TFMamba module, which effectively reduces the requirements for input data and reduces the training time of the model. The model can accurately predict the flow, speed and other information of each point to be detected in the short term in the future, thereby improving the accuracy and reliability of traffic flow prediction and providing more effective decision support for road managers.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of traffic information analysis, and in particular to a method and device for short-term traffic flow prediction based on a deep learning method. Background Art

[0002] Traffic flow state prediction is the basis for traffic induction and reasonable traffic control, and is a prerequisite for the realization of intelligent transportation. However, the randomness and dynamic characteristics of traffic flow determine the difficulty of prediction, which has always been a research difficulty and hotspot in the field of transportation. Among them, short-term traffic flow prediction is an early warning forecast of traffic conditions in the future time scale of less than 15 minutes. It is a key task to assist intelligent transportation systems in making decisions, solve dynamic congestion problems, and improve road capacity; while long-term traffic flow prediction focuses on traffic flow change patterns in days, months or longer periods, and provides support for road managers to make decisions on a longer time scale, such as the formulation of holiday control measures. Since the 1960s, experts and scholars from all over the world have developed various prediction models for traffic flow prediction using methods from various disciplines. According to the nature of the prediction method itself, the current traffic flow prediction models can be roughly divided into three categories: prediction models based on statistical theory, prediction models based on traditional machine learning methods, and prediction models based on deep learning methods.

[0003] Prediction models based on statistical theory focus on mining the spatiotemporal patterns of traffic flow from a probabilistic perspective and use the relevant information of this spatiotemporal pattern for prediction. Common models include: History Average Model, Time-Series Model, Kalman Filtering Mode, Nonparametric Regressive Model, etc. However, these models focus on mining the spatiotemporal patterns of traffic flow from a probabilistic perspective. Because they mainly rely on historical data, they cannot make full use of current traffic information. When traffic conditions change rapidly, the prediction accuracy of these models may be affected.

[0004] Prediction models based on traditional machine learning methods use computers to automatically learn traffic trends from traffic data and predict short-term traffic flows based on them. Common models include: K-Nearest Neighbor (KNN), Support Vector Regression (SVR), etc. These models use computers to automatically learn traffic trends from traffic data, but they may not be able to handle large-scale, high-dimensional data sets and are more sensitive to data preprocessing and feature selection.

[0005] The prediction model based on deep learning method is the development of traditional machine learning prediction model. It focuses on using deeper network models to mine data information to obtain better prediction results. Common models include: Recurrent Neural Network (RNN), Convolutional Neural Network (CNN), Graph Neural Networks (GNN), etc. Although deep learning models can process large-scale, high-dimensional data and achieve good prediction results, they require a large amount of data for training, and the computational complexity and training time are high during the training process. In addition, deep learning models are very sensitive to the selection of parameters, and different parameter configurations may lead to huge differences in prediction results. At the same time, the interpretability of deep learning models is poor, and their prediction results are difficult to understand.

[0006] Therefore, there is a need for a short-term traffic flow prediction model based on deep learning methods that can utilize real-time data, has low input data requirements, and requires less training time to improve road capacity and solve dynamic congestion problems. Summary of the invention

[0007] The purpose of the present invention is to overcome the problems of insufficient accuracy, high input data requirements and long training time in the prior art, and to provide a method and device for short-term traffic flow prediction based on a deep learning method.

[0008] In order to achieve the above-mentioned object of the invention, the present invention provides the following technical solutions:

[0009] A short-term traffic flow prediction method based on a deep learning method comprises the following steps:

[0010] a: Obtaining traffic data information of the area to be predicted; the traffic data information includes historical vehicle flow data and historical average speed data;

[0011] b: inputting the traffic data information into a pre-built short-term traffic flow prediction model;

[0012] c: Outputting the short-term traffic status prediction result of the area to be predicted; the short-term traffic status prediction result includes the traffic volume and average vehicle speed within a set time;

[0013] Specifically, the traffic flow short-term prediction model adopts the U-TFMamba model, which is based on the UNet model and has a TFMamba module between the UNet model encoder and decoder; the TFMamba module includes a cluster data selection module and several Mamba modules; the cluster data selection module is used to import data of different clusters into corresponding Mamba blocks;

[0014] The pre-construction of the traffic flow short-term prediction model includes the following steps:

[0015] S1: Obtain historical traffic data information, pre-process it and generate a training sample set;

[0016] S2: Construct a short-term traffic flow prediction model, perform model training on it through the training sample set, and output the short-term traffic flow prediction model after the model converges.

[0017] As a preferred embodiment of the present invention, S1 comprises:

[0018] S11: Obtain historical traffic data information;

[0019] S12: Performing data screening on the historical traffic data information to screen out data information whose error exceeds a preset threshold and whose missing data volume exceeds a preset value;

[0020] S13: reviewing the historical traffic data information after data screening, and repairing or deleting the data according to the review result, and outputting it as an original data matrix;

[0021] S14: preprocessing the original data matrix; the preprocessing includes: data preparation, extracting virtual nodes, and building a virtual node center network;

[0022] S15: Generate a training sample set.

[0023] As a preferred solution of the present invention, the data preparation comprises the following steps:

[0024] S141: Abnormal state identification: identifying the abnormal state of the original data matrix D in the historical traffic data information by defining an indicator function A(j, i), and adding the abnormal state mark to the data matrix D′; specifically:

[0025] ,

[0026] ,

[0027] ,

[0028] Among them, m is the number of nodes in the road network, n is the length of the time series data of a single node, and timestamp mn The timestamp of the m*nth record, including date and time information; ID mn is the node ID of the m*nth record; x mn is the parameter value of the m*nth record; x ji is the i-th historical time series data in node j, u j and are the historical time series data {x j1 ,x j2 ,...,x jn}mean and standard deviation;

[0029] S142: Periodic feature organization: split the timestamps in the data matrix D′, organize the data, and output a periodic feature data matrix V with a natural day as a period; its expression is:

[0030] ,

[0031] Among them, V(j,d,t) represents the value in the matrix V corresponding to the node ID j, date d and time t. x mfr represents the value in the matrix V corresponding to the node ID m, date f and time r, ID j is the ID of the jth node, ID j is the ID of the jth node, date d is the date data of the dth date, time t is the time data of the tth time, m is the number of nodes in the road network, f is the date length of the data, r is the time length of the data, and their relationship with the timestamp is:

[0032] ,

[0033] Among them, extract_date() and extract_time() are date data extraction formulas and time data extraction formulas respectively, timestamps w For the dataset D ′ The timestamp of the wth record, date w For timestamps w The date data of the wth data split out from the time w For timestamps w The time data of the wth data split out;

[0034] S143: Periodic data screening: Check whether there is data marked as abnormal for more than p consecutive hours through the preset Boolean variable isUnreliable(j, d), delete the data that satisfies isUnreliable(j, d)=True, and output the retained data set as matrix V′; its expression is:

[0035] ,

[0036] ,

[0037] in, represents the number of time steps per hour, s is the time step in minutes, pq is the continuous time step to be checked, A(j,d,t z+i ) means that when the node ID in the matrix V is j and the date is d, the data from time z to time z+i are all marked as abnormal data.

[0038] As a preferred solution of the present invention, the extracting virtual nodes comprises the following steps:

[0039] All data V'(j, d, t) of the matrix V' are stored in a large data matrix X, where the expression of X is:

[0040] ,

[0041] Among them, x jdt is numerical data;

[0042] The k-means method is used to cluster the data matrix X, and its expression is:

[0043] ,

[0044] Where C is the center of the cluster, k-means() is the operation of the k-means clustering method, L is the category label to which each data point belongs, and k represents the best choice for the number of clusters, which is determined by the elbow rule;

[0045] According to the clustering result L, the data of each category is combined into the data of a virtual node:

[0046] ,

[0047] Among them, G i Represents the data of the i-th virtual node, L jdt is the category label corresponding to the data point V′(j,d,t), and V′(j,d,t) represents the value in the matrix V′ corresponding to the node ID j, date d, and time t.

[0048] As a preferred solution of the present invention, the construction of a virtual node center network includes the following steps:

[0049] In each virtual node G i In the time dimension, the center of the data in each sliding window is calculated with a sliding window of step size 1 and size h steps. The center of the data in the sliding window W(t) is calculated as follows:

[0050] ,

[0051] Where t-(h-1) is the start time of the sliding window W(t), t is the end time, and h-1 is the duration of the sliding window W(t); is a time-related hyperparameter, with a value range of [0, h-1];

[0052] According to each virtual node G i The center of the data in the sliding window W(t) is center(W(t)), generating a virtual node center network G center , whose expression is:

[0053] ,

[0054] Among them, T is the time set.

[0055] As a preferred solution of the present invention, the data audit includes integrity audit and accuracy audit;

[0056] The integrity review is to review whether there are missing and empty values ​​in the historical traffic data information;

[0057] If there are any missing data, we will choose to supplement or delete them according to the degree of missing data and the impact on the overall data;

[0058] Specifically, when the missing degree does not exceed the preset time length, the corresponding missing data is filled by the average of the previous and next data and the average of the historical average;

[0059] When the degree of missingness exceeds the preset time length, the corresponding missing data is filled by the historical average value;

[0060] If there is a null value, choose to assign or delete it according to the specific situation of the data:

[0061] The accuracy review is to review whether there are any abnormalities in the mean and standard deviation of the historical traffic data information; if there are any abnormalities, the corresponding historical traffic data information has accuracy defects, and the data is deleted according to the review results and then supplemented by linear interpolation.

[0062] As a preferred embodiment of the present invention, the operation of the U-TFMamba model includes the following steps:

[0063] 1) Data matching:

[0064] ①. For each actual node j, when predicting at time t, calculate the average value of its data in the time interval [t−(h-1), t], and its expression is:

[0065] ,

[0066] in, is the average value of real-time input data, For node j at t- The data at the moment, h is the sliding window step size, is a time-related hyperparameter, with a value range of [0, h-1];

[0067] ②. Calculate the distance between the node average value and the virtual node center. The expression is:

[0068] ,

[0069] in, is the distance between the node average and the virtual node center, is the central value of virtual node i in the sliding window W(t);

[0070] ③. Match the actual node j to the virtual node i that minimizes the distance (j,i,t3), and the expression is:

[0071] ,

[0072] in, is the virtual node i corresponding to the actual node j at time t, argmin i The value of i that minimizes distance(j,i,t);

[0073] 2) Data organization:

[0074] ①. For each virtual node i, filter out the data of all actual nodes that match the virtual node from the actual node data R. The expression is:

[0075] ,

[0076] Among them, R i (t) is the actual node data set contained in the virtual node i at time t, is the data of node j at time t;

[0077] ②. Each individual actual node data R i (t) is considered as a single input sample and these samples are organized into multiple batches. , For nth i batches of samples;

[0078] Where B is the batch size, is the batch quantity, for Round up value of ;

[0079] 3) Real-time prediction:

[0080] ①. Input the batch data into the corresponding virtual node model for prediction and return the prediction result. The expression is:

[0081] ,

[0082] Among them, prediction(i) is the prediction result of virtual node i, model i is the model calibrated for virtual node i, ;

[0083] Among them, batch is the input batch data;

[0084] ②. Integrate the prediction results of all virtual nodes, the expression is:

[0085] ,

[0086] Among them, predictions are the output prediction results.

[0087] As a preferred solution of the present invention, the pre-construction of the short-term traffic flow prediction model further includes step S3;

[0088] S3: verifying the traffic flow short-term prediction model through a preset evaluation function, and when the evaluation index is lower than the threshold, returning to step S2 to perform model training until the evaluation index is not lower than the threshold.

[0089] A traffic flow short-term prediction device based on a deep learning method comprises at least one processor and a memory communicatively connected to the at least one processor; the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute any of the methods described above.

[0090] Compared with the prior art, the present invention has the following beneficial effects:

[0091] According to the newly constructed U-TFMamba model, the present invention establishes a short-term traffic flow prediction method based on deep learning. The model takes the UNet model as the framework and creatively adds the optimized TFMamba module, which effectively reduces the requirements for input data and reduces the training time of the model. The model can accurately predict the vehicle flow, speed and other information of each point to be detected in the short term in the future, thereby improving the accuracy and reliability of traffic flow prediction and providing road managers with more effective decision-making support. BRIEF DESCRIPTION OF THE DRAWINGS

[0092] Figure 1 A schematic diagram of a flow chart of a method for short-term traffic flow prediction based on a deep learning method according to Embodiment 1 of the present invention;

[0093] Figure 2 A schematic diagram of the construction process of a short-term traffic flow prediction model in a short-term traffic flow prediction method based on a deep learning method according to Embodiment 1 of the present invention;

[0094] Figure 3 This is a schematic diagram of the structure of the U-TFMamba model in a short-term traffic flow prediction method based on a deep learning method described in Example 1 of the present invention;

[0095] Figure 4 A schematic diagram of a Mamba structure in a short-term traffic flow prediction method based on a deep learning method according to Embodiment 1 of the present invention;

[0096] Figure 5 It is a schematic diagram of an improved Multi-Mamba structure in a short-term traffic flow prediction method based on a deep learning method according to Embodiment 1 of the present invention;

[0097] Figure 6 This is a structural schematic diagram of a short-term traffic flow prediction device based on a deep learning method described in Example 4 of the present invention, which utilizes the short-term traffic flow prediction method based on a deep learning method described in Example 1. DETAILED DESCRIPTION

[0098] The present invention is further described in detail below in conjunction with test examples and specific implementation methods. However, this should not be understood as the scope of the above subject matter of the present invention being limited to the following embodiments, and all technologies realized based on the content of the present invention belong to the scope of the present invention.

[0099] Example 1

[0100] A short-term traffic flow prediction method based on a deep learning method comprises the following steps:

[0101] a: Obtain traffic data information of the area to be predicted; the traffic data information includes historical vehicle flow data and historical average speed data.

[0102] b: Input the traffic data information into a pre-built short-term traffic flow prediction model.

[0103] c: Output the short-term traffic status prediction result of the area to be predicted; the short-term traffic status prediction result includes the traffic flow and average speed within the set time. The traffic flow formula is: traffic flow = number of passing vehicles / time.

[0104] Furthermore, the short-term traffic status prediction result can also be used as data input for later processing of congested area prediction, so as to obtain congestion prediction information.

[0105] The traffic flow short-term prediction model adopts the U-TFMamba model, which is based on the UNet model and has a TFMamba module between the UNet model encoder and decoder; the TFMamba module includes a clustering data selection module and several Mamba modules; the clustering data selection module is used to import data of different clusters into corresponding Mamba blocks.

[0106] Specifically, Figure 2 As shown, the pre-construction of the short-term traffic flow prediction model includes the following steps:

[0107] S1: Obtain historical traffic data information, pre-process it and generate a training sample set.

[0108] S2: Construct a short-term traffic flow prediction model, perform model training on it through the training sample set, and output the short-term traffic flow prediction model after the model converges.

[0109] Specifically, the Mamba model is an innovative sequence modeling architecture that aims to solve the efficiency problem of traditional models (such as Transformer and LSTM) when processing long sequences. The Mamba model introduces Selective State Spaces, which enables the parameters of the model to change dynamically according to the input, thereby achieving selective propagation or forgetting of information. This feature enables it to perform well in processing discrete modalities (such as text) and complex reasoning tasks. At the same time, UNet's decoder-encoder structure can also effectively capture the spatiotemporal characteristics of traffic flow data, while improving the stability and memory capacity of the model.

[0110] This embodiment proposes for the first time to combine the Mamba module with the UNet model to form a new U-TFMamba model (such as Figure 3As shown in Figure 2, it consists of several convolutional layers and TFMamba modules).

[0111] The encoder-decoder of the model is composed of a UNet network. In order to improve the accuracy of the UNet network in long-sequence prediction, this embodiment superimposes a new and targeted TFMamba module on it to solve the key problems in traffic flow prediction. The model realizes comprehensive modeling of traffic flow data by realizing selective information propagation and fusion between the encoder and decoder, utilizing Mamba's long-sequence processing capabilities and UNet's multi-scale feature extraction capabilities. The TFMamba module introduces selective state space and efficient parallel algorithms, enabling the TFMamba module to capture complex dependencies when processing long-sequence data. Specifically, the TFMamba module performs well in capturing long-term dependencies in traffic flow data by dynamically adjusting model parameters, overcoming the common gradient vanishing and explosion problems of traditional models when processing long-sequence data. By selectively propagating or ignoring information, the TFMamba module enhances the flexibility and accuracy of the model in dealing with sudden changes and pattern changes in traffic flow.

[0112] As the infrastructure of the U-TFMamba model, the UNet model has been carefully optimized and tuned to ensure the effective extraction and processing of multi-scale features of traffic flow data. The encoder-decoder structure of UNet gradually extracts low-level and high-level features of the input data through a series of convolutional layers and maximum pooling layers, and gradually restores the spatial resolution of the data through transposed convolutional layers. The introduction of jump connections enables features to be directly transmitted between different levels, thereby retaining more detailed information and avoiding information loss during downsampling and upsampling. In this way, UNet can not only capture the short-term change characteristics of traffic flow data, but also extract long-term trends, providing comprehensive multi-scale feature modeling.

[0113] At the same time, the TFMamba module of this embodiment has been specifically adjusted and optimized for the prediction environment of the entire road network. In the environment of the entire road network, there are problems such as difficulty in aggregating multi-source data and large differences in traffic patterns in different road sections. In order to enhance the generalization ability of the model, this embodiment proposes a new Multi-Mamba structure. In the data processing stage, different data are first clustered, and then corresponding Mamba blocks are added to each different data class based on the number of clusters to achieve differentiated learning of different types of data. This structural design not only solves the problem of multi-source data fusion, but also captures the characteristic differences of different road sections, significantly improving the generalization ability and prediction accuracy of the model. Through this innovative adjustment, the TFMamba module can more effectively process complex traffic flow data, providing a more robust and adaptable solution for traffic flow prediction in the environment of the entire road network. Figure 4and Figure 5 As shown, the original Mamba structure and the Multi-Mamba structure proposed in this embodiment are respectively shown, wherein the Mamba structure is composed of a group of convolutional layers (conv layers) and SSM (State-Space Module), and the Mamba structure is first proposed in the article Gu, Dao, Mamba: Linear-time sequence modeling with selective state spaces. arXiv preprintarXiv:2312.00752., and the Multi-Mamba structure of the present invention is improved on the Mamba structure, and is composed of a clustering data selection module (whose purpose is to select training and prediction data to enter the corresponding SSM module), and convolutional layers and SSM modules corresponding to the number of clusters. Its purpose is to import different traffic clustering data into their corresponding Mamba blocks, and conduct targeted learning respectively, so as to obtain a more generalized prediction effect.

[0114] Example 2

[0115] This embodiment is a specific construction method of the traffic flow short-term prediction model described in Embodiment 1, including the following steps:

[0116] S1: Obtain historical traffic data information, pre-process it and generate a training sample set.

[0117] The data preprocessing process mainly includes three processes: data screening, data review and data organization. Before using the data, it is necessary to screen the data to ensure the authenticity, integrity and validity of the data as much as possible. If the error between the used data and the actual data is large, and the amount of missing data is too large, it may affect the feasibility of the model building process and the validity of the established model. The original data is mainly reviewed from the two aspects of integrity and accuracy. The integrity review mainly checks whether there are omissions in the data and whether all the data are filled in. It mainly checks whether there are missing and null values ​​in the data. If there are null values, you can choose to assign or delete them according to the specific situation of the data. If there are missing values, you need to choose to supplement or delete them according to the degree of missing data and the degree of impact on the overall data. The accuracy review mainly includes two aspects: one is to check whether the data truly reflects the objective actual situation and whether the content is in line with the actual situation; the second is to check whether there are errors in the data and whether the calculation is correct. It mainly checks whether there are abnormalities in the data based on the average and maximum values ​​of the data values ​​and the actual meaning of the data, and repairs or deletes the data according to the analysis results. Data organization is to organize the processed data into a matrix with a certain form according to the characteristics of the nature and law, such as arranging the feature data and label data in a purposeful manner according to the time sequence or period characteristics, where the feature data is the input variable, which has a certain influence on the output variable, such as the x variable in simple linear regression. The label data is the data to be predicted, such as the y variable in simple linear regression.

[0118] S11: Obtain historical traffic data information. The basic form of historical traffic data information is shown in Table 1 (taking speed as an example):

[0119] Table 1

[0120]

[0121] S12: Performing data screening on the historical traffic data information to screen out data information with an error exceeding a preset threshold and a missing data amount exceeding a preset value.

[0122] S13: auditing the historical traffic data information after data screening, and repairing or deleting the data according to the audit result, and outputting it as an original data matrix.

[0123] The data review includes completeness review and accuracy review;

[0124] The integrity review is to review whether there are missing and empty values ​​in the historical traffic data information;

[0125] If there are any missing data, we will choose to supplement or delete them according to the degree of missing data and the impact on the overall data;

[0126] If there is a null value, choose to assign or delete it according to the specific situation of the data:

[0127] The accuracy audit is to audit whether there are any abnormalities in the average and maximum values ​​of the historical traffic data information; if there are abnormalities, the corresponding historical traffic data information has accuracy defects, and the data is repaired or deleted according to the audit results. The accuracy audit specifically includes the following steps:

[0128] (1) Find outliers and missing values

[0129] The data is grouped according to the different data source IDs in the data source ID column. Then, for each data source ID group, the mean and standard deviation of the corresponding speed column are calculated. Next, the 3sigma method is used to determine the range of outliers. If the speed of a data point exceeds this range, it is marked as an outlier and replaced with NaN. At the same time, find the missing values ​​in the data and mark them with NaN.

[0130] (2) Supplementing abnormal and missing values

[0131] After confirming the abnormal and missing data, focus on dealing with the outliers and missing values ​​in the data. This step is to ensure that the data set is more complete and reliable. At this stage, the linear interpolation method is used. The principle of linear interpolation is to infer the possible values ​​of the data based on the linear relationship between known data points. This method maintains the continuity and trend of the data to a certain extent, thereby improving the availability of the data set and the accuracy of the analysis.

[0132] S14: performing data preprocessing on the original data matrix; the preprocessing includes: data preparation, extracting virtual nodes, and constructing a virtual node center network;

[0133] The data preparation includes the following steps:

[0134] S141: Abnormal state identification: identifying the abnormal state of the original data matrix D in the historical traffic data information by defining an indicator function A(j, i), and adding the abnormal state mark to the data matrix D′; specifically:

[0135] ,

[0136] ,

[0137] ,

[0138] Among them, m is the number of nodes in the road network, n is the length of the time series data of a single node, and timestamp mn The timestamp of the m*nth record, including date and time information; IDmn is the node ID of the m*nth record; x mn is the parameter value of the m*nth record; x ji is the i-th historical time series data in node j, u j and are the historical time series data {x j1 ,x j2 ,...,x jn}mean and standard deviation;

[0139] S142: Periodic feature organization: split the timestamps in the data matrix D′, organize the data, and output a periodic feature data matrix V with a natural day as a period; its expression is:

[0140] ,

[0141] Among them, V(j,d,t) represents the value in the matrix V corresponding to the node ID j, date d and time t. x mfr represents the value in matrix V corresponding to node ID m, date f, and time r, ID j is the ID of the jth node, ID j is the ID of the jth node, date d is the date data of the dth date, time t is the time data of the tth time, m is the number of nodes in the road network, f is the date length of the data, r is the time length of the data, and their relationship with the timestamp is:

[0142] ,

[0143] Among them, extract_date() and extract_time() are date data extraction formulas and time data extraction formulas respectively, timestamps w For the dataset D ′ The timestamp of the wth record, date w For timestamps w The date data of the wth data split out from the time w For timestamps w The time data of the wth data split out;

[0144] S143: Periodic data screening: Check whether there is data marked as abnormal for more than p consecutive hours through the preset Boolean variable isUnreliable(j, d), delete the data that satisfies isUnreliable(j, d)=True, and output the retained data set as matrix V′; its expression is:

[0145] ,

[0146] ,

[0147] in, represents the number of time steps per hour, s is the time step in minutes, pq is the continuous time step to be checked, A(j,d,t z+i ) means that when the node ID in the matrix V is j and the date is d, the data from time z to time z+i are all marked as abnormal data.

[0148] The extracting of virtual nodes comprises the following steps:

[0149] All data V'(j, d, t) of the matrix V' are stored in a large data matrix X, where the expression of X is:

[0150] ,

[0151] Among them, x jdt is numerical data;

[0152] The k-means method is used to cluster the data matrix X, and its expression is:

[0153] ,

[0154] Where C is the center of the cluster, k-means() is the operation of the k-means clustering method, L is the category label to which each data point belongs, and k represents the best choice for the number of clusters, which is determined by the elbow rule;

[0155] According to the clustering result L, the data of each category is combined into the data of a virtual node:

[0156]

[0157] Among them, G i Represents the data of the i-th virtual node, L jdt is the category label corresponding to the data point V′(j,d,t), and V′(j,d,t) represents the value in the matrix V′ corresponding to the node ID j, date d, and time t.

[0158] The construction of the virtual node center network includes the following steps:

[0159] In each virtual node G i In the time dimension, the center of the data in each sliding window is calculated with a sliding window of step size 1 and size h steps. The center of the data in the sliding window W(t) is calculated as follows:

[0160]

[0161] Where t-(h-1) is the start time of the sliding window W(t), t is the end time, and h-1 is the duration of the sliding window W(t); is a time-related hyperparameter, with a value range of [0, h-1];

[0162] According to each virtual node G i The center of the data in the sliding window W(t) is center(W(t)), generating a virtual node center network G center , whose expression is:

[0163]

[0164] Among them, T is the time set.

[0165] S15: Generate a training sample set.

[0166] S2: Construct a short-term traffic flow prediction model, perform model training on it through the training sample set, and output the short-term traffic flow prediction model after the model converges.

[0167] The operation of the U-TFMamba model includes the following steps:

[0168] 1) Data matching:

[0169] ①. For each actual node j, when predicting at time t, calculate the average value of its data in the time interval [t−(h-1), t], and its expression is:

[0170] ,

[0171] in, is the average value of real-time input data, For node j at t- The data at the moment, h is the sliding window step size, is a time-related hyperparameter, and its value range is [0, h-1];

[0172] ②. Calculate the distance between the node average value and the virtual node center. The expression is:

[0173] ,

[0174] in, is the distance between the node average and the virtual node center, is the central value of virtual node i in the sliding window W(t);

[0175] ③. Match the actual node j to the virtual node i that minimizes the distance (j,i,t), and its expression is:

[0176] ,

[0177] in, is the virtual node i corresponding to the actual node j at time t, argmin i The value of i that minimizes distance(j,i,t);

[0178] 2) Data organization:

[0179] ①. For each virtual node i, filter out the data of all actual nodes that match the virtual node from the actual node data R. The expression is:

[0180] ,

[0181] Among them, R i (t) is the actual node data set contained in the virtual node i at time t, is the data of node j at time t;

[0182] ②. Each individual actual node data R i (t) is considered as a single input sample and these samples are organized into multiple batches. , For nth i batches of samples;

[0183] Where B is the batch size, is the batch quantity, for The rounded-up value of ; that is, the batch number is determined by rounding up division;

[0184] 3) Real-time prediction:

[0185] ①. Input the batch data into the corresponding virtual node model for prediction and return the prediction result. The expression is:

[0186] ,

[0187] Among them, prediction(i) is the prediction result of virtual node i, model i is the model calibrated for virtual node i, ;

[0188] Among them, batch is the input batch data;

[0189] ②. Integrate the prediction results of all virtual nodes, the expression is:

[0190] ,

[0191] Among them, predictions are the output prediction results.

[0192] Example 3

[0193] The difference between this embodiment and embodiment 2 is that the pre-construction of the short-term traffic flow prediction model also includes S3.

[0194] S3: verifying the traffic flow short-term prediction model through a preset evaluation function, and when the evaluation index is lower than the threshold, returning to S2 for model training until the evaluation index is no lower than the threshold.

[0195] After completing the model construction, it is necessary to select appropriate model evaluation indicators to verify the model. For prediction problems, the main evaluation indicators include Mean Squared Error (MSE), Root Mean Squared Error (RMSE), Mean Absolute Error (MAE), and Coefficient of Determination (R2). The calculation formula is as follows:

[0196] The expression of mean square error MSN is:

[0197] ,

[0198] The expression of root mean square error RMSE is:

[0199] ,

[0200] The expression of mean absolute error MAE is:

[0201] ,

[0202] Coefficient of determination R 2 The expression is:

[0203] ,

[0204] Among them, m is the amount of data, yi is the actual value, is the predicted value, for y i The mean of the four performance evaluation indicators is greater than 0, and the R2 value range is [0,1]. The closer the R2 value is to 1, the better the model prediction effect is. The smaller the other three evaluation indicators are, the better the model prediction effect is. The evaluation indicators can reflect the effectiveness of the constructed model to a certain extent, but they do not have absolute significance. On the one hand, the output results of the model will be affected by the data quality and data organization form. On the other hand, for practical application problems, it is only necessary to achieve the expected purpose of the task. Obtaining higher accuracy beyond the task goal may require more resource loss. By outputting the visualization results of the model evaluation indicators, the prediction effect of the model can be intuitively judged. By analyzing the values ​​of specific evaluation indicators, the reliability of the model can be judged. If the effect of the constructed model is not good, it is necessary to adjust the hyperparameters in the model to improve the accuracy of the model. Usually, the hyperparameters that need to be adjusted in deep learning models include the number of neural network layers, the number of neural network nodes per layer, the learning rate, the number of iterations, the time step, etc. The general methods for adjusting parameters include grid parameter adjustment, greedy parameter adjustment, Bayesian parameter adjustment, etc. In general, for a small number of hyperparameters and a single model, the difficulty of adjusting the model is relatively low.

[0205] Real data verification example:

[0206] 473 nodes were randomly selected from a provincial road network as pilot areas, and historical traffic data from May 1, 2023 to May 31, 2023 were used as the corresponding research data, with a time granularity of 2 minutes. The data from the last week of May in the pilot area were selected from the historical data as the test set to evaluate the prediction performance of the model, and the other data were used as the training set.

[0207] This verification example selects the mean percentage error (MAPE) and mean absolute error (MAE) as evaluation indicators of model accuracy. The mean percentage error focuses on the error percentage of the model prediction value relative to the actual value, and the mean absolute error focuses on the average absolute deviation of the model prediction value. In addition, in the real-time prediction of the entire road network, the prediction time (TIME) is an important indicator, which indicates the time required for the model to complete a real-time prediction of the road network. The prediction time directly affects the practicality and deployability of the model, so it needs to be paid special attention.

[0208] The expression for mean percentage error (MAPE) is:

[0209]

[0210] The expression of mean absolute error MAE is:

[0211]

[0212] Where N is the total number of samples; y (i) is the measured value of speed; f(x (i) ) is the speed prediction value

[0213] Table 2

[0214] Prediction step length (min) MAPE (%) MAE (km / h) TIME(s) 30 21.68 19.36 1.9

[0215] The evaluation results of the model on the test set are shown in Table 2. The prediction step (30 minutes) means that the model predicts the traffic speed data for the next 30 minutes each time. The MAPE value is 21.68%, which means that the average prediction error of the model accounts for 21.68% of the actual value; the MAE value is 19.36, which means that the average absolute deviation between the model prediction value and the actual value is 19.36 km / h. The lower MAPE and MAE values ​​indicate that the model has good prediction accuracy and generalization ability. At the same time, the TIME value is 1.9, which means that the model completed the real-time prediction of 473 nodes in the road network within 1.9 seconds, indicating that the model can quickly complete the road network prediction, which is very important for real-time traffic management and emergency response.

[0216] Example 4

[0217] like Figure 6 As shown, a traffic flow short-term prediction device based on a deep learning method includes at least one processor, a memory connected to the at least one processor, and at least one input-output interface connected to the at least one processor; the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the traffic flow short-term prediction method based on a deep learning method described in the above embodiment. The input-output interface may include a display, a keyboard, a mouse, and a USB interface for inputting and outputting data.

[0218] Those skilled in the art can understand that: all or part of the steps of implementing the above method embodiments can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above method embodiments; and the aforementioned storage medium includes: mobile storage devices, read-only memories (ROM), disks or optical disks, etc. Various media that can store program codes.

[0219] When the above-mentioned integrated unit of the present invention is implemented in the form of a software functional unit and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present invention can be essentially or partly reflected in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROMs, magnetic disks, or optical disks.

[0220] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the present invention.

Claims

1. A short-term traffic flow prediction method based on deep learning method, characterized in that: The following steps are involved: a: Obtaining traffic data information of the area to be predicted; the traffic data information includes historical vehicle flow data and historical average speed data; b: inputting the traffic data information into a pre-built short-term traffic flow prediction model; c: Outputting the short-term traffic status prediction result of the area to be predicted; the short-term traffic status prediction result includes the traffic volume and average vehicle speed within a set time; Specifically, the traffic flow short-term prediction model adopts the U-TFMamba model, which is based on the UNet model and has a TFMamba module between the UNet model encoder and decoder; the TFMamba module includes a cluster data selection module and several Mamba modules; the cluster data selection module is used to import data of different clusters into corresponding Mamba blocks; The pre-construction of the traffic flow short-term prediction model includes the following steps: S1: Obtain historical traffic data information, pre-process it and generate a training sample set; S2: constructing a short-term traffic flow prediction model, training the model through the training sample set, and outputting the short-term traffic flow prediction model after the model converges; The S1 includes: S11: Obtain historical traffic data information; S12: performing data screening processing on the historical traffic data information, screening out data information whose error exceeds a preset threshold and whose missing data volume exceeds a preset value; S13: reviewing the historical traffic data information after data screening, and repairing or deleting the data according to the review result, and outputting it as an original data matrix; The data review includes completeness review and accuracy review; The integrity review is to review whether there are missing and empty values ​​in the historical traffic data information; If there are any missing data, we will choose to supplement or delete them according to the degree of missing data and the impact on the overall data; Specifically, when the degree of missingness does not exceed the preset time length, the corresponding missing data is filled by the average of the previous and next data and the average of the historical average; When the missing degree exceeds the preset time length, the corresponding missing data is filled by the historical average value; If there is a null value, choose to assign or delete it according to the specific situation of the data: The accuracy review is to review whether there are any abnormalities in the mean and standard deviation of the historical traffic data information; if there are any abnormalities, the corresponding historical traffic data information has accuracy defects, and the data is deleted according to the review results and then supplemented by linear interpolation; S14: preprocessing the original data matrix; the preprocessing includes: data preparation, extracting virtual nodes, and building a virtual node center network; The data preparation includes the following steps: S141: Abnormal state identification: identifying the abnormal state of the original data matrix D in the historical traffic data information by defining an indicator function A(j, i), and adding the abnormal state mark to the data matrix D′; specifically: , , , Among them, m is the number of nodes in the road network, n is the length of the time series data of a single node, and timestamp mn The timestamp of the m*nth record, including date and time information; ID mn is the node ID of the m*nth record; x mn is the parameter value of the m*nth record; x ji is the i-th historical time series data in node j, u j and are the historical time series data {x j1 ,x j2 , ... ,x jn }mean and standard deviation; S142: Periodic feature organization: split the timestamps in the data matrix D′, organize the data, and output a periodic feature data matrix V with a natural day as a period; its expression is: , Among them, V(j,d,t) represents the value in the matrix V corresponding to the node ID j, date d and time t. x mfr represents the value in matrix V corresponding to node ID m, date f, and time r, ID j is the ID of the jth node, date d is the date data of the dth date, time t is the time data at time t, m is the number of nodes in the road network, f is the date length of the data, r is the time length of the data, and their relationship with the timestamp is: , Among them, extract_date() and extract_time() are date data extraction formulas and time data extraction formulas respectively, timestamps w For the dataset D ′ The timestamp of the wth record, date w For timestamps w The date data of the wth data split out from the time w For timestamps w The time data of the w-th data split out; S143: Periodic data screening: Check whether there is data marked as abnormal for more than p consecutive hours through the preset Boolean variable isUnreliable(j, d), delete the data that satisfies isUnreliable(j, d)=True, and output the retained data set as matrix V′; its expression is: , , in, represents the number of time steps per hour, s is the time step in minutes, pq is the continuous time step to be checked, A(j,d,t z+i ) means that when the node ID in the matrix V is j and the date is d, the data from time z to time z+i are all marked as abnormal data; The extracting of virtual nodes comprises the following steps: All data V'(j, d, t) of the matrix V' are stored in a large data matrix X, where the expression of X is: , Among them, x jdt is numerical data; The k-means method is used to cluster the data matrix X, and its expression is: , Where C is the center of the cluster, k-means() is the operation of the k-means clustering method, L is the category label to which each data point belongs, and k represents the best choice for the number of clusters, which is determined by the elbow rule; According to the clustering result L, the data of each category is combined into the data of a virtual node: , Among them, G i Represents the data of the i-th virtual node, L jdt is the category label corresponding to the data point V′(j,d,t), V′(j,d,t) represents the value in the matrix V′ corresponding to the node ID j, date d and time t; The construction of the virtual node center network includes the following steps: In each virtual node G i In the time dimension, the center of the data in each sliding window is calculated with a sliding window of step size 1 and size h steps. The center of the data in the sliding window W(t) is calculated as follows: , Where t-(h-1) is the start time of the sliding window W(t), t is the end time, and h-1 is the duration of the sliding window W(t); is a time-related hyperparameter, with a value range of [0, h-1]; According to each virtual node G i The center of the data in the sliding window W(t) is center(W(t)), generating a virtual node center network G center , whose expression is: , Where T is the time set; S15: Generate a training sample set.

2. The method for short-term traffic flow prediction based on deep learning method according to claim 1, characterized in that: The operation of the U-TFMamba model includes the following steps: 1) Data matching: ①. For each actual node j, when predicting at time t, calculate the average value of its data in the time interval [t−(h-1), t], and its expression is: , in, is the average value of real-time input data, For node j at t- The data at the moment, h is the sliding window step size, is a time-related hyperparameter, with a value range of [0, h-1]; ②. Calculate the distance between the node average value and the virtual node center. The expression is: , in, is the distance between the node average and the virtual node center, is the central value of virtual node i in the sliding window W(t); ③. Match the actual node j to the virtual node i that minimizes the distance (j,i,t), and its expression is: , in, is the virtual node i corresponding to the actual node j at time t, argmin i The value of i that minimizes distance(j,i,t); 2) Data organization: ①. For each virtual node i, filter out the data of all actual nodes that match the virtual node from the actual node data R. The expression is: , Among them, R i (t) is the actual node data set contained in the virtual node i at time t, is the data of node j at time t; ②. Each individual actual node data R i (t) is considered as a single input sample and these samples are organized into multiple batches. , For nth i batches of samples; Where B is the batch size, is the batch quantity, for Round up value of ; 3) Real-time prediction: ①. Input the batch data into the corresponding virtual node model for prediction and return the prediction result. The expression is: , Among them, prediction(i) is the prediction result of virtual node i, model i is the model calibrated for virtual node i, ; Among them, batch is the input batch data; ②. Integrate the prediction results of all virtual nodes, the expression is: , Among them, predictions are the output prediction results.

3. The method for short-term traffic flow prediction based on deep learning method according to claim 1, characterized in that: The pre-construction of the traffic flow short-term prediction model also includes step S3; S3: verifying the traffic flow short-term prediction model through a preset evaluation function, and when the evaluation index is lower than the threshold, returning to step S2 to perform model training until the evaluation index is not lower than the threshold.

4. A short-term traffic flow prediction device based on deep learning method, characterized in that: It includes at least one processor and a memory communicatively connected to the at least one processor; the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method described in any one of claims 1 to 3.