Traffic flow prediction method and system based on CNN-LSTM-At

The CNN-LSTM-At model is combined with the spatiotemporal characteristics of ETC data and uses the attention mechanism to predict traffic flow, which solves the shortcomings of existing methods in feature processing and data collection equipment, and achieves more accurate and interpretable traffic flow prediction. .

CN118116200BActive Publication Date: 2024-09-17SHANDONG HI SPEED GRP CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410360158.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-03-27
Publication Date
2024-09-17
Estimated Expiration
2044-03-27

AI Technical Summary

Technical Problem

Existing traffic flow prediction methods may ignore important factors when processing feature parameters, the data collection equipment of the deep learning model is not convenient for accurate analysis, and the model has poor interpretability.

Method used

A traffic flow prediction method based on CNN-LSTM-At is adopted, using the spatio-temporal characteristic data collected by ETC, extracting spatial features through CNN, extracting temporal features through LSTM, and introducing an attention mechanism for importance weighting to achieve accurate prediction of traffic flow.

Benefits of technology

It improves the accuracy and model interpretability of traffic flow prediction, can better capture the complex spatiotemporal changing characteristics of traffic flow, and enhances the prediction ability of deep neural networks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118116200B
    Figure CN118116200B
Patent Text Reader

Abstract

The present invention proposes a traffic flow prediction method and system based on CNN-LSTM-At, and relates to the technical field of traffic flow prediction. It includes obtaining ETC breakpoint data of multiple ETC gantries on a highway, converting the ETC breakpoint data into average data of a road section by segment processing, reconstructing vehicle trajectories, and performing abnormal data processing on the reconstructed data to obtain original data; inputting the original data into a CNN-LSTM-At model, extracting spatial features using the CNN model, and then inputting the spatial features into an LSTM model, extracting temporal features using the LSTM model, and introducing an attention mechanism to weight the importance of the aforementioned spatial features and temporal features, so as to realize the prediction of traffic flow. The present invention uses traffic data collected by ETC to predict traffic flow. The traffic data collected by ETC has spatiotemporal characteristics, hides more information, and has an identification function, which is convenient for accurate analysis and research of more parameters in traffic data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of traffic flow prediction, and in particular relates to a traffic flow prediction method and system based on CNN-LSTM-At. Background Art

[0002] At present, traffic flow prediction methods can be divided into three categories: parameter models, deep learning models, and combination models. Parameter models include traditional statistical models and integrated methods, among which classic regression models include autoregressive moving average model (ARIMA), linear regression, and logistic regression. However, parameter models such as ARIMA often rely on a large number of assumptions and require a large amount of historical data for model training. Their prediction results are greatly affected by the sample size. Therefore, researchers have gradually introduced deep learning methods such as convolutional neural networks and recursive neural networks into the field of traffic flow prediction.

[0003] Considering the temporal and spatial variation characteristics of traffic flow, the long short-term memory network as a special RNN method has been widely used in the field of traffic flow prediction. At present, the traffic flow prediction method based on LSTM is relatively mature, but further research is still needed on the following issues:

[0004] 1) Treating characteristic parameters equally in each traffic flow prediction process may ignore some factors that have important influence on the prediction;

[0005] 2) Most traffic flow prediction models use coil sensors, vehicle GPS data, and simulation data. Data obtained using unmarked collection devices such as coils and radars are not convenient for accurate analysis of more parameters in traffic data.

[0006] 3) The “black box” problem of deep learning models reduces the interpretability of such models in traffic flow prediction problems. Summary of the invention

[0007] In order to overcome the shortcomings of the above-mentioned prior art, the present invention provides a traffic flow prediction method and system based on CNN-LSTM-At, and uses traffic data collected by ETC to predict traffic flow. The traffic data collected by ETC has temporal and spatial characteristics and hides more information. Compared with other collection devices with no breakpoint identification such as coils and radars, ETC data has an identification function, which is convenient for accurate analysis and research on more parameters in traffic data.

[0008] To achieve the above objectives, one or more embodiments of the present invention provide the following technical solutions:

[0009] The first aspect of the present invention provides a traffic flow prediction method based on CNN-LSTM-At.

[0010] The traffic flow prediction method based on CNN-LSTM-At includes the following steps:

[0011] Obtain ETC breakpoint data from multiple ETC gantries on the highway, convert the ETC breakpoint data into average data of the road section by segment processing, reconstruct the vehicle trajectory, and perform abnormal data processing on the reconstructed data to obtain the original data;

[0012] The original data is input into the CNN-LSTM-At model, and the spatial features are extracted using the CNN model. The spatial features are then input into the LSTM model, and the temporal features are extracted using the LSTM model. The attention mechanism is introduced to weight the importance of the aforementioned spatial and temporal features to achieve traffic flow prediction.

[0013] Optionally, the connection and restoration of the entire driving trajectory of the vehicle entering the toll station, passing the gantry, and exiting the toll station can be achieved through the unique passID of the vehicle passing through the highway:

[0014] Calculate the mileage, average speed and average travel time of vehicles on the section between two adjacent gantries or the section between a gantries and a toll booth;

[0015] The average speed and flow of all vehicles on each road section are calculated according to the set time to obtain the traffic parameter status of the road section, that is, the average data of the road section.

[0016] Optionally, also include:

[0017] Extract and separate the gantry data of all vehicles in the highway system;

[0018] Based on the license plate number, gantry adjacency and driving speed factors, the missed vehicle trajectory is identified and the vehicle spatial trajectory is reconstructed using the K nearest neighbor algorithm.

[0019] The reconstructed data is processed for abnormal data, including erroneous data elimination and missing data filling, to obtain the original data.

[0020] Optionally, the format of the original data is an N×M matrix, where N represents the time series length of the original data, and M represents the traffic characteristic information of each time period.

[0021] Optionally, the spatial features of the original data are extracted through a CNN model consisting of convolutional layers, pooling layers, and fully connected layers.

[0022] Optionally, the output of the LSTM is calculated as follows:

[0023]

[0024] h t =o t⊙tanh(c t )

[0025] Among them, the time step is t; the input is x t , the hidden state at the previous moment is h t-1 , the cell state is c t-1 ; ☉ represents element-by-element product; o t is the output gate; W c is the input x t The weight matrix, U c is the hidden state h at the previous moment t-1 The weight matrix, b c is the bias vector, tanh is the hyperbolic tangent function; f t =σ(W f x t +U f h t-1 +b f ), W f is the input x t The weight matrix, U f is the hidden state h at the previous moment t-1 The weight matrix, b f is the bias vector, σ is the sigmoid function; i t =σ(W i x t +U i h t-1 +b i ), W i is the input x t The weight matrix, U i is the hidden state h at the previous moment t-1 The weight matrix, b i is the bias vector.

[0026] Optionally, a temporal attention module and a spatial attention module are introduced. In the temporal dimension, the attention mechanism is used to adaptively assign different importances to the data according to the traffic conditions at different time slices; in the spatial dimension, the attention mechanism is used to adaptively capture the dynamic correlation between nodes.

[0027] The second aspect of the present invention provides a traffic flow prediction system based on CNN-LSTM-At.

[0028] Traffic flow prediction system based on CNN-LSTM-At, including:

[0029] The preprocessing module is configured to: obtain ETC breakpoint data of multiple ETC gantries on the highway, convert the ETC breakpoint data into average data of the road section by segment processing, reconstruct the vehicle trajectory, and perform abnormal data processing on the reconstructed data to obtain the original data;

[0030] The prediction module is configured as follows: input the original data into the CNN-LSTM-At model, use the CNN model to extract spatial features, then input the spatial features into the LSTM model, use the LSTM model to extract temporal features, and introduce the attention mechanism to weight the importance of the aforementioned spatial features and temporal features to achieve traffic flow prediction.

[0031] The third aspect of the present invention provides a computer-readable storage medium having a program stored thereon, which, when executed by a processor, implements the steps in the traffic flow prediction method based on CNN-LSTM-At as described in the first aspect of the present invention.

[0032] The fourth aspect of the present invention provides an electronic device, including a memory, a processor, and a program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps in the traffic flow prediction method based on CNN-LSTM-At as described in the first aspect of the present invention are implemented.

[0033] One or more of the above technical solutions have the following beneficial effects:

[0034] The present invention provides a traffic flow prediction method and system based on CNN-LSTM-At, which uses traffic data collected by ETC to predict traffic flow. The traffic data collected by ETC has spatiotemporal characteristics and hides more information. Compared with other collection devices with breakpoints and no markings, such as coils and radars, ETC data has a marking function, which is convenient for accurate analysis and research on more parameters in traffic data.

[0035] The present invention combines CNN and LSTM and uses the attention mechanism to improve the effect of the model. First, CNN is used to extract various spatiotemporal data features in the traffic parameter sequence, while reducing the number of parameters and retaining the main feature information; secondly, LSTM is used to process time series data, learn the changing rules of traffic status, and capture the complex dynamic spatiotemporal change characteristics of traffic flow; finally, the Attention mechanism is introduced to learn node weights to extract effective content information, thereby improving the interpretability of the deep neural network model.

[0036] Advantages of additional aspects of the present invention will be given in part in the following description, and in part will become obvious from the following description, or will be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] The accompanying drawings in the specification, which constitute a part of the present invention, are used to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute improper limitations on the present invention.

[0038] Figure 1 This is a flow chart of the method of the first embodiment.

[0039] Figure 2 This is a data flow chart of the LSTM model of the first embodiment.

[0040] FIG3( a ) is a diagram showing the average speed prediction results of the CNN model of the first embodiment.

[0041] FIG3( b ) is a graph showing the average speed prediction results of the LSTM model of the first embodiment.

[0042] FIG3( c ) is a graph showing the average speed prediction results of the CNN-LSTM model of the first embodiment.

[0043] FIG. 3( d ) is a diagram showing the average speed prediction results of the model of the first embodiment of the present invention.

[0044] FIG4( a ) is a diagram showing the flow prediction results of the CNN model of the first embodiment.

[0045] FIG4( b ) is a diagram showing the traffic prediction results of the LSTM model of the first embodiment.

[0046] FIG4( c ) is a diagram showing the flow prediction results of the CNN-LSTM model of the first embodiment.

[0047] FIG. 4( d ) is a diagram showing the flow prediction results of the model of the first embodiment of the present invention. DETAILED DESCRIPTION

[0048] It should be noted that the following detailed descriptions are exemplary and are intended to provide further explanation of the present invention. Unless otherwise specified, all technical and scientific terms used herein have the same meanings as those commonly understood by those skilled in the art to which the present invention belongs.

[0049] It should be noted that the terms used herein are for describing specific embodiments only and are not intended to be limiting of exemplary embodiments according to the present invention.

[0050] In the absence of conflict, the embodiments of the present invention and the features of the embodiments may be combined with each other.

[0051] The overall idea proposed by the present invention is:

[0052] The development of highway informatization provides reliable data support for the safe operation of highways. While completing the highway toll collection business, the ETC system also collects a large amount of transaction and vehicle passing data. ETC data with high coverage and accuracy can provide economical and reliable data support for travel big data analysis and traffic operation management. Therefore, this study analyzes the changing trend of highway traffic flow based on ETC data, estimates and predicts the traffic operation status of highways, and aims to use the existing highway infrastructure data to propose an accurate traffic status prediction method, provide vehicles with congestion warning information in a timely manner, and thus improve the traffic efficiency of highways.

[0053] Based on ETC data, this paper designs a highway traffic flow prediction model called CNN-LSTM-Attention. This model combines CNN and LSTM and uses the attention mechanism to improve the effect of the model. The specific research ideas are as follows:

[0054] Firstly, CNN is used to extract various spatiotemporal data features from traffic parameter sequences, which reduces the number of parameters while retaining the main feature information.

[0055] Secondly, LSTM is used to process time series data, learn the changing rules of traffic status, and capture the complex dynamic spatiotemporal change characteristics of traffic flow;

[0056] Finally, the Attention mechanism is introduced to learn node weights to extract effective content information, thereby improving the interpretability of the deep neural network model.

[0057] Embodiment 1

[0058] This embodiment discloses a traffic flow prediction method based on CNN-LSTM-At.

[0059] like Figure 1 As shown in FIG. 1 , the traffic flow prediction method based on CNN-LSTM-At includes the following steps:

[0060] Obtain ETC breakpoint data from multiple ETC gantries on the highway, convert the ETC breakpoint data into average data of the road section by segment processing, reconstruct the vehicle trajectory, and perform abnormal data processing on the reconstructed data to obtain the original data;

[0061] The original data is input into the CNN-LSTM-At model, and the spatial features are extracted using the CNN model. The spatial features are then input into the LSTM model, and the temporal features are extracted using the LSTM model. The attention mechanism is introduced to weight the importance of the aforementioned spatial and temporal features to achieve traffic flow prediction.

[0062] Furthermore, the obtained ETC breakpoint data is preprocessed, specifically including:

[0063] Through the unique passID of the vehicle passing through the highway, the connection and restoration of the vehicle's entire driving trajectory from entering the toll station, passing the gantry, and exiting the toll station can be achieved:

[0064] Calculate the mileage, average speed and average travel time of vehicles on the section between two adjacent gantries or the section between a gantries and a toll booth;

[0065] The average speed and flow of all vehicles on each road section are calculated according to the set time to obtain the traffic parameter status of the road section, that is, the average data of the road section.

[0066] Furthermore, it also includes:

[0067] Extract and separate the gantry data of all vehicles in the highway system;

[0068] Based on the license plate number, gantry adjacency and driving speed factors, the missed vehicle trajectory is identified and the vehicle spatial trajectory is reconstructed using the K nearest neighbor algorithm.

[0069] The reconstructed data is processed for abnormal data, including erroneous data elimination and missing data filling, to obtain the original data.

[0070] like Figure 1 As shown, this embodiment proposes a CNN-LSTM prediction model integrating attention mechanism for traffic flow parameter prediction of highway sections. The model first combines CNN and LSTM networks to form a CNN-LSTM neural network: the CNN network is used to extract spatial features and correlations between feature variables, and the LSTM model is further selected to extract temporal features of historical time series data; then the attention mechanism is introduced to weight the importance of the spatiotemporal feature information extracted by the CNN-LSTM network, so as to give full play to the advantages of the three, thereby improving the prediction accuracy of the model.

[0071] according to Figure 1 As shown in the figure, the CNN-LSTM-Attention model consists of three main components: CNN, LSTM, and Attention. CNN is mainly used to effectively extract nonlinear local features and mine the correlation between data to generate more important feature information; LSTM focuses on learning the temporal dynamic change rules of local features extracted by CNN; and the attention mechanism is mainly used to weight feature information.

[0072] The entire CNN-LSTM-Attention prediction model is designed with a four-level structure, and its detailed construction process is as follows:

[0073] 1) Input layer: Input the training data into the prediction model. The format of the input data is an N×M matrix, where N represents the time series length of the training data and M represents the traffic characteristic information of each time period.

[0074] 2) CNN layer: The spatiotemporal features of the input data are extracted through three convolutional layers, a pooling layer, and a fully connected layer. The attention mechanism is introduced in the CNN layer to enhance the spatiotemporal feature correlation between sequences, and the enhanced sequence data is passed to the subsequent model. The number of convolution kernels is 50, the size is 3×3, and the step size is 1. The pooling layer performs dimensionality reduction processing on the input high-dimensional feature data to improve the calculation speed of the convolutional neural network and prevent overfitting. The maximum pooling strategy is adopted, the pooling kernel size is 2×2, and the step size is 2. A Dropout layer is added after the pooling layer and the LSTM layer to effectively prevent overfitting. The fully connected layer is used as a regression output layer to output spatiotemporal feature data, reduce the influence of feature position on the classification results, and improve the robustness of the entire network.

[0075] 3) LSTM layer: It mines the temporal correlation of the input data sequence. The three-layer LSTM network can better capture the long-term dependencies in long sequence data and improve the modeling ability of sequence data. The number of LSTM neurons is 128.

[0076] 4) Output layer: outputs the prediction results of the model.

[0077] (1)CNN

[0078] Convolutional neural network is one of the representative algorithms in the field of deep learning. It is a feedforward neural network that includes convolution calculation and deep structure, and can achieve end-to-end learning. CNN usually includes data input layer, convolution layer, activation layer, pooling layer and fully connected layer. The complete CNN structure can be formed by iterative calculation of each layer

[13] . In terms of traffic prediction, CNN can extract effective features from traffic data, and automatically learn and extract spatial features and local patterns in data through convolution and pooling operations. Secondly, CNN is suitable for spatiotemporal modeling. It constructs a deep network structure through multi-layer convolution and pooling operations, and effectively captures the spatiotemporal dependencies in traffic data. Compared with traditional methods based on statistical methods or regression models, CNN can better capture nonlinear relationships and complex patterns in data, thereby improving the accuracy and precision of prediction.

[0079] (2) LSTM

[0080] Long short-term memory (LSTM) is a variant of RNN. It is used to solve the long-term dependency problem that is common in general recurrent neural networks. Its core concepts are cell states and “gate” structures

[14] . LSTM can learn the changing patterns of traffic conditions based on historical traffic data and predict future traffic conditions. Figure 2 As shown in the figure, the LSTM model takes historical traffic data as the input sequence and future traffic data as the output sequence, and achieves accurate traffic flow prediction by capturing the complex dynamic change characteristics of traffic flow.

[0081] At time step t, suppose the input is x t , the hidden state at the previous moment is h t-1 , the cell state is c t-1 , the calculation of LSTM is as follows: First, calculate the forget gate f t , controls the degree of forgetting of the unit state at the previous moment:

[0082] f t =σ(W f x t +U f h t-1 +b f ) (1)

[0083] Among them, W f is the input x t The weight matrix, U f is the hidden state h at the previous moment t-1 The weight matrix, b f is the bias vector and σ is the sigmoid function.

[0084] Then, calculate the input gate i t , controls the degree of input of new information:

[0085] i t =σ(W i x t +U i h t-1 +b i ) (2)

[0086] Among them, W i is the input x t The weight matrix, U i is the hidden state h at the previous moment t-1 The weight matrix, b i is the bias vector and σ is the sigmoid function.

[0087] Next, calculate the new cell state Used to update the current unit status:

[0088]

[0089] Among them, W c is the input x t The weight matrix, U c is the hidden state h at the previous moment t-1 The weight matrix, b c is the bias vector and tanh is the hyperbolic tangent function.

[0090] Finally, calculate the current cell state c t , and update the hidden state h t , thus obtaining the output of the model:

[0091]

[0092] h t =o t ⊙tanh(c t ) (5)

[0093] Among them, ☉ represents the element-by-element product, o t Is the output gate, used to control the output level:

[0094] o t =σ(W o x t +U o h t-1 +b o ) (6)

[0095] Among them, W o is the input x o The weight matrix, U o is the hidden state h at the previous moment t-1 The weight matrix, b o is the bias vector and σ is the sigmoid function.

[0096] (3) Attention Mechanism

[0097] The attention mechanism can assign different weights according to the importance of different information. Its core idea is to extract effective content information by learning node weights. Its calculation principle is shown in formula (7). There are three main types of attention mechanisms in convolutional neural networks: spatial domain, channel domain, and mixed domain. Spatial attention is to pay different attention to different positions on the convolutional layer, and channel attention is mainly manifested in the different attention to different channels. At the same time, considering the information in the channel domain and the local information in each channel, the spatial and channel attention are combined to obtain the mixed attention mechanism.

[0098] Attention(Query,Source)=∑i Source(Query,Key i )·Value i (7)

[0099] In the formula: Source represents the original input data information; Query represents under certain conditions or information; Key represents the importance of data information; Value is an element in the data information.

[0100] Traffic flow data is characterized by high spatiotemporal complexity. The use of attention mechanism can better reflect the spatiotemporal correlation in traffic flow data. This study mainly introduces the temporal attention module and the spatial attention module. In the temporal dimension, the attention mechanism is used to adaptively assign different importance to the data for traffic conditions on different time slices. In the spatial dimension, the traffic flow conditions in different areas have certain spatial correlations, and the attention mechanism is used to adaptively capture the dynamic correlation between nodes in the spatial dimension.

[0101] (4) Experiment

[0102] Data preparation and preprocessing

[0103] The experimental data used in this study were collected from the entrances and exits of toll stations and gantries along a certain section of the Beijing-Taipei Expressway from March 1 to March 31, 2023. A certain section of the Beijing-Taipei Expressway connects multiple counties and cities, and multiple ETC gantries are set up on the section.

[0104] In this study, 15 sections of the road network were studied, and the toll station and ETC gantries data in the sections were analyzed and preprocessed:

[0105] Through the unique pass ID of the vehicle passing through the highway, the connection and restoration of the vehicle's full trajectory of entering the toll station, passing the gantry, and exiting the toll station are realized, and the mileage, average speed, and average travel time of the vehicle on the section between two adjacent gantries or the section between the gantry and the toll station are calculated. The average speed and flow of all vehicles on each section are calculated every 15 minutes to obtain the traffic parameter status of the section. Each section contains 96 records per day, and a total of 44,640 data are obtained from 15 sections per day. In order to perform data analysis, 80% of the data are divided into training sets and 20% are divided into test sets, and the data are normalized.

[0106] In order to restore the complete driving trajectory of the vehicle, we first need to calculate the driving speed, journey time and mileage of each vehicle. The mileage is the distance between adjacent gantries, obtained according to the pile number; the journey time is the difference between two passing times; the driving speed can be obtained by dividing the mileage by the journey time.

[0107] However, there is often a certain proportion of missed detections in the traffic data of highway vehicles. In order to reduce this interference, the gantry data of all vehicles in the highway system can be extracted and separated. Based on factors such as license plate number, gantry adjacency and driving speed, the missed detection trajectory of the vehicle is identified, and the vehicle spatial trajectory is reconstructed through the K nearest neighbor algorithm.

[0108] The K-nearest neighbor (KNN) algorithm is a commonly used machine learning classification algorithm proposed by Cover and Hart in 1968. In this embodiment, it is used for the ambiguous path type missed detection interval of the vehicle to complete the trajectory reconstruction at the spatial level.

[0109] Model evaluation indicators

[0110] To evaluate the prediction accuracy of the algorithm proposed in this study, the performance of the model can be evaluated by comparing the error between the true value and the predicted value. This embodiment selects two commonly used error evaluation indicators for testing, namely the mean absolute error (MAE) and the root mean square error (RMSE). The MAE indicator can reflect the actual situation of the error between the predicted value and the true value, and the RMSE can well reflect the accuracy of the prediction. The calculation formula is as follows:

[0111]

[0112]

[0113] In the formula, and represents the actual speed and predicted speed of the jth road in the ith sample, and M represents the number of samples.

[0114] Experimental results and analysis

[0115] In order to evaluate the impact of the CNN-LSTM-Attention model proposed in this embodiment on the prediction performance of highway traffic parameters, three models are introduced to compare with the proposed prediction model.

[0116] (1) CNN: CNN is a deep feedforward neural network. The convolution process extracts features from the image. CNN can adaptively extract important features from the input data. In this study, the convolution kernel size is set to 3x3, the pooling depth of the pooling layer is set to 0.2, the training batch size is set to 64, the time step size is set to 20, and the learning rate is set to 0.001.

[0117] (2) LSTM: LSTM is an improved recurrent neural network that can effectively capture the temporal characteristics of time series problems. This study sets the training batch size to 64, the time step size to 20, and the learning rate to 0.001.

[0118] (3) CNN-LSTM: The data is input into CNN to extract spatial features, and then input into LSTM to extract temporal dimension features. The structure of the input layer is (16, 32, 64), including three convolutional layers and one pooling layer. The specific parameter settings are the same as those of CNN and LSTM.

[0119] Table 1 Performance comparison between prediction model and comparison model (average speed)

[0120] Tab.1 Comparison of performance of predictive and comparison models (average speed)

[0121]

[0122]

[0123] In order to verify the effectiveness of the model proposed in this embodiment in predicting the average speed of the research section, the prediction effects of the CNN model, LSTM model and CNN-LSTM combined model were selected for comparison. The prediction errors are shown in Table 1.

[0124] It can be observed that the CNN-LSTM-Attention model proposed in this paper has the highest prediction accuracy. Compared with the LSTM single model without the attention mechanism, the CNN-LSTM-Attention model has a 6.88% reduction in MAE and a 10.82% reduction in RMSE. This is because the combined model can not only deeply extract the temporal correlation information of traffic parameters, but also extract and predict the spatial features of different road sections in the region through the combination of the CNN network and the attention mechanism.

[0125] Judging from the results, the prediction effect of the CNN model is the worst. This is because although the CNN model takes into account the spatial correlation, the extraction effect of the time information of the road network is not accurate enough. The LSTM model improves the model performance to a certain extent by increasing the extraction of previous time information, but it does not take into account the spatial correlation between road sections, and cannot accurately estimate and measure its impact on the distribution law of traffic parameters. In contrast, the CNN-LSTM model combines the advantages of CNN and LSTM in space and time, and the effect is significantly improved. The model proposed in this embodiment can be more accurate to key features, improve the efficiency and accuracy of prediction, and have better prediction accuracy due to the addition of the attention mechanism, so the effect is significantly improved.

[0126] Table 2 Performance comparison between prediction model and comparison model (traffic)

[0127] Tab.2 Comparison of performance of predictive and comparison models (traffic flow)

[0128]

[0129] In order to predict the traffic flow of the research section, the CNN model, LSTM model and CNN-LSTM combined model were also selected for comparison. The prediction errors are shown in Table 2.

[0130] It can be seen that the CNN-LSTM-Attention model proposed in this embodiment has the best prediction effect. The CNN-LSTM combination model with the attention mechanism has a 40.92% reduction in MAE and a 47.55% reduction in RMSE compared to the CNN-LSTM combination model. This is because the introduction of the attention mechanism models the importance of each feature, controls the weight of attention by weight, effectively improves the performance of the model, and can reduce the amount of calculation to a certain extent.

[0131] In order to more intuitively compare the prediction effects of various models, a single road section is selected as a case to visualize the average speed and flow prediction effects of the prediction model established in this paper. Figure 3(a)-Figure 3(d) and Figure 4(a)-Figure 4(d) shown.

[0132] As shown in Figures 3(a), 3(b), 3(c) and 3(d), it can be seen that the actual average speed of vehicles fluctuates greatly from 2:00 to 6:00, and the average speed predicted by the single CNN model also oscillates greatly. The average speed of the combined prediction model proposed in the study is relatively stable during this period, mainly fluctuating around 85 km / h. As the actual speed increases, the average speed predicted by each model also increases. Among them, the CNN-LSTM-Attention model has the fastest response to the increase in speed. During the evening rush hour around 18:00, the average speed gradually decreases. The prediction values ​​and actual values ​​of each model show that the CNN-LSTM-Attention model has the best prediction fit from 18:00 to 22:00, while the single CNN model has the worst prediction effect.

[0133] As shown in Figures 4(a), 4(b), 4(c), and 4(d), the CNN and LSTM single model methods show a certain time lag in traffic forecasting, and the prediction effect of traffic fluctuations in the time period from 8:30 to 12:30 is poor. This is because the prediction of the current moment variable based on the time series model will be affected by the variables at the previous moment. The long data collection time interval and the certain time lag relationship between the variables lead to the lag of the prediction. The CNN-LSTM combined prediction model has a certain improvement in the continuity of the prediction, but the prediction effect is average for traffic fluctuations and sudden increases and decreases. Introducing the attention mechanism based on the CNN-LSTM model can better learn the model features and improve the accuracy of the prediction.

[0134] Through the analysis of the example data, the following conclusions can be drawn:

[0135] (1) In terms of vehicle average speed prediction, the combined model proposed in this study shows the best prediction performance. The CNN-LSTM-Attention model proposed in this paper has the highest prediction accuracy. Compared with the LSTM single model without the introduction of the attention mechanism, the MAE index is reduced by 6.88% and the RMSE index is reduced by 10.82%. This shows that the combined model can not only extract the temporal correlation information of traffic parameters, but also extract and predict the spatial features of different sections in the region by combining the CNN network and the attention mechanism. Therefore, the combined model proposed in this study has extremely high applicability in the prediction of highway average speed.

[0136] (2) In terms of traffic flow prediction, the combined model proposed in this study performed best in all evaluation indicators. The CNN-LSTM-Attention model proposed in the study had the best prediction effect. The CNN-LSTM combined model with the attention mechanism reduced the MAE index by 40.92% and the RMSE index by 47.55% compared with the CNN-LSTM combined model. At the same time, by observing the schematic diagram of the prediction results, it can be found that there is a lag when predicting for a single time series model, and the CNN-LSTM combined prediction model cannot handle traffic fluctuations and sudden increases and decreases well. In contrast, the CNN-LSTM-Attention model proposed in the study combined with the attention mechanism can show a better fit effect when predicting traffic, so that the traffic conditions of the highway can be predicted in a timely and accurate manner.

[0137] Embodiment 2

[0138] This embodiment discloses a traffic flow prediction system based on CNN-LSTM-At.

[0139] Traffic flow prediction system based on CNN-LSTM-At, including:

[0140] The preprocessing module is configured to: obtain ETC breakpoint data of multiple ETC gantries on the highway, convert the ETC breakpoint data into average data of the road section by segment processing, reconstruct the vehicle trajectory, and perform abnormal data processing on the reconstructed data to obtain the original data;

[0141] The prediction module is configured as follows: input the original data into the CNN-LSTM-At model, use the CNN model to extract spatial features, then input the spatial features into the LSTM model, use the LSTM model to extract temporal features, and introduce the attention mechanism to weight the importance of the aforementioned spatial features and temporal features to achieve traffic flow prediction.

[0142] Embodiment 3

[0143] The purpose of this embodiment is to provide a computer-readable storage medium.

[0144] A computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps in the traffic flow prediction method based on CNN-LSTM-At as described in Example 1 of the present disclosure.

[0145] Embodiment 4

[0146] The purpose of this embodiment is to provide an electronic device.

[0147] An electronic device includes a memory, a processor, and a program stored in the memory and executable on the processor. When the processor executes the program, the steps in the traffic flow prediction method based on CNN-LSTM-At as described in Example 1 of the present disclosure are implemented.

[0148] The steps involved in the apparatuses of the above embodiments 2, 3 and 4 correspond to the method embodiment 1, and the specific implementation methods can refer to the relevant description part of embodiment 1. The term "computer-readable storage medium" should be understood as a single medium or multiple media including one or more instruction sets; it should also be understood to include any medium that can store, encode or carry an instruction set for execution by a processor and enable the processor to execute any method in the present invention.

[0149] Those skilled in the art should understand that the modules or steps of the present invention described above can be implemented by a general-purpose computer device, or alternatively, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. The present invention is not limited to any specific combination of hardware and software.

[0150] Although the above describes the specific implementation mode of the present invention in conjunction with the accompanying drawings, it is not intended to limit the scope of protection of the present invention. Those skilled in the art should understand that various modifications or variations that can be made by those skilled in the art on the basis of the technical solution of the present invention without creative work are still within the scope of protection of the present invention.

Claims

1. Traffic flow prediction method based on CNN-LSTM-At, It is characterized in that The following steps are involved: Obtain ETC breakpoint data from multiple ETC gantries on the highway, convert the ETC breakpoint data into average data of the road section by segment processing, reconstruct the vehicle trajectory, and perform abnormal data processing on the reconstructed data to obtain the original data; The original data is input into the CNN-LSTM-At model, and the spatial features are extracted using the CNN model. The spatial features are then input into the LSTM model, and the temporal features are extracted using the LSTM model. The attention mechanism is introduced to weight the importance of the spatial and temporal features to achieve traffic flow prediction. Through the unique passID of the vehicle passing through the expressway, the whole trajectory of the vehicle entering the toll station, passing through the gantry, and exiting the toll station is connected and restored: the mileage, average speed, and average travel time of the vehicle on the section between two adjacent gantries or between the gantry and the toll station are calculated; Calculate the average speed and flow of all vehicles on each road section according to the set time, and obtain the traffic parameter status of the road section: the average data of the road section; Extract and separate the gantry data of all vehicles in the highway system; identify the missed vehicle trajectories based on the license plate number, gantry adjacency and driving speed factors, and reconstruct the vehicle's spatial trajectory through the K nearest neighbor algorithm; perform abnormal data processing on the reconstructed data, including excluding erroneous data and filling in missing data, to obtain the original data; The CNN-LSTM-At model consists of three parts: CNN, LSTM, and Attention. CNN is used to extract the spatiotemporal features of input data; LSTM is a three-layer LSTM network that can better capture the long-term dependencies in long sequence data; Attention is a hybrid attention mechanism that combines spatial and channel attention.

2. The traffic flow prediction method based on CNN-LSTM-At as claimed in claim 1, It is characterized in that The format of the original data is an N×M matrix, where N represents the time series length of the original data and M represents the traffic characteristic information of each time period.

3. The traffic flow prediction method based on CNN-LSTM-At as claimed in claim 1, It is characterized in that The spatial features of the original data are extracted through a CNN model consisting of convolutional layers, pooling layers, and fully connected layers.

4. The traffic flow prediction method based on CNN-LSTM-At as claimed in claim 1, It is characterized in that The output of the LSTM is calculated as follows: h t =o t ⊙tanh(c t ) Among them, the time step is t; the input is x t , the hidden state at the previous moment is h t-1 , the cell state is c t-1 ; ⊙ represents element-by-element product; O t is the output gate; W c is the input x t The weight matrix, U c is the hidden state h at the previous moment t-1 The weight matrix, b c is the bias vector, tanh is the hyperbolic tangent function; f t =σ(W f x t +U f h t-1 +b f ), W f is the input x t The weight matrix, U f is the hidden state h at the previous moment t-1 The weight matrix, b f is the bias vector, σ is the sigmoid function; i t =σ(W i x t +U i h t-1 +b i ), W i is the input x t The weight matrix, U i is the hidden state h at the previous moment t-1 The weight matrix, b i is the bias vector.

5. The traffic flow prediction method based on CNN-LSTM-At as claimed in claim 1, It is characterized in that The temporal attention module and the spatial attention module are introduced. In the temporal dimension, the attention mechanism is used to adaptively assign different importance to the data according to the traffic conditions in different time slices; in the spatial dimension, the attention mechanism is used to adaptively capture the dynamic correlation between nodes.

6. Traffic flow prediction system based on CNN-LSTM-At, Features: include: The preprocessing module is configured to: obtain ETC breakpoint data of multiple ETC gantries on the highway, convert the ETC breakpoint data into average data of the road section by segment processing, reconstruct the vehicle trajectory, and perform abnormal data processing on the reconstructed data to obtain the original data; The prediction module is configured as follows: inputting the original data into the CNN-LSTM-At model, extracting spatial features using the CNN model, then inputting the spatial features into the LSTM model, extracting temporal features using the LSTM model, and introducing the attention mechanism to weight the importance of the aforementioned spatial features and temporal features to achieve traffic flow prediction; Through the unique passID of the vehicle passing through the expressway, the whole trajectory of the vehicle entering the toll station, passing through the gantry, and exiting the toll station is connected and restored: the mileage, average speed, and average travel time of the vehicle on the section between two adjacent gantries or between the gantry and the toll station are calculated; Calculate the average speed and flow of all vehicles on each road section according to the set time, and obtain the traffic parameter status of the road section: the average data of the road section; Extract and separate the gantry data of all vehicles in the highway system; identify the missed vehicle trajectories based on the license plate number, gantry adjacency and driving speed factors, and reconstruct the vehicle's spatial trajectory through the K nearest neighbor algorithm; perform abnormal data processing on the reconstructed data, including excluding erroneous data and filling in missing data, to obtain the original data; The CNN-LSTM-At model consists of three parts: CNN, LSTM, and Attention. CNN extracts the spatiotemporal features of input data through three convolutional layers, a pooling layer, and a fully connected layer. LSTM is a three-layer LSTM network that can better capture the long-term dependencies in long sequence data; Attention is a hybrid attention mechanism that combines spatial and channel attention.

7. A computer-readable storage medium having a program stored thereon, It is characterized in that When the program is executed by a processor, the steps in the traffic flow prediction method based on CNN-LSTM-At are implemented as described in any one of claims 1 to 5.

8. An electronic device comprising a memory, a processor, and a program stored in the memory and executable on the processor, It is characterized in that When the processor executes the program, the steps in the traffic flow prediction method based on CNN-LSTM-At as described in any one of claims 1 to 5 are implemented.