Bus travel time prediction method based on dual attention mechanism and bidirectional two-layer LSTM
Through the dual attention mechanism and the two-way double-layer LSTM model, the problem of large errors in the existing bus trip time prediction model is solved, more accurate itinerary time prediction and efficient scheduling are achieved, and bus operation efficiency is improved.
Patent Information
- Application Number
- CN202210007787.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-06
- Publication Date
- 2025-01-14
- Estimated Expiration
- 2042-01-06
AI Technical Summary
The existing bus trip time prediction model has large errors, resulting in insufficient timely dispatch, and the phenomenon of "traveling" or "large intervals" appear, which in turn reduces operational efficiency and service level.
The bus trip time prediction method based on the dual attention mechanism and two-way double-decker LSTM is adopted. By acquiring and preprocessing the bus attribute data and entry and exit data, the itinerary time feature data set is constructed, and the irrelevant feature factors are discarded, and the double attention is used. Force mechanism and bidirectional LSTM model predict to output more accurate travel time.
It improves the accuracy and scheduling efficiency of the estimated travel time of the bus, reduces the prediction error, and meets the scheduling needs of the bus company.
Smart Images

Figure CN114328675B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of urban intelligent transportation, and in particular to a bus travel time prediction method based on a dual attention mechanism and a bidirectional double-layer LSTM. Background Art
[0002] As an important part of public transportation, buses have the advantages of small per capita area, low per capita energy consumption, large carrying capacity, and low overall transportation costs. By improving the service level of buses and attracting more people to use public transportation, it will help alleviate urban traffic congestion, reduce urban air pollution, and ensure the healthy and good operation of the city. Therefore, vigorously developing buses is an important measure to achieve sustainable development of urban transportation and promote a virtuous cycle and interactive development between people and society.
[0003] At present, bus dispatching is mainly estimated by dispatchers based on their own experience, or based on traditional bus travel time prediction models (such as historical data models, time series models, regression prediction models, support vector machine models, Kalman filter models, etc.) to obtain the estimated travel time. This method often has large estimation errors, and dispatching is often not timely, resulting in "bus stringing" or "large intervals", which in turn leads to low bus operating efficiency, poor service level, low attractiveness, and utilization rate far from the ideal level. Summary of the invention
[0004] In view of this, the purpose of the present invention is to provide a bus travel time prediction method based on a dual attention mechanism and a bidirectional double-layer LSTM, which can more accurately estimate the bus travel time and achieve efficient bus scheduling.
[0005] To achieve the above object, the present invention adopts the following technical solution:
[0006] A bus travel time prediction method based on dual attention mechanism and bidirectional double-layer LSTM includes the following steps:
[0007] Step S1: Obtain bus attribute data and entry and exit data, and pre-process them to build a basic travel time data set;
[0008] Step S2: Obtain the basic characteristics, running time and weather characteristics of the bus, and construct a travel time feature dataset;
[0009] Step S3: Based on the correlation coefficient and variance analysis, the characteristic factors in the travel time characteristic data set are subjected to correlation analysis with the travel time, irrelevant and poorly correlated characteristic factors are discarded, and the data are matched with the travel time basic data set to obtain the travel time prediction data set;
[0010] Step S4: Construct a bus travel time prediction model with a dual attention mechanism and a bidirectional two-layer LSTM neural network, input the travel time prediction dataset into the model, predict the bus travel time, and output the estimated bus travel time.
[0011] Furthermore, the step S1 is specifically as follows:
[0012] Step S11: Obtain bus attribute data and entry and exit data, directly remove duplicate records and abnormal data and complete missing data;
[0013] Step S12: According to the bus operation shift number, the bus attribute data and the entry and exit data are matched to obtain the bus operation time of each operation shift and construct a basic travel time data set.
[0014] Furthermore, step S2 is specifically as follows: obtaining the vehicle number, driver number, vehicle departure time, and departure interval of the bus; obtaining the running time from the starting station to the terminal station in a similar time period of the previous day and a similar time period of the same characteristic day of the previous week; obtaining the weather characteristics of the vehicle during operation including weather type, humidity, wind speed, and temperature, and constructing a travel time feature data set.
[0015] Furthermore, the step S3 is specifically as follows:
[0016] Step S31: using the Pearson correlation coefficient to perform a correlation analysis between the continuous characteristic factor and the bus running time to obtain the correlation between the variables;
[0017] Step S32: classify and encode discrete characteristic factors such as weather type, driver number, bus number, etc., and convert them into categorical characteristic factors, and use variance test to analyze the correlation between categorical characteristic factors and bus running time;
[0018] Step S33: discard irrelevant or poorly correlated feature factors, match the retained features with the travel time basic data set, and obtain the travel time prediction data set.
[0019] Furthermore, the step S4 is specifically as follows:
[0020] Step S41: inputting the travel time prediction data set into the feature importance extraction module, allocating different degrees of attention to the features according to the differences in the importance of the features, and obtaining a feature importance matrix;
[0021] Step S42: concatenate the feature importance matrix with the input features of the model to obtain a bus operation status matrix;
[0022] Step S43: inputting the bus operation state matrix into the time feature extraction module, using the bidirectional LSTM to extract the time features of the bus operation process, and generating the operation time feature matrix;
[0023] Step S44: Input the obtained running time feature matrix into the travel time prediction module, fuse the attention into the time step of LSTM, construct the Attention_LSTM layer, and realize the extraction of the impact features of buses at different time distances; in the fully connected layer, use the root mean square error as the loss function, compare the predicted results with the actual results, and continuously train the model to realize the prediction of bus travel time.
[0024] A bus travel time prediction system based on dual attention mechanism and bidirectional two-layer LSTM, including
[0025] The feature importance extraction module uses the attention mechanism to obtain the importance weight of each feature to generate a feature importance matrix, distinguish the impact of different features on bus travel time, and improve the prediction efficiency and accuracy of the model;
[0026] The time feature extraction module uses the strong time feature capture capability of the bidirectional LSTM to capture the operation characteristics of the buses running before and after, and obtain the time characteristics of the bus during operation;
[0027] The travel time prediction module introduces attention into LSTM, constructs the Attention_LSTM layer, gives different attention to different time steps in LSTM, and shows the impact of vehicles at different time distances on the bus travel time.
[0028] Compared with the prior art, the present invention has the following beneficial effects:
[0029] The present invention introduces LSTM into bus travel time prediction. On the one hand, the bidirectional LSTM is used to capture the time characteristics of the front and rear buses during operation. On the other hand, based on the bidirectional LSTM, the Attention_LSTM layer is added to realize the extraction of the impact features of buses at different time distances, which effectively improves the prediction accuracy of the model, realizes more accurate bus estimated travel time and efficient bus scheduling. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] Figure 1 It is a schematic flow chart of the method of the present invention;
[0031] Figure 2 The structure diagram of the bus travel time prediction model with dual attention mechanism and bidirectional double-layer LSTM;
[0032] Figure 3A bus route map of bus route B2 in the embodiment of the present invention;
[0033] Figure 4 A comparison chart of the travel time prediction result obtained in an embodiment of the present invention and the true value. DETAILED DESCRIPTION
[0034] The present invention will be further described below in conjunction with the accompanying drawings and embodiments.
[0035] Please refer to Figure 1 The present invention provides a bus travel time prediction method based on a dual attention mechanism and a bidirectional double-layer LSTM, comprising the following steps:
[0036] Step S1, obtain bus attribute data and entry and exit data, directly remove duplicate records and abnormal data and complete missing data. According to the bus operation shift number, match the bus attribute data and entry and exit data, obtain the bus operation time of each operation shift, and build a basic travel time data set;
[0037] Step S2, obtain the basic features of the bus, such as the vehicle number, driver number, vehicle departure time, departure interval, etc.; obtain the running time from the departure station to the terminal station in a similar time period of the previous day and a similar time period of the same characteristic day of the previous week; obtain the weather characteristics such as weather type, humidity, wind speed, temperature, etc. when the vehicle is running, and construct a travel time feature data set;
[0038] Step S3: Based on the correlation coefficient and variance analysis, a correlation analysis is performed between the characteristic factors in the characteristic data set and the travel time, and irrelevant and poorly correlated characteristic factors are discarded, and the data is matched with the travel time basic data set to obtain a travel time prediction data set;
[0039] Step S4: Based on the attention mechanism and LSTM, a dual-attention mechanism and a bidirectional double-layer LSTM neural network bus travel time prediction model is constructed, the travel time prediction data set is input into the model, the bus travel time is predicted, and the estimated travel time of the bus is output.
[0040] Embodiment 1:
[0041] refer to Figure 3 This embodiment takes the B2 bus operating vehicles in Guangzhou as the research object, and selects the B2 bus data during the evening rush hour (17:00-19:00) on weekdays from October 1, 2020 to December 11, 2020 as example data. The specific implementation method is as follows:
[0042] Step S1, obtain bus attribute data and entry and exit data, directly remove duplicate records and abnormal data and complete missing data. According to the bus operation shift number, match the bus attribute data and entry and exit data, obtain the bus operation time of each operation shift, and build a basic travel time data set.
[0043] 1. Collect data. The collected experimental data consists of two parts: the first part is static data, which contains the basic information of the bus stations on the B2 bus line; the second part is dynamic data, including the B2 bus entry and exit data and bus attribute data.
[0044] The basic information of the platform includes the platform number, platform longitude and latitude, up and down signs of the platform, etc.; the bus entry and exit data includes the waybill ID, vehicle number, platform number, platform name, entry time, exit time, up and down signs, date, etc.; the bus attribute data includes the waybill ID, departure time, vehicle number, driver number, line type, departure interval, etc.
[0045] 2. Data preprocessing. Data preprocessing mainly includes bus entry and exit data preprocessing, bus attribute data preprocessing, static data and dynamic data matching, and travel time acquisition.
[0046] The preprocessing of bus dispatch data mainly involves removing duplicate records and extracting the entire operation data.
[0047] Preprocessing of bus entry and exit data includes removing duplicate data, calibrating abnormal data, interpolating missing data, and obtaining bus travel time. First, the duplicate entry and exit data are directly removed; second, abnormal data are processed. Abnormal data refers to data with reverse time or running time far less than the average station running time. They are first removed and then interpolated; third, missing data are processed, focusing on the missing data of the terminal arrival time. By calculating the proportion of the average driving time and the average stop time of each part in the missing station, the interpolation time of each part is calculated in the missing time period to complete the completion. Finally, the bus travel time of the running shift is obtained according to the departure time and the arrival time of the terminal.
[0048] Match static data and dynamic data. According to the bus operation schedule number, the basic platform information, bus attribute data and bus entry and exit data are matched to obtain the basic data set of travel time.
[0049] Step S2, obtain the basic characteristics of the bus, such as the vehicle number, driver number, vehicle departure time, departure interval, etc.; obtain the running time from the starting station to the terminal station in a similar time period of the previous day and a similar time period of the same characteristic day of the previous week; obtain weather characteristics such as weather type, humidity, wind speed, temperature, etc. when the vehicle is running, and construct a travel time feature data set.
[0050] Step S3: Based on the correlation coefficient and variance analysis, the characteristic factors in the characteristic data set are subjected to correlation analysis with the travel time, irrelevant and poorly correlated characteristic factors are discarded, and the data are matched with the travel time basic data set to obtain the travel time prediction data set.
[0051] 1. Use the Pearson coefficient correlation coefficient to conduct a correlation analysis between continuous characteristics (vehicle departure time, departure interval, travel time in a similar time period on the previous day of operation, travel time on the same characteristic day of the previous week, humidity, wind speed, temperature) and bus travel time.
[0052] 2. Use variance analysis to conduct variance analysis on the classification characteristics (bus number, driver number, weather type) and bus travel time.
[0053] 3. Obtain the travel time prediction data set based on the correlation coefficient and variance analysis results.
[0054] Step S4: construct a "double attention mechanism and bidirectional double-layer LSTM neural network bus travel time prediction model" based on the attention mechanism and LSTM, input the travel time prediction data set into the model, predict the bus travel time, and output the estimated bus travel time.
[0055] 1. Build a bus travel time prediction model based on the Kares deep learning framework with dual attention mechanism and bidirectional double-layer LSTM.
[0056] 2. The travel time prediction data set is divided, and the B2 bus operation data during the evening rush hour on weekdays from October 1, 2020 to December 4, 2020 is used for training; the B2 bus operation data during the evening rush hour on weekdays from December 7 to December 11 is used for verification.
[0057] 3. The training data in the travel time prediction dataset is input into the bus travel time prediction model with dual attention mechanism and bidirectional double-layer LSTM for training, with the root mean square error as the measurement indicator.
[0058] 4. Predict the travel time of bus route B2 during the evening rush hour on weekdays from December 7 to December 11, and output the estimated travel time.
[0059] Following the above specific implementation steps, a comparison chart of the predicted value and the actual value of the bus running time during the evening peak hours on weekdays from December 7 to December 11 is obtained. The average absolute error of the predicted bus travel time obtained by the present invention is 6.23%.
[0060] Table 1
[0061]
[0062] As shown in Table 1, Table 1 Comparison of the prediction results of the evening peak on each weekday by the dual-attention bidirectional two-layer LSTM model;
[0063] From Monday to Friday, the performance of the model varies. From Monday to Thursday, it has a higher prediction accuracy, and its average error is lower than the total average error. The prediction accuracy is the best on Monday, with an average absolute error of about 3 minutes. However, the prediction accuracy on Friday drops significantly, with an average absolute percentage error of only 8.88%, and an average absolute error of about 7 minutes. By analyzing the B2 bus route, it can be found that the B2 bus route has two major characteristics. Feature 1: The B2 route passes through many colleges and universities, a total of 7, namely: Guangzhou University of Technology, Guangzhou Institute of Engineering Technology, Guangzhou Sports Institute, South China Normal University, Jinan University, Guangdong Institute of Posts and Telecommunications Technology, and Guangdong Polytechnic Normal University; Feature 2: The B2 route passes through many department stores and shopping centers, a total of 16, namely: Shiguangli, Libo Plaza, Xindaxin Department Store, Guangbai Department Store, VT101 Victoria Plaza, Tianhecheng Shopping Plaza, Zhengjia Plaza, Wanlinghui, Taikoo Hui, Modern Department Store, Tianyu Plaza, Walmart, Juntang Shopping Plaza, Tianhecheng Department Store, Jushidai Constellation Plaza, and Dongpu Shopping Center. Therefore, during the peak hours on Friday night, more college students and citizens go to major department stores and shopping malls, and the travel volume increases significantly compared to Monday to Thursday. In this case, on the one hand, the number of people getting on and off the bus increases significantly, the bus stop time at each station changes, and the complexity of the spatiotemporal law of operation increases; on the other hand, the increase in the number of private cars and online car-hailing trips makes the road conditions on the operating routes of the bus more complicated. Therefore, when the model predicts the travel time of buses during the peak hours on Friday night, it is difficult to predict and it is difficult to capture the spatiotemporal law of bus operation in a complex traffic environment. The accuracy has decreased, but the average error is still less than 9%, which generally meets the bus dispatching needs of the bus company.
[0064] In this embodiment, the dual-attention bidirectional two-layer LSTM model is compared with other neural network models. Table 2 is a comparison of the experimental results of the dual-attention bidirectional two-layer LSTM model with other neural network models.
[0065] Table 2
[0066]
[0067] Specifically, in order to better analyze the effect of feature importance extraction module, time feature module and travel time prediction module on the accuracy of travel time prediction, the prediction accuracy of the model is compared from two aspects. On the one hand, the model is compared with other neural network models: compared with the single attention bidirectional two-layer LSTM model, the relative accuracy is improved by 7.98%; compared with the non-attention bidirectional two-layer LSTM model, the relative accuracy is improved by 16.3%; compared with the two-layer LSTM, the relative accuracy is improved by 19.3%. On the other hand, compared with the travel time prediction model of the traditional method: compared with the multi-layer perceptron, the relative accuracy is improved by 29.0%; compared with the support vector machine model, the relative accuracy is improved by 31.0%. From the comparison results, it can be seen that the feature importance extraction module and the time feature module have a great improvement in improving the accuracy of bus travel time prediction, which can mine the deep time characteristics of the bus operation process and integrate different features into the model prediction in a more targeted manner to obtain higher prediction accuracy.
[0068] The above description is only a preferred embodiment of the present invention. All equivalent changes and modifications made according to the scope of the patent application of the present invention should fall within the scope of the present invention.
Claims
1. A bus travel time prediction method based on dual attention mechanism and bidirectional double-layer LSTM, characterized in that: The steps include: Step S1: Obtain bus attribute data and entry and exit data, and pre-process them to build a basic travel time data set; Step S2: Obtain the bus number, driver number, vehicle departure time, and departure interval of the bus; obtain the running time from the departure station to the terminal station in a similar time period of the previous day and a similar time period of the same characteristic day of the previous week; obtain the weather characteristics of the vehicle during operation, including weather type, humidity, wind speed, and temperature, and construct a travel time feature data set; Step S3: Based on the correlation coefficient and variance analysis, the characteristic factors in the travel time characteristic data set are subjected to correlation analysis with the travel time, irrelevant and poorly correlated characteristic factors are discarded, and the data are matched with the travel time basic data set to obtain the travel time prediction data set; Step S4: construct a bus travel time prediction model with a dual attention mechanism and a bidirectional double-layer LSTM neural network, input the travel time prediction data set into the model, predict the bus travel time, and output the estimated bus travel time; Step S4 is specifically as follows: Step S41: inputting the travel time prediction data set into the feature importance extraction module, allocating different degrees of attention to the features according to the differences in the importance of the features, and obtaining a feature importance matrix; Step S42: concatenate the feature importance matrix with the input features of the model to obtain a bus operation status matrix; Step S43: inputting the bus operation state matrix into the time feature extraction module, using the bidirectional LSTM to extract the time features of the bus operation process, and generating the operation time feature matrix; Step S44: Input the obtained running time feature matrix into the travel time prediction module, fuse the attention into the time step of LSTM, construct the Attention_LSTM layer, and realize the extraction of the impact features of buses at different time distances; in the fully connected layer, use the root mean square error as the loss function, compare the predicted results with the actual results, and continuously train the model to realize the prediction of bus travel time.
2. The bus travel time prediction method based on dual attention mechanism and bidirectional double-layer LSTM according to claim 1 is characterized in that: The step S1 is specifically as follows: Step S11: Obtain bus attribute data and entry and exit data, directly remove duplicate records and abnormal data and complete missing data; Step S12: According to the bus operation shift number, the bus attribute data and the entry and exit data are matched to obtain the bus operation time of each operation shift and construct a basic travel time data set.
3. The bus travel time prediction method based on dual attention mechanism and bidirectional double-layer LSTM according to claim 1 is characterized in that: The step S3 is specifically as follows: Step S31: using the Pearson correlation coefficient to perform a correlation analysis between the continuous characteristic factors and the bus running time to obtain the correlation between the variables; Step S32: classify and encode the discrete characteristic factors of weather type, driver number, and bus number, and convert them into categorical characteristic factors, and use variance test to analyze the correlation between the categorical characteristic factors and bus running time; Step S33: discard irrelevant or poorly correlated feature factors, match the retained features with the travel time basic data set, and obtain the travel time prediction data set.
4. A bus travel time prediction system based on dual attention mechanism and bidirectional double-layer LSTM, characterized in that: The system is implemented by a bus travel time prediction method based on a dual attention mechanism and a bidirectional double-layer LSTM as described in any one of claims 1 to 3, including The feature importance extraction module uses the attention mechanism to obtain the importance weight of each feature to generate a feature importance matrix, distinguish the impact of different features on bus travel time, and improve the prediction efficiency and accuracy of the model; The time feature extraction module uses the strong time feature capture capability of the bidirectional LSTM to capture the operation characteristics of the buses running before and after, and obtain the time characteristics of the bus during operation; The travel time prediction module introduces attention into LSTM, constructs the Attention_LSTM layer, gives different attention to different time steps in LSTM, and shows the impact of vehicles at different time distances on the bus travel time.