Expressway traffic conflict analysis and prediction method based on RF-LSTM algorithm
By deploying equipment on highways to collect data and using RF-LSTM algorithm to train models, the challenges of data set scale, model interpretability and real-time data processing capabilities in highway traffic conflict prediction are solved, and higher prediction accuracy and real-time performance are achieved, providing more scientific and forward-looking decision-making support for traffic management.
Patent Information
- Application Number
- CN202411756151.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-03
- Publication Date
- 2025-03-25
AI Technical Summary
The prior art challenges in highway traffic conflict predictions with data set size, model interpretability, and real-time data processing capabilities.
Highway traffic conflict analysis and prediction methods based on RF-LSTM algorithm are used to collect traffic flow data by deploying equipment on highways, perform data cleaning and normalization processing, and train K-means clustering model, random forest model and long and short-term memory network to identify potential high-risk areas and times.
It significantly improves the accuracy and real-time nature of traffic conflict prediction, optimizes feature selection and model integration, and enhances the scientificity and foresight of traffic management.
Smart Images

Figure CN119691485A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of intelligent transportation systems, and in particular to a highway traffic conflict analysis and prediction method based on RF-LSTM algorithm. Background Art
[0002] With the rapid development of economy and the surge in the number of motor vehicles, the safety and efficiency of highways, as an important part of the modern transportation system, have received extensive attention. Traffic accidents not only cause casualties and property losses, but also have a negative impact on social stability and economic development. Therefore, improving the safety of highways and reducing the occurrence of traffic accidents have become hot issues in the transportation field.
[0003] Traditional traffic safety research mainly relies on statistical analysis of accident data, but due to the sporadic nature of traffic accidents and the lag in data collection, this method has limitations in terms of real-time and preventive nature. In recent years, traffic conflict prediction has gradually gained attention as a new research direction. By analyzing traffic conflicts, potential dangers can be identified in advance and preventive measures can be taken to reduce the risk of accidents.
[0004] In the field of traffic conflict prediction and analysis, traditional statistical methods such as descriptive statistics, probability distribution, parameter estimation, etc., although they reveal the potential causes and patterns of traffic accidents to a certain extent, they are insufficient in processing large-scale or unstructured data, capturing nonlinear relationships and complex interactions, and handling outliers and high-dimensional data.
[0005] Machine learning techniques, especially ensemble methods such as Random Forest (RF), have shown significant results in identifying key factors of traffic conflicts. These models are good at processing large data sets and complex patterns, and are very useful for analyzing traffic flow and control strategies. However, they require a large amount of labeled data and the models are less interpretable. In addition, deep learning models, especially Long Short-Term Memory (LSTM), have also shown high accuracy in predicting traffic conflicts, thanks to their ability to effectively process time series data.
[0006] Although these technologies have made progress in traffic conflict prediction, they still face challenges in data set size, model interpretability, and real-time data processing capabilities. Therefore, this patent proposes a highway traffic conflict prediction and analysis method that combines random forests and long short-term memory networks, aiming to overcome the limitations of existing technologies and provide a more accurate and practical solution. Summary of the invention
[0007] The purpose of the present invention is to overcome the deficiencies in the above-mentioned background technology and provide a highway traffic conflict analysis and prediction method based on RF-LSTM algorithm to accurately identify and predict potential conflicts in highway traffic flow.
[0008] The technical solution of the present invention is:
[0009] The highway traffic conflict analysis and prediction method based on RF-LSTM algorithm includes the following steps:
[0010] Step 1: Deploy equipment on highways to collect traffic flow data;
[0011] Step 2: Clean and normalize the data to obtain the vehicle trajectory data set;
[0012] Step 3: Train the K-means clustering model to perform traffic conflict clustering analysis;
[0013] Step 4: Train the random forest model for feature selection;
[0014] Step 5: Train the long short-term memory network for trajectory prediction;
[0015] Step 6: Conflict prediction of traffic flow on the highway is performed to identify potential high-risk areas and times.
[0016] The step 2 comprises: first extracting a vehicle trajectory data set and performing data cleaning, then constructing features according to the vehicle trajectory data set, then normalizing the features, and finally dividing the vehicle trajectory data set into a training set and a test set; the features constructed according to the vehicle trajectory data set include a speed difference with the preceding vehicle, an acceleration difference with the preceding vehicle, an average acceleration, an average headway, an average speed, and an average headway.
[0017] The vehicle trajectory dataset includes video frame number, time, vehicle number, vehicle type, trajectory coordinates, vehicle outer dimensions, speed, acceleration, vehicle lane, adjacent vehicle number, lane marking line shape, speed difference with the preceding vehicle, acceleration difference with the preceding vehicle, average acceleration, average headway time, average acceleration, and average headway distance.
[0018] The step 3 includes: determining clustering features and the number of clusters and optimizing a K-means clustering model; the K-means clustering model divides the vehicle trajectory data set into rear-end collisions and lane change conflicts.
[0019] The step 4 includes: firstly dividing the vehicle trajectory data set into feature variables and target variables, then converting the target variables into binary values, and finally training and optimizing the random forest model; selecting the features that have the greatest impact on traffic conflict prediction according to the importance scores output by the random forest model;
[0020] The characteristic variables include speed, acceleration, vehicle type, speed difference with the preceding vehicle, acceleration difference with the preceding vehicle, average acceleration, average headway, average speed, and average headway; the target variable is collision time.
[0021] The step 5 includes: first converting the trajectory coordinates, speed and features selected in step 4 of the vehicle into time series data, and then training and optimizing the long short-term memory network; the long short-term memory network predicts the trajectory of the vehicle.
[0022] The long short-term memory network includes an LSTM layer, a Dropout layer, an LSTM layer, a fully connected layer and an activation function layer.
[0023] The step 6 includes: firstly forming a traffic conflict prediction model by combining a K-means clustering model, a random forest model and a long short-term memory network, then deploying the traffic conflict prediction model, and finally using the traffic conflict prediction model to predict traffic conflicts on the traffic flow of the highway and identify potential high-risk areas and times.
[0024] The traffic conflict prediction includes calculating the collision time according to the vehicle trajectory predicted by the traffic conflict prediction model. When the collision time is less than or equal to the collision threshold, it is considered that there is a traffic conflict.
[0025] The beneficial effects of the present invention are:
[0026] (1) Improve prediction accuracy and real-time performance: This paper significantly improves the accuracy of traffic conflict prediction by integrating the advantages of the random forest model (RF) and the long short-term memory network (LSTM). The ability of the random forest model in feature selection, combined with the processing of time series data by the long short-term memory network, enables the model to capture the complex dynamics and key features in traffic flow, which not only improves the accuracy of prediction, but also enhances the model's response speed to real-time data, providing faster and more accurate decision support for traffic management.
[0027] (2) Optimizing feature selection and model integration: The present invention uses a random forest model for feature selection to automatically identify the most critical features (factors) for traffic conflict prediction, thereby simplifying the model and improving its operating efficiency. At the same time, by inputting the selected features into the long short-term memory network, the present invention can deeply analyze the time series data and reveal the pattern of traffic conflicts changing over time. That is, the trajectory information is predicted through the long short-term memory network, and then the collision time (TTC) of the traffic conflict is calculated based on the trajectory information. This method of feature selection and model integration makes the prediction model more efficient and accurate when processing large-scale traffic data.
[0028] (3) Enhance the scientificity and foresight of traffic management: The model of the present invention is trained and verified based on actual traffic data, ensuring the practicality and reliability of the prediction results. Through early identification and early warning of traffic conflicts, the present invention provides scientific data support for traffic management departments, helping them to take preventive measures in advance and reduce the occurrence of traffic accidents. In addition, the flexibility and scalability of the model means that it can be adjusted according to the traffic characteristics of different regions, providing an effective tool for improving traffic safety. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] Figure 1 It is a schematic diagram of a flow chart of the present invention.
[0030] Figure 2 It is a loss function change diagram of the LSTM network of the present invention.
[0031] Figure 3 It is a comparison diagram between the predicted value X and the actual value of the conflicting vehicles of the present invention.
[0032] Figure 4 It is a comparison diagram between the predicted value Y and the actual value of the conflicting vehicles of the present invention.
[0033] Figure 5 It is a comparison diagram between the predicted speed and the actual speed of the conflicting vehicles of the present invention. DETAILED DESCRIPTION
[0034] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0035] The highway traffic conflict analysis and prediction method based on RF-LSTM algorithm includes the following steps:
[0036] Step 1: Data Collection
[0037] Data collection includes: deploying equipment on highways to collect traffic flow data.
[0038] Data collection is the basis for building an effective traffic conflict prediction model. Data collection can obtain sufficient and accurate vehicle traffic flow data on highways for in-depth analysis and model training.
[0039] The data sources involved in data collection include traffic monitoring cameras, vehicle sensor data and traffic management systems, as well as data collection equipment deployed at key locations on highways (including fixed monitoring points, mobile monitoring vehicles, and drones).
[0040] It is necessary to collect a bird's-eye view of the highway to facilitate subsequent analysis and prediction of vehicle trajectories.
[0041] High-precision GPS technology, radar and laser ranging technology, and video analysis technology are used to ensure the quality and integrity of the data. At the same time, the frequency and duration of data collection are determined to ensure the representativeness and adequacy of the data, such as continuous data collection during peak traffic hours and periodic data collection at different time periods.
[0042] In addition, relevant data protection regulations must be followed to ensure data security and privacy, including data encryption and anonymization. Through these detailed data collection steps, high-quality and diverse traffic flow data can be obtained, providing a solid foundation for subsequent data analysis and model training. These data will be used to train random forest models and long short-term memory networks to achieve accurate prediction and analysis of traffic conflicts.
[0043] This example uses video data of a microscopic road in China. The video data is a 5.1k high-resolution highway traffic operation video collected by a drone, including 650 minutes of measurement data at 8 locations on Chinese highways. The scenes cover straight sections, weaving areas, merging / diverging sections of highways, including free flow, congested flow and other traffic flow states, as well as road construction and wet road conditions.
[0044] Step 2: Data Preprocessing
[0045] Data preprocessing includes: cleaning and normalizing the data to obtain the vehicle trajectory data set and ensure the consistency and comparability of the data.
[0046] Preprocessing the collected raw traffic data is a key step to ensure data quality and provide accurate information for subsequent analysis. Data preprocessing can greatly improve data availability and provide high-quality data support for building an accurate traffic conflict prediction model.
[0047] The steps of this embodiment include:
[0048] 2.1) Extracting vehicle trajectory dataset
[0049] ①Use Python’s pandas library to load high-resolution highway video data;
[0050] Use the pd.read_excel function to read the data stored in the Excel file and store it in a DataFrame object for subsequent processing.
[0051] The following is the specific Python code implementation:
[0052] data = pd.read_excel(data_path), where data_path is the path of the data file.
[0053] ② Use computer vision technology (existing technology) to extract vehicle trajectory datasets from video data to overcome difficulties such as image jitter, vehicle classification errors, and missing road information.
[0054] The vehicle trajectory dataset includes video information, vehicle information, road information, and collision time.
[0055] Video information includes video frame number and time.
[0056] The vehicle's own information includes vehicle number, vehicle type, trajectory coordinates (the vehicle's x-coordinate and y-coordinate in the top view), vehicle dimensions, speed, and acceleration.
[0057] Road information includes the lane the vehicle is in, the number of adjacent vehicles, and the shape of lane markings.
[0058] The collision time is the relative distance between the front and rear vehicles divided by the relative speed. The relative distance between the front and rear vehicles is calculated using the trajectory coordinates, and the relative speed is the speed difference between the front and rear vehicles.
[0059] 2.2) Data cleaning
[0060] Check and handle missing values and outliers in vehicle trajectory datasets.
[0061] For missing values, the vehicle trajectory dataset containing missing values is deleted to ensure the integrity of the data;
[0062] For outliers, such as data with speed exceeding a reasonable range (such as 250km / h), they are removed from the vehicle trajectory dataset.
[0063] The corresponding Python code is:
[0064] data.dropna(inplace=True) and data=data[data['Speed']<=250].
[0065] 2.3) Feature Engineering
[0066] Features are constructed based on the vehicle trajectory dataset to meet the needs of subsequent model prediction.
[0067] The structural features are as follows:
[0068] 1. Front and rear interactive information: speed difference and acceleration difference with the front vehicle;
[0069] 2. Macro traffic flow: average acceleration, average headway, average speed, and average headway.
[0070] The relevant Python code is:
[0071] ① Speed difference with the vehicle ahead:
[0072] data['Speed_Diff']=data['Speed']-data['Leading_Vehicle_Speed']
[0073] ② Acceleration difference with the vehicle in front:
[0074] data['Acc_Diff']=data['Acceleration']-data['Leading_Vehicle_Acceleration']
[0075] ③Average acceleration
[0076] ttc_data['Average_Acceleration']=ttc_data.apply(lambda row:calculate_averages(row,data),axis=1)
[0077] ④Average speed
[0078] ttc_data['Average_Velocity',]=ttc_data.apply(lambda row:calculate_averages(row,data),axis=1)
[0079] ⑤Average headway
[0080] ttc_data['Average_Time_Headway',]=ttc_data.apply(lambda row:calculate_averages(row,data),axis=1)
[0081] ⑥Average headroom
[0082] ttc_data['Average_Following_Distance']=ttc_data.apply(lambda row:calculate_averages(row,data),axis=1)
[0083] The final vehicle trajectory dataset includes the number of video frames, time, vehicle number, vehicle type, trajectory coordinates, vehicle dimensions, speed, acceleration, vehicle lane, adjacent vehicle number (including the front vehicle and left and right adjacent vehicles), lane marking line shape, speed difference with the front vehicle, acceleration difference with the front vehicle, average acceleration, average headway time, average speed, and average headway distance.
[0084] 2.4) Normalization
[0085] By normalizing the features of the vehicle trajectory dataset, data of different dimensions and ranges are converted to a unified standard so that they are in the same numerical range, such as the interval from 0 to 1, to eliminate the order of magnitude differences between different features, making model training more stable and efficient. Normalization often uses minimum-maximum scaling or Z-score standardization.
[0086] The features that need to be normalized include: speed, acceleration, speed difference with the preceding vehicle, acceleration difference with the preceding vehicle, average acceleration, average headway, average speed, and average headway.
[0087] Use MinMaxScaler in the sklearn library to normalize all numerical features so that the values of these features are between 0 and 1. The formula is as follows:
[0088]
[0089] Where: X is the original value of the data, X′ is the normalized value of the data, max is the maximum value of the feature to which the data belongs, and min is the minimum value of the feature to which the data belongs.
[0090] The data is then verified to ensure its accuracy and consistency.
[0091] 2.5) Divide the training set and test set
[0092] The vehicle trajectory dataset is split into training and testing sets to train the model and evaluate its performance.
[0093] The train_test_split function is used to split the vehicle trajectory dataset into a training set and a test set, with the training set accounting for 80% and the test set accounting for 20%, to facilitate subsequent model (random forest model and long short-term memory network) training and evaluation.
[0094] Step 3: Train the K-means clustering model for traffic conflict clustering analysis
[0095] The K-means clustering model is trained to classify the traffic conflicts in the vehicle trajectory dataset, which can be divided into two types of traffic conflicts: rear-end collision and lane change conflict.
[0096] The K-means clustering model is an unsupervised learning algorithm that groups data points into different clusters based on the similarities between the data points.
[0097] Through the K-means clustering model, complex traffic conflict data are grouped according to specific characteristics, namely, divided into rear-end collisions and lane change conflicts. Each type has its own unique characteristics and occurrence patterns, so as to carry out more targeted analysis and prediction. This classification not only helps to deeply understand the characteristics of different types of conflicts, but also provides more refined data support for subsequent model training. In addition, the clustering results can also be used to identify specific patterns and trends in traffic flow, thereby providing valuable insights for traffic management and the formulation of safety measures. Through this detailed clustering analysis, the present invention can ensure that the model can perform customized predictions and analyses for different types of traffic conflicts, thereby improving the accuracy and practicality of the predictions.
[0098] The steps of this embodiment include:
[0099] 3.1) Determine clustering features
[0100] Features are extracted from the preprocessed vehicle trajectory dataset as input to the K-means clustering model.
[0101] The extracted features include vehicle speed, trajectory coordinates of the vehicle itself, the trajectory coordinates of the preceding vehicle and the trajectory coordinates of the left and right adjacent vehicles, time interval (calculated based on time), and angle difference (calculated based on trajectory coordinates).
[0102] 3.2) Determine the number of clusters
[0103] It is necessary to determine the number of clusters, that is, the number of clusters. In this embodiment, in order to perform K-means clustering, K-Means in the scikit-learn library is used, and n_clusters=2 is set because two types of traffic conflicts need to be distinguished.
[0104] 3.2) Training and optimizing models
[0105] Call the fit method to train the model and use the labels_ attribute to get the cluster label for each data point.
[0106] K-means clustering is used to iteratively group data points in the feature space until a stopping condition is met, such as minimizing the intra-cluster difference or reaching a preset number of iterations.
[0107] 3.3) Traffic conflict classification
[0108] The K-means clustering model divides the vehicle trajectory dataset into rear-end conflicts and lane-changing conflicts.
[0109] Step 4: Train a random forest model for feature selection
[0110] A random forest model (RF) is trained to analyze the data (vehicle trajectory dataset) to identify the most influential features for traffic conflict prediction.
[0111] The data (vehicle trajectory dataset) is fed into the random forest model, which evaluates the importance of each feature by building multiple decision trees and combining their predictions. This process involves multiple random sampling of the dataset and random selection of features in each tree, thereby ensuring the generalization ability of the model and reducing the risk of overfitting.
[0112] The feature importance scores of the random forest model can determine which features are most directly associated with the occurrence of traffic conflicts. These features are then used to train subsequent long short-term memory networks to analyze the dynamic changes of these factors in time series.
[0113] Feature selection not only improves the prediction efficiency of the model, but also helps to deeply understand the mechanism behind traffic conflicts and provide a scientific basis for the formulation of traffic management and safety strategies. Through this meticulous feature selection process, it can ensure that the model focuses on the most relevant data, thereby improving the accuracy and reliability of traffic conflict prediction.
[0114] The steps of this embodiment include:
[0115] 4.1) Data processing and segmentation
[0116] ① Use the read_excel function of the pandas library to load the vehicle trajectory dataset stored in the Excel file.
[0117] ② According to the training set and test set divided in step 2.5), the vehicle trajectory dataset is divided into feature variables (X) and target variables (Y).
[0118] The initial feature variables (X) are as follows:
[0119]
[0120] The target variable (Y) is the collision time.
[0121] ③Convert the collision time (TTC, time to collision) into a binary value for easy model processing.
[0122] A TTC of less than 2 seconds is marked as 1 (indicating a conflict), and a TTC of 2 seconds or more is marked as 0 (indicating a non-conflict).
[0123] 4.2) Training and optimizing models
[0124] The feature variables (X) and target variables (Y) belonging to rear-end collisions are input into the random forest model for training and testing. The feature variables (X) and target variables (Y) belonging to lane change conflicts are input into the random forest model for training and testing.
[0125] In order to optimize the parameters of the random forest model, the RandomizedSearchCV function is used for random search.
[0126] The parameter grid includes the number of decision trees (n_estimators), the maximum number of features (max_features), the maximum depth of the decision tree (max_depth), the minimum number of samples required to split a node (min_samples_split), the minimum number of samples required to be a leaf node (min_samples_leaf), and whether to use bootstrap sampling (bootstrap).
[0127] By setting n_iter to 100 and cv to 3, the present invention performs 100 random searches and uses 3-fold cross validation to evaluate the performance of each iteration.
[0128] 4.3) Select the optimal feature combination
[0129] The feature importance scores output by the random forest model are as follows:
[0130] Ranking Influencing factors (characteristics) Importance Rating 1 Speed difference with the vehicle ahead 0.320304 2 Average headway 0.248348 3 Average headway 0.202173 4 Average speed 0.090671 5 Acceleration difference with the vehicle ahead 0.078730 6 speed 0.023844 7 Acceleration 0.018352 8 Average acceleration 0.008874 9 Vehicle Type 0.008704
[0131] Since the importance scores of the influencing factors ranked 1-3 (speed difference with the preceding vehicle, average headway distance, and average headway time) are all greater than 0.2, and the importance scores of the remaining factors are all less than 0.1, the gap is too large, so the speed difference with the preceding vehicle, the average headway distance, and the average headway time are selected as the most influential features for traffic conflict prediction.
[0132] The invention can find the optimal combination of features, thereby improving the prediction performance of the model and ensuring that the model has higher accuracy and reliability in predicting traffic conflicts.
[0133] Step 5: Train LSTM for trajectory prediction
[0134] Train a long short-term memory network to predict the future trajectory of the vehicle from time series format data.
[0135] The selected features are analyzed for time series using a long short-term memory network (LSTM network) to train the model to predict the future trajectory of the vehicle. As a special type of recurrent neural network, the LSTM network is good at processing and predicting time series data and can capture long-term dependencies.
[0136] First, the time series of the data is formatted to obtain time series data to ensure that the input data can reflect the timing characteristics of vehicle movement. Then, the training set and test set are divided to evaluate the performance of the model. Next, the LSTM network structure is designed, including determining the number of layers, the number of neurons in each layer, and hyperparameters such as the activation function. During the training process, the LSTM network gradually adjusts the internal weights to minimize the prediction error by learning the patterns in the historical data. In addition, in order to prevent overfitting, regularization techniques such as dropout are introduced. After the training is completed, the model is verified using the test set to evaluate its generalization ability on unknown data.
[0137] Therefore, the LSTM network can predict the trajectory of the vehicle, that is, the position and speed within 1 second in the future, to support the early identification and prevention of traffic conflicts. This prediction capability is crucial for real-time traffic management and accident prevention, and helps improve road use efficiency and safety.
[0138] The steps of this embodiment include:
[0139] 5.1) Time Series Formatting
[0140] According to the training set and test set divided in step 2.5), the trajectory coordinates (X coordinate, Y coordinate), speed, and features selected in the previous step (speed difference with the front vehicle, average headway, average headway time) of the conflicting vehicles are formatted into time series to obtain time series data so that the LSTM network can learn the temporal dependency.
[0141] The original data and time step are used as input to the create_dataset function, which then outputs the formatted time series data. In this step, the present invention organizes past data points into sequences for predicting future values.
[0142] 5.2) Training and optimizing models
[0143] The time series data of rear-end collision is input into the LSTM network for training and testing. The time series data of lane change conflict is input into the LSTM network for training and testing.
[0144] 5.3) Trajectory Prediction
[0145] The LSTM network predicts the future trajectory of the vehicle.
[0146] The structure of the LSTM network is:
[0147] ①First add an LSTM layer and set return sequence to True to keep the integrity of the time steps. This means that the LSTM layer will output a complete sequence of time steps, which is crucial for capturing long-term dependencies in time series data.
[0148] ② Adding Dropout layers to prevent overfitting helps the model not be overly sensitive to the training data during training.
[0149] ③ Add another LSTM layer, and this time set the return sequence to False, because this is the last LSTM layer and the present invention only needs the final output.
[0150] ④Add a fully connected layer and activation function layer to output the prediction results.
[0151] When compiling the model, the present invention selects the adam optimizer and mean square error as the loss function, which is a common choice in time series prediction problems. The parameter adjustment results are as follows:
[0152] parameter value Optimal number of layers 1 Units 192 Activation Tanh Dropout 0 Optimizer Adam Learning rate 0.01
[0153] When training the model, the present invention uses two callback functions, Early Stopping and Model Checkpoint. Early Stopping is used to stop training when the loss of the validation set no longer decreases, which can prevent the model from overfitting. The model checkpoint is used to save the model with the best performance, that is, the model with the smallest loss on the validation set. Through these steps, the LSTM network of the present invention can learn the mode of vehicle movement and predict potential traffic conflicts, providing strong support for traffic management.
[0154] The specific formula of the LSTM network is as follows:
[0155] Assume that the input sequence X is (x1, x2…, x t ), the hidden layer state H is (h1, h2…, h t ), use the activation function to calculate the forgotten information:
[0156] f t =σ(W xf x t +W hf h t-1 +b f )
[0157] Where: f t is the output of the forget gate at time t; σ is the activation function; W xf is the weight vector from the input layer to the forget gate; x t is the input of the network at the current time t; W hf is the weight vector from the hidden layer to the forget gate; h t-1 is the state of the hidden layer at the previous moment; b f is the bias of the forget gate.
[0158] Update the information through the input gate:
[0159] i t =σ(W xi x t +W hi h t-1 +b i )
[0160] C t1 =tanh(W xc x t +W hc h t-1 +b c )
[0161] Where: i t is the output of the input gate at time t; W xi is the weight vector from the input layer to the input gate; b i is the bias of the input gate; C t1 is the state of the cell at the current moment; tanh is the activation function; W xc is the weight vector from the input layer to the output gate; b c is the bias of the cell unit.
[0162] Combine the calculation results of the forget gate and the output gate to get the output C of the cell at the current moment t :
[0163] C t =f t *C t-1 +i t *C t1
[0164] Where: * is the multiplication of vector elements; C t-1 is the state of the cell unit at the previous moment.
[0165] Compute the output on the new cell:
[0166] o t =σ(W xo x t +W ho h t-1 +b o )
[0167] h t =o t *tanh(c t )
[0168] In the formula: o t is the output of the output gate at time t; W xo is the weight vector from the input layer to the output gate; Who is the weight vector of the input and the cell state; b o is the bias of the output gate; h t is the predicted value of the traffic flow sequence at time t.
[0169] like Figure 2 As shown in the figure, as the number of iterations increases, the loss function values of the model training set (blue curve) and the test set (yellow curve) both show a rapid downward trend and finally stabilize. The final loss function value of the test set is basically the same as that of the training set, and the difference between the two is small, indicating that the model training and prediction effects are good.
[0170] Step 6: Traffic conflict prediction
[0171] Traffic conflict prediction involves using traffic conflict prediction models to predict conflicts in traffic flows on highways and identify potential high-risk areas and times.
[0172] 6.1) The K-means clustering model, random forest model (RF) and long short-term memory network (LSTM network) are combined to form a traffic conflict prediction model (RF-LSTM).
[0173] In the traffic conflict prediction model, the K-means clustering model is first used to distinguish the types of traffic conflicts, and then the importance scores of the features are obtained from the random forest model, which helps to understand which factors have the greatest impact on traffic conflicts. Then, the long short-term memory network is used to predict future traffic conditions based on time series data.
[0174] The traffic conflict prediction model not only takes into account the static characteristics that affect traffic conflicts, but also incorporates dynamic changes in the time dimension. It can reduce the deviation that may be caused by a single model, improve the stability and accuracy of the prediction, and thus be able to more comprehensively predict the occurrence of traffic conflicts.
[0175] 6.2) Deployment of traffic conflict prediction model
[0176] The traffic conflict prediction model is deployed to the actual traffic monitoring system to predict conflicts in real-time traffic flow on highways and identify potential high-risk areas and times.
[0177] The traffic conflict prediction model identifies road sections or time periods with a higher risk of traffic conflicts. The traffic management department analyzes the prediction results and can take measures in advance, such as adjusting the settings of traffic lights or issuing traffic warnings, to reduce the occurrence of traffic accidents.
[0178] 6.3) Traffic Conflict Prediction
[0179] ① The traffic conflict prediction model outputs the predicted trajectory (within 1 second), and calculates the collision time (TTC) based on the predicted trajectory.
[0180] The TTC calculation formula is the relative distance between the front and rear vehicles divided by the relative speed, and the result is in seconds.
[0181] The relative distance between the front and rear vehicles is calculated by the trajectory coordinates, and the relative speed is the speed difference between the front and rear vehicles.
[0182] ②Set the collision threshold: Set the collision threshold to 2s.
[0183] ③ Determine traffic conflicts
[0184] When the collision time is less than or equal to the collision threshold, it is considered that there is a traffic conflict, and the final prediction result is obtained: a rear-end collision or a lane change conflict occurs.
[0185] 6.4) Model validation (verify the prediction accuracy of the model by comparing it with actual traffic data and evaluate the performance of the model under different traffic conditions)
[0186] In order to verify the prediction accuracy of the model, the prediction results are compared with the actual traffic data. The difference between the model prediction value and the actual value is measured by statistical indicators, such as the mean square error (MSE). The smaller the indicator value, the more accurate the model prediction. In this way, the performance of the model under different traffic conditions can be evaluated, and the model can be adjusted and optimized as needed to improve its prediction performance. This process ensures that the model is not only effective in theory, but also plays an important role in practical applications.
[0187] The experimental results show that the model achieves good performance in both position and velocity prediction.
[0188] Position prediction: Figure 3 As shown, the RMSE of the Y coordinate is about 17 cm, which is very accurate; Figure 4 As shown, the RMSE of the X coordinate is about 1.0 meter. Considering the complexity of the traffic environment and the high speed of vehicles on the highway, this error is within an acceptable range.
[0189] Speed prediction: Figure 5 As shown, the RMSE of speed is about 3.43 m / s, indicating that the model has a high accuracy in predicting vehicle speed.
[0190] In summary, the present invention uses machine learning and deep learning techniques to predict and analyze traffic conflicts on highways, combining data science, traffic engineering and computer science, aiming to improve road safety and the efficiency of traffic management through advanced algorithms.
[0191] The main steps of the present invention include: using a method combining random forest (RF) and long short-term memory network (LSTM) to analyze and predict highway traffic conflicts; firstly, using K-means clustering algorithm to classify traffic conflicts (conflicts are divided into two categories: rear-end collision and lane change conflict), then identifying key influencing factors (such as speed difference between conflicting vehicles and leading vehicles, headway and headway, etc.) through random forest model, then, taking the X coordinate, Y coordinate, speed of the conflicting vehicles and the key variables predicted in the previous text as input variables, using long short-term memory network to explore the dynamic influence of these factors on time series; the model can effectively predict vehicle trajectories and potential traffic conflicts, showing good adaptability to actual traffic flow conditions, and providing support for traffic flow management by early identification of potential risks; the method combines random forest for feature selection and LSTM for processing time series dynamics, providing a powerful tool for traffic engineers and policy makers to make wise decisions and implement effective traffic management strategies.
[0192] The present invention significantly improves the accuracy of traffic conflict prediction by integrating the advantages of random forest (RF) and long short-term memory network (LSTM). The ability of random forest algorithm in feature selection, combined with LSTM's processing of time series data, enables the model to capture the complex dynamics and key features in traffic flow. This integrated approach not only improves the accuracy of prediction, but also enhances the model's response speed to real-time data, providing faster and more accurate decision support for traffic management.
[0193] Embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes. The schemes in the embodiments of the present invention may be implemented in various computer languages, for example, object-oriented programming language Java and literal scripting language JavaScript, etc.
[0194] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0195] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0196] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0197] Although the preferred embodiments of the present invention have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention.
[0198] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.
Claims
1. A highway traffic conflict analysis and prediction method based on RF-LSTM algorithm includes the following steps: Step 1: Deploy equipment on highways to collect traffic flow data; Step 2: Clean and normalize the data to obtain the vehicle trajectory data set; Step 3: Train the K-means clustering model to perform traffic conflict clustering analysis; Step 4: Train the random forest model for feature selection; Step 5: Train the long short-term memory network for trajectory prediction; Step 6: Conflict prediction of traffic flow on the highway is performed to identify potential high-risk areas and times.
2. The highway traffic conflict analysis and prediction method based on the RF-LSTM algorithm according to claim 1 is characterized in that: The step 2 comprises: first extracting a vehicle trajectory data set and performing data cleaning, then constructing features according to the vehicle trajectory data set, then normalizing the features, and finally dividing the vehicle trajectory data set into a training set and a test set; the features constructed according to the vehicle trajectory data set include a speed difference with the preceding vehicle, an acceleration difference with the preceding vehicle, an average acceleration, an average headway, an average speed, and an average headway.
3. The highway traffic conflict analysis and prediction method based on the RF-LSTM algorithm according to claim 2 is characterized in that: The vehicle trajectory dataset includes video frame number, time, vehicle number, vehicle type, trajectory coordinates, vehicle outer dimensions, speed, acceleration, vehicle lane, adjacent vehicle number, lane marking line shape, speed difference with the preceding vehicle, acceleration difference with the preceding vehicle, average acceleration, average headway time, average acceleration, and average headway distance.
4. The highway traffic conflict analysis and prediction method based on the RF-LSTM algorithm according to claim 3 is characterized in that: The step 3 includes: determining clustering features and the number of clusters and optimizing a K-means clustering model; the K-means clustering model divides the vehicle trajectory data set into rear-end collisions and lane change conflicts.
5. The highway traffic conflict analysis and prediction method based on the RF-LSTM algorithm according to claim 4 is characterized in that: The step 4 includes: firstly dividing the vehicle trajectory data set into feature variables and target variables, then converting the target variables into binary values, and finally training and optimizing the random forest model; and selecting the features that have the greatest impact on traffic conflict prediction according to the importance scores output by the random forest model.
6. The highway traffic conflict analysis and prediction method based on RF-LSTM algorithm according to claim 5 is characterized in that: The characteristic variables include speed, acceleration, vehicle type, speed difference with the preceding vehicle, acceleration difference with the preceding vehicle, average acceleration, average headway, average speed, and average headway; The target variable is the collision time.
7. The highway traffic conflict analysis and prediction method based on RF-LSTM algorithm according to claim 6 is characterized in that: The step 5 includes: first converting the trajectory coordinates, speed and features selected in step 4 of the vehicle into time series data, and then training and optimizing the long short-term memory network; the long short-term memory network predicts the trajectory of the vehicle.
8. The highway traffic conflict analysis and prediction method based on RF-LSTM algorithm according to claim 7 is characterized by: The long short-term memory network includes an LSTM layer, a Dropout layer, an LSTM layer, a fully connected layer and an activation function layer.
9. The highway traffic conflict analysis and prediction method based on RF-LSTM algorithm according to claim 8 is characterized in that: The step 6 includes: firstly forming a traffic conflict prediction model by combining a K-means clustering model, a random forest model and a long short-term memory network, then deploying the traffic conflict prediction model, and finally using the traffic conflict prediction model to predict traffic conflicts on the traffic flow of the highway and identify potential high-risk areas and times.
10. The highway traffic conflict analysis and prediction method based on RF-LSTM algorithm according to claim 9 is characterized in that: The traffic conflict prediction includes calculating the collision time according to the vehicle trajectory predicted by the traffic conflict prediction model. When the collision time is less than or equal to the collision threshold, it is considered that there is a traffic conflict.
Citation Information
Cited By
Expressway interleaving area lane change accident risk early warning method and system based on vehicle trajectory data
CN121305922A