Improved Long Short-Term Memory-Based Periodic Traffic Volume Prediction Method

In response to the problem of fixed time intervals for short-term traffic flow prediction, which fails to meet the requirements of traffic signal control based on traffic cycle signals, this paper proposes an improved long short-term memory-based method for periodic traffic volume prediction. The method presented in this study involves improvements to the Long Short-Term Memory (iLSTM) and Bidirectional Long Short-Term Memory (iBiLSTM) models, leading to the construction of the iBiLSTM-iLSTM-NN model. This model incorporates spatial data from surrounding intersections and employs data fitting techniques to establish the correlation between periodic queue length and traffic volume. Subsequently, a predictive model for periodic traffic volume is developed based on this correlation, enabling reliable forecasting of future traffic volumes within a given cycle. Additionally, actual intersection data is collected for simulation analysis. The results indicate that the prediction error of periodic traffic volume is influenced by different traffic flow characteristics such as peak, off-peak, and normal periods, as well as different inbound lanes. Different model parameters have a noticeable impact on the model’s performance, with smaller batch sizes leading to more stable models. By comparing the performance of different prediction models using various error evaluation metrics, this study finds that the proposed model exhibits the most stable performance. The research findings can be applied to rapidly predict future traffic volumes for several periods based on the instantaneous queue length at the end of the red signal phase, providing reliable, accurate, and timely data for urban traffic signal control.


I. INTRODUCTION
Short-term traffic flow prediction plays a crucial role in the research and application of intelligent transportation systems, as intelligent signal timing based on short-term traffic flow prediction can effectively alleviate traffic congestion conditions [1].Traffic flow prediction has long been a focus and hot research topic in the field of traffic control.Traditional research mostly relies on statistical methods [2], but in recent years, with the rise of machine learning, new breakthroughs and methods have emerged in short-term traffic flow prediction.Deep learning, an important branch of machine learning, enables in-depth exploration of data characteristics and modeling, reducing the incompleteness of manually The associate editor coordinating the review of this manuscript and approving it for publication was Yiqi Liu .designed models [3], [4].With the continuous improvement of hardware conditions and big data processing capabilities, traffic prediction based on deep learning has made significant progress.Deep learning has been widely applied to various domains [5], including classification, text, image, and video processing.Some commonly used methods include Support Vector Machines (SVM) [6], K-Nearest Neighbors (KNN) [7], and neural networks [8].
Representative studies in traffic flow prediction include Zhang et al. [9] applied an improved wavelet packet analysis and deep neural network with LSTM to short-term traffic flow prediction, reducing the dependence on historical data and achieving better prediction accuracy compared to LSTM, GRU [10], and other models; Zhang et al. [11] proposed a short-term traffic flow prediction model based on an improved grey wolf algorithm and BP neural network, which exhibited faster convergence compared to the standard grey wolf algorithm [12], [13]; Ma et al. [14] developed a new LSTM NN model for speed prediction, which outperformed other algorithms such as Elman NN in time series forecasting [15]; Lee et al. [16] used a fusion model of CNN [17] and LSTM to predict short-term arrival flow and long-term traffic demand trends; Comert et al. [18] proposed a grey model that outperformed more complex models (LSTM and NN models); Luo et al. [19] proposed a hybrid prediction algorithm that combines Convolutional Neural Network (CNN) with Support Vector Regression (SVR).Compared to the traditional SVR algorithm [20], this combined prediction algorithm demonstrates superior predictive capabilities.Zhang et al. [21] established a spatiotemporal Markov model to predict traffic flow after an accident.
In signalized intersections, the queue length of vehicles can also have a certain impact on traffic flow prediction.To express the relationship between the signal timing and the traffic queue length, Wang et al. [22] developed static and linear dynamic stochastic distribution models.Yang et al. [23] developed a platoon cooperation strategy based on the formation process from single vehicle to coordination platoon, and observed a clear increase in road capacity under the platoon scenario.Zeng et al. [24] proves the equivalent queue length prediction models can quantitatively describe the existence of stochastic traffic fluid in roads.Rahman et al. [25] utilizes the queue lengths at two upstream intersections and the current intersection to conduct real-time prediction of the queue length.The aforementioned studies indicate that deep learning can be applied to short-term traffic flow prediction and has achieved certain results.However, there are still some shortcomings or limitations present, including:1) On the one hand, existing traffic data prediction operates on periodic time scales, typically ranging from 5 to 60 minutes, resulting in significant time spans.As the collection of traffic volume data itself takes some time, there is inevitably a lag in the data.On the other hand, in practical traffic signal control, changes in control strategies and timing parameters occur at the level of cycles.Since the duration of road signal control does not align with the time scale of data prediction, it introduces substantial errors into the forecasting process.2) In urban road signalized intersections, due to the influence of upstream roads on downstream roads, queue lengths can have a significant impact on traffic volume.
These limitations severely restrict the practical application of theoretical research achievements in short-term traffic flow prediction.Additionally, the existing LSTM models suffer from the inability to obtain the previous time step's cell state and the need to separately determine which information to forget and which information to add.Therefore, this paper proposes an improved long short-term memory (LSTM) model based on queue length for periodic traffic volume prediction.Queue length represents the road length occupied by vehicles queuing or traveling at low speeds at traffic intersections.Traffic volume is closely related to inbound queue length at intersections, and the queue length indicator has instantaneous measurability.By utilizing the historical periodic queue length at signalized intersections and related upstream intersections, the proposed improved LSTM neural network achieves timely and reliable prediction of periodic traffic volumes.

II. MODEL INTRODUCTION A. LSTM MODEL
Recurrent Neural Networks (RNNs) suffer from issues such as vanishing and exploding gradients during backpropagation, making it difficult to optimize the neural network [26] The Long Short-Term Memory (LSTM) neural network, which is an improved version of RNN, effectively addresses these problems and is capable of analyzing time series data [27].Therefore, an LSTM-based model can be employed to fit time series data.
LSTM consists of individual cells, where each cell can effectively store and update unit information for utilization.The LSTM cell comprises three gate structures: an input gate, an output gate, and a forget gate.These gate structures, particularly the forget gate, make LSTM an efficient neural network model for handling time series data.The structure of an LSTM cell is illustrated in Figure 1.
LSTM passes linear information and utilizes a hidden layer structure to process and output information.The specific formulas are as follows: In the equations, f t represents the forget gate, i t represents the input gate, C t represents the cell input state, C t represents the cell state update, o t represents the output gate structure, and h t represents the cell output.
The final output of LSTM should include all the cell outputs, represented by Y T .
In this case, only the last output vector, h T −1 is the desired prediction value.Therefore, the prediction value for the next time step, denoted as x T = h T −1 , can be obtained using the last output vector.

B. iLSTM MODEL
The Improved Long Short-Term Memory (iLSTM) [28] unit, as illustrated in Figure 2, introduces modifications to the forget gate and the cell input state, as shown in Equations ( 5) and ( 6).This improvement allows the computation to involve the previous time step's cell state as well, enabling simultaneous determination of forgetting and adding information.

C. iBiLSTM MODEL
The iBiLSTM (Improved Bidirectional Long Short-Term Memory) model is built on the foundation of the iLSTM model and is inspired by biRNN [29], [30].The biLSTM model incorporates two independent propagation directions, allowing for separate processing of forward and backward sequence data.It has been demonstrated in various domains, such as speech recognition [31], that biLSTM performs better than LSTM.In this paper, we establish an improved bidirec-

D. THE MODEL FOR THE RELATIONSHIP BETWEEN PERIODIC QUEUE LENGTH AND TRAFFIC VOLUME
The model for the relationship between periodic queue length and traffic volume can be established based on the collected data from a specific intersection area in Kunming City [32], [33], [34].The analysis conducted using Python indicated a high correlation coefficient of 0.95 between periodic queue length and traffic volume.
The regression model provides a good fit for the data, as shown in Figure 4.The statistical analysis yielded the following results: • F-value: 4.358 × 104 • P-value: 0.00 • Coefficient of determination (R^2): 0.911 • Adjusted coefficient of determination: 0.911 These results indicate that the model is highly significant and has strong explanatory power.The regression equation, as denoted by equation (7), captures the relationship between periodic traffic volume and queue length.The specific regression equations and the detailed parametric analyses are provided (as described in Table 1).

E. iBiLSTM-iLSTM-NN PREDICTION MODEL
The iBiLSTM-iLSTM-NN prediction model is proposed to predict periodic queue length based on its close positive correlation with periodic traffic volume, both measured in the unit of traffic signal control cycles.The periodic traffic volume represents the volume of traffic passing through the entrance lane within one signal cycle, while the periodic queue length refers to the maximum queue length observed in the entrance lane during one signal cycle.In this study, the LSTM model is improved and combined with spatial data from surrounding intersections.By utilizing historical data of periodic queue lengths [35], [36], [37], the iBiLSTM-iLSTM-NN model is constructed to predict the queue length for each cycle.Subsequently, a prediction method for periodic traffic volume based on queue length is developed.The specific workflow of the model is illustrated in Figure 5.By incorporating the improved LSTM model, spatial data, and historical queue length information, this approach aims to provide an effective method for predicting periodic queue length and, consequently, the periodic traffic volume.This model takes advantage of the convenience and high data quality of periodic queue length surveys to enhance the accuracy of traffic flow predictions.
The first step is to collect and preprocess the data by gathering queue length and traffic volume for each cycle.The historical sequence data of periodic queue lengths from the surrounding intersections are normalized for further processing.A queue length prediction model is constructed using the normalized data and trained to capture the temporal patterns present in the data, enabling the prediction of future queue lengths for the target intersection.
Next, the historical periodic queue lengths and traffic volumes are used to establish a relationship between the queue length and traffic volume.Based on this relationship, a model is developed to predict traffic volume on a periodic basis.By fitting the historical data, the model can estimate the traffic volume for future cycles.
By following this approach, it is possible to predict the periodic traffic volume by leveraging the historical queue length and traffic volume data.The process involves collecting and preprocessing the data, training a queue length prediction model, and establishing a relationship between queue length and traffic volume to enable traffic volume prediction.

III. EXPERIMENTAL SETUP A. EXPERIMENTAL SETTINGS
To evaluate the effectiveness of the periodic traffic volume prediction method, road traffic data from a specific intersection area in Kunming City were collected.The data included traffic volume, turning ratios, queue lengths, and signal timing.A VISSIM simulation model was established based on the intersection area, and a prediction model was developed using Python for analysis and validation.
Based on the collected real-world traffic data, VISSIM, traffic simulation software, was used for simulation analysis.To simulate road conditions during different periods of time, three different traffic states were modeled: peak, off-peak, and low-traffic periods [38].In order to facilitate data collection, coordinated signal control was implemented for the key intersection in the area.The signal timings for the peak, off-peak, and low-traffic periods are presented in Table 2. To improve the accuracy of the prediction results, the model incorporates road conditions and traffic volume data from surrounding intersections.By considering the overall traffic dynamics in the vicinity, including the interactions between upstream and downstream roads, the prediction system can capture a more comprehensive understanding of traffic flow patterns.To compare the road conditions of different approach lanes, data from each inbound lane at every intersection is separately collected and analyzed.To ensure consistency between road signal control and data prediction time scales, data is aggregated based on the intersection's signal cycle.Specifically, queue lengths and traffic volumes are recorded once per signal cycle of each intersection.To mitigate the impact of random errors, the simulations were repeated five times for each traffic state with different random seeds, and the average values were calculated.The detector sampling interval was set to the corresponding cycle length, and detector data were updated once per cycle.The simulation road network structure is illustrated in Figure 6.Using Python for analysis and validation.A total of 9,072 experiments were designed, including 27 combinations of prediction models based on LSTM, BiLSTM, iLSTM, iBiLSTM, RNN, and neural networks (NN).A comparison Through comparative analysis of different models and parameters, the most accurate prediction models and model parameters were selected for different types of data.

B. EXPERIMENTAL PROCEDURE
Taking into account the relationship between periodic traffic volume and periodic queue length at urban road intersections, the prediction models were constructed using the PyTorch deep learning library in Python.The training steps were as follows: Phase 1: Data acquisition Step 1: Obtain the queue length and traffic volume for each entrance lane of the intersection during peak, off-peak, and low-traffic periods using VISSIM simulation based on the collected data from a specific intersection area in Kunming City.Repeat the experiment five times with different random seeds and take the average.Conduct a correlation test between periodic queue length and traffic volume, resulting in a correlation coefficient of 0.95, indicating a strong positive correlation.

Phase 2: Initialization
Step 2: Define the relationship between the entrance lanes of the intersection and the surrounding intersections.
Step 3: Initialize the network structure hyperparameters and data parameters in the prediction model.The network model hyperparameters are shown in Table 3.
Step 6: Combine different models for comparison.

Phase 4: Training of prediction models
Step 7: Normalize the periodic traffic volume and queue length using min-max normalization.

C. EVALUATION METRICS
To train the neural networks and evaluate the prediction errors of periodic queue length and traffic volume, the following evaluation metrics are selected: Smooth L1 loss [39], Root Mean Square Error (RMSE) [40], Mean Squared Error (MSE) [41], and Mean Absolute Error (MAE) [42].Measuring prediction performance is done using these metrics.Smooth L1 loss is a combination of MSE and MAE, which smooths the error near zero and is less sensitive to outliers.It helps prevent the exploding gradient problem during training and provides stronger robustness.The formula is as follows: RMSE measures the deviation between the predicted values and the true values.It is sensitive to outliers in the data.The formula is: MSE is the most commonly used error in regression loss functions.It calculates the mean of the squared differences between the predicted values and the target values.It is sensitive to outliers.The formula is: MAE is a linear score where all individual differences have equal weight around the mean.The formula is: These evaluation metrics will help assess the accuracy and performance of the prediction models in terms of periodic queue length and traffic volume.

IV. PERFORMANCE EVALUATION A. COMPARISON AND ANALYSIS OF PREDICTION MODELS AND MODEL PARAMETERS
Since the prediction of future periodic traffic volume is based on the prediction of historical periodic queue length and regression fitting to construct a prediction model for periodic traffic volume [43], [44], there is a general correlation between the prediction errors of periodic queue length and traffic volume.To visually understand the impact of different variables on prediction errors, a controlled variable analysis method is used to compare and analyze the influence of different parameters on the accuracy of prediction models [45].Different prediction models are constructed to predict periodic traffic volume, and the prediction results are shown in Figure 7.It can be observed that the prediction errors vary among different models and model parameters [46].When the prediction model is iBiLSTM, the average prediction error is the lowest at 9.78%.When all prediction models have the same model parameters with Batch size = 4 and training length = 7, the average training error for all models is the lowest at 17.33%.When the model is iBiLSTM-iLSTM-NN and the model parameters are Batch size = 2 and training length = 4, the minimum prediction error is 2.72%.
Figure 8 shows the box plot of prediction errors with different Batch sizes under the same prediction model.It can be observed that the prediction model has the smallest data fluctuation when Batch size = 2.As the Batch size gradually increases, the fluctuation effect also increases.Therefore, the best performance is achieved when Batch size = 2.This observation suggests that a smaller batch size leads to more stable and accurate predictions in this particular prediction model.
In summary, the comparison and analysis of different prediction models and model parameters provide insights into the factors that influence the accuracy of the prediction models for periodic traffic volume.

B. DATA TYPE COMPARISON ANALYSIS
When the prediction model is iBiLSTM-iLSTM-NN and the model parameters are Batch size = 2, predictions are made for different types of data, and the results are shown in Figure 9.It can be observed that the prediction errors are relatively larger during peak periods compared to off-peak and normal periods.During peak periods, the prediction error is 19.9%.During off-peak periods, the prediction error is 2.7%.During the normal periods, the prediction error is 2.3%.This indicates that this model is more accurate to predict in non-congested conditions.
When the prediction model is in the normal period, the prediction errors for different entrance roads are shown in Figure 10.The prediction errors for various straight-through inbound lanes are relatively close to each other, indicating that the model performs consistently and provides stable predictions for these lanes.On the other hand, the prediction errors for left-turn inbound lanes show significant variations, implying that the model's performance is less stable and less accurate when predicting traffic conditions for left-turn lanes.
This observation suggests that the model might be more proficient in capturing and predicting traffic patterns for straight-through movements, while facing challenges in  accurately forecasting traffic flow for left-turn movements.Possible reasons for this disparity could be differences in traffic behavior, signal control strategies, or data availability between straight-through and left-turn lanes, requiring further investigation and potential model refinements to improve prediction accuracy for all types of inbound lanes.

C. MODEL EVALUATION
To demonstrate the effectiveness of the selected models in the experiment, six models (LSTM, BiLSTM, RNN, iBiLSTM, iBiLSTM-NN, iBiLSTM-iLSTM-NN) were used and four error evaluation metrics (MAE, RMSE, smooth L1 loss, MSE) were compared and analyzed.The results are shown in Figure 11.
From Figure 11, it can be observed that the proposed iBiLSTM-based prediction model outperforms the LSTM and BiLSTM models in all four error evaluation metrics.Among them, iBiLSTM-NN and iBiLSTM-iLSTM-NN show relatively stable performance across different error evaluation metrics.Both models have smaller prediction errors than iBiLSTM in MAE and smooth L1 loss metrics, and the prediction errors of both models are very close to each other.Due to the additional layer of iLSTM in iBiLSTM-iLSTM-NN compared to iBiLSTM-NN, the computational cost of iBiLSTM-iLSTM-NN is higher, but it is more accurate.This indicates that the iBiLSTM-iLSTM-NN prediction model performs best and can more accurately predict periodic traffic volume.
In conclusion, for the selection of prediction models, the iBiLSTM-iLSTM-NN model with Batch size = 2 and training length = 4 has the smallest prediction error and the most effective performance.In terms of data prediction, the accuracy is higher during off-peak and normal periods, and the prediction errors for through movements are relatively stable.

V. DISCUSSION AND CONCLUSION
This paper proposes a method for predicting periodic traffic volume based on queue length, and the results demonstrate the following: 1) The prediction error is significantly influenced by different traffic flow characteristics, including peak, off-peak, and normal periods, as well as different entrance lanes.During normal and off-peak periods when the number of vehicles is low, the prediction error is small.However, during peak periods when the number of vehicles is high, the error is large.The prediction error for straight-through entrance lanes is relatively stable due to the high volume, fast, and consistent flow.2) Different prediction models exhibit significant differences in prediction error.The prediction models based on improved Long Short-Term Memory (iLSTM) and improved Bidirectional Long Short-Term Memory (iBiLSTM) techniques have smaller prediction errors compared to the non-improved models.
3) The model parameters have a noticeable impact on the model performance, with smaller batch sizes leading to more stable models.4) By comparing the performance of various prediction models using different error evaluation metrics, the iBiLSTM-iLSTM-NN model proves to be the most optimal.In conclusion, the most effective prediction model is the iBiLSTM-iLSTM-NN model with the model parameters set to Batch size = 2 and training length = 4.Further analysis will be conducted to explore the prediction patterns of traffic volume for future n cycles.
tional Long Short-Term Memory (iBiLSTM) model based on the iLSTM model.The structure of the iBiLSTM model is depicted in Figure 3.It consists of two hidden layers of iLSTM cells connected to the same output layer.The iBiLSTM model includes a forward iLSTM hidden layer and a backward iLSTM hidden layer.The forward hidden layer, denoted as forward, performs forward computation, processing the forward sequence data from time Tn to time T -1.On the other hand, the backward hidden layer, denoted as backward, performs backward computation, processing the backward sequence data from time T -1 to time Tn.Each hidden layer utilizes the iLSTM model for computation.

Step 8 :
Select the prediction model and relevant model parameters for training, with a decaying learning rate α.After model training, validate the data and save the validation results.Step 9: Repeat Step 8 until all prediction models and related parameters have been trained.Step 10: Analyze and compare the effects of different prediction models and related model parameters on the prediction results, and identify the prediction model with the highest accuracy and the corresponding model parameters.

FIGURE 7 .
FIGURE 7. Prediction error of different prediction models for periodic traffic volume.(The model parameters are batch size and training length, respectively.)

FIGURE 8 .
FIGURE 8. Box plot of prediction error data under different batch sizes.

FIGURE 9 .
FIGURE 9. Comparison chart of prediction errors for different data periods.

FIGURE 10 .
FIGURE 10.Box plot of prediction error data under different batch sizes.

FIGURE 11 .
FIGURE 11.Model prediction error chart for different error evaluation metrics.

TABLE 1 .
Model parameter test table.

TABLE 3 .
Hyperparameters of deep learning network model.