Road traffic incident real-time prediction system
By designing a real-time prediction system for road traffic events, integrating multiple models and final prediction through logistic regression classifiers, the problem of insufficient prediction accuracy and reliability in the prior art is solved, and more efficient traffic event prediction and robustness are achieved.
Patent Information
- Application Number
- CN202411553240.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-01
- Publication Date
- 2025-03-25
AI Technical Summary
The existing traffic event prediction methods are difficult to fully capture complex traffic data characteristics, resulting in insufficient prediction accuracy and reliability, and fail to effectively integrate the strengths of various models, so as to fully utilize the advantages of integrated models.
A real-time prediction system for highway traffic events was designed. Through data preparation module, model design and training module, model fusion module and system deployment module, multiple models such as BP neural network, LSTM, GRU, random forest and gradient improvement decision tree, capture different features and patterns in traffic data, and make final predictions through logistic regression classifiers.
It improves the accuracy and reliability of predictions, enhances the robustness of the system, can predict traffic events more accurately, and improves the usability and application efficiency of the model through the deployment of cloud server platforms.
Smart Images

Figure CN119694107A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of traffic management, and more specifically, to a real-time prediction system for highway traffic events. Background Art
[0002] In the field of traffic management, highway tunnels are often accompanied by high safety risks due to their special closed environment. Therefore, real-time and accurate prediction of possible traffic incidents in tunnels has become the key to improving the level of tunnel safety management. However, most of the existing traffic incident prediction methods are based on a single model or simple statistical analysis, which makes it difficult to fully capture the complex characteristics of traffic data, resulting in insufficient prediction accuracy and reliability. Although traditional machine learning models such as decision trees and support vector machines can process structured traffic data to a certain extent, due to the complexity of factors such as traffic flow, vehicle speed, and the proportion of large vehicles in tunnels, these models have uneven prediction effects on high-dimensional and variable feature data. In addition, existing methods generally have data imbalance problems, especially in highway traffic incident prediction, where the data of accidents is far less than normal data, which makes the model easily biased towards the majority class during training, thereby reducing the sensitivity to minority class events. In order to solve these problems, deep learning models such as long short-term memory networks (LSTM) and gated recurrent units (GRU) have been introduced in recent years to deal with the long-term dependency problem of time series data. However, a single model still has limitations, such as overfitting to specific scenarios or strong dependence on specific features, which makes the predictions lacking robustness and universality. Although some studies have begun to try multi-model fusion and improve prediction accuracy through integrated learning, these methods often only stay at simple model combinations and fail to effectively integrate the strengths of various models and give full play to the advantages of integrated models, resulting in a large room for improvement when dealing with complex traffic conditions. Therefore, in order to solve the problems existing in the prior art, a more comprehensive and intelligent multi-model fusion system is provided in the present application scheme, which can effectively solve the problem of data imbalance and improve the real-time prediction capabilities of highway tunnel traffic events. Summary of the invention
[0003] The present invention aims to overcome at least one defect (shortcoming) of the above-mentioned prior art and provide a real-time prediction system for highway traffic events, which is used to solve the problems that the prior art is difficult to fully capture the complex traffic data characteristics, resulting in insufficient prediction accuracy and reliability, as well as the failure to effectively integrate the strengths of various models, unable to give full play to the advantages of the integrated model, and the uneven prediction effects.
[0004] The technical solution adopted by the present invention is a real-time prediction system for highway traffic events, including: a data preparation module, used to collect data in real time and pre-process the data; a model design and training module, used to design and train several models using processed data; a model fusion module, used to fuse the trained models; a system deployment module, used to package the models and deploy them to a cloud service platform;
[0005] The data preparation module, the model design and training module and the model fusion module are connected in sequence, and the model design and training module and the model fusion module are connected to the cloud server platform through the system deployment module respectively; the cloud server platform is connected to the data preparation module for transmitting the data to be predicted to the model of the cloud server platform for prediction, and is connected to the result display module for real-time display of the prediction results;
[0006] Thus, in this application, by using the model fusion module to fuse the multiple models obtained by the model design and training modules to capture different features and patterns in traffic data, the accuracy and reliability of the prediction are greatly improved, and the time series model is set in the fused multiple models to effectively process and capture the time series dependency in the time series data, and the occurrence of traffic events has a more accurate prediction capability. At the same time, the prediction probability of multiple models is used as the feature input, and input into the stacked model obtained by fusion for final prediction, which can comprehensively consider the outputs of different models, reduce the errors that may be caused by a single model, and improve the overall robustness. The model is also deployed in the cloud server platform, which can improve the availability of the model, make the application of the model more efficient and convenient, and can quickly process and analyze traffic data, predict potential highway traffic events in real time, and provide timely warnings and response measures for highway tunnel management. A result display module is set to intuitively display the prediction results to the user, so as to help the user to specify the corresponding action plan in time for the prediction results. In addition, the system is highly flexible and can adjust and expand the model according to different data sources and needs to adapt to various traffic prediction tasks.
[0007] Preferably, the model design and training module includes a BP model training unit, a LSTM model training unit, a GRU model training unit, a random forest model training unit and a gradient boosting decision tree training unit. Different hyperparameters are used for training in each training unit, and training is performed batch by batch through a data loader. Finally, a validation set is used for performance evaluation.
[0008] The model design and training module set up in this system can configure the corresponding model training units according to different needs, so as to train several traffic event prediction models, which can effectively capture the different characteristics and patterns in traffic data, thereby effectively improving the accuracy and reliability of the prediction.
[0009] Preferably, the BP model training unit includes an input layer, a hidden layer and an output layer. First, the input data of the input layer is set to 13, and then the hidden layer is set to two layers, which are used to extract high-level features from the input data and perform abstract combination thereof, and finally the prediction probability of each category is output through the output layer; at the same time, a cross entropy loss function component is set to optimize the prediction accuracy of the BP model, and an Adam optimizer component is set to adaptively adjust the learning rate to ensure the stability and efficiency of parameter updates;
[0010] Preferably, the LSTM model training unit introduces three gate mechanism components, namely a forget gate, an input gate and an output gate, for controlling the flow of information so that information can be effectively retained or forgotten when processing long time series; the LSTM model also includes a back-propagation component for updating model parameters through a back-propagation algorithm;
[0011] Preferably, the GRU model training unit includes an input layer, a GRU layer and a fully connected layer, which are used to introduce a gating mechanism to control the flow of information; the GRU layer includes an update gate and a reset gate, which are used to determine the update of the hidden state;
[0012] Preferably, the random forest model training unit includes: a parameter initialization and data preparation component, which is used to initialize forest parameters and perform data preparation to generate input data; a decision tree construction and training component, which is used to select the optimal splitting point according to the characteristics of the input data to construct the structure of the decision tree and perform training; an integrated prediction component, which is used to perform independent prediction on each decision tree and obtain the final output by voting on the prediction results of all decision trees;
[0013] Preferably, the gradient boosting decision tree training unit includes an iterative optimization component for calculating the prediction residual of the current model and fitting the prediction residual with a new decision tree, thereby scaling the learning rate to optimize the model.
[0014] Preferably, the model fusion module includes:
[0015] A probability acquisition unit is used to obtain the predicted probability of the model output in each training unit in the model design and training module;
[0016] The stacked feature construction unit is used to splice the prediction probabilities of each model into a new feature matrix and generate a feature matrix dataset;
[0017] A stacking model building unit, used to integrate various models to generate a stacking model, and train it using a feature matrix data set;
[0018] The stacked model building unit also includes a logistic regression classifier, which learns the prediction results of each model to generate a final prediction.
[0019] In this system, corresponding components are set up to stack the outputs of multiple models, and a logistic regression classifier is used for ensemble learning, so that the outputs of different models can be comprehensively considered, the errors that may be caused by a single model can be reduced, and the overall robustness can be improved.
[0020] Preferably, the data preparation module includes:
[0021] A temporal feature extraction unit, used to convert event information into features that can be used by the model;
[0022] Data cleaning and merging unit, used to remove invalid data and merge data by aligning different data sets by time using the merge_asof function;
[0023] Result matching unit, used to integrate safety information into traffic data and integrate them into Excel files;
[0024] The data balancing processing unit is used to balance the imbalance between traffic event data and normal data.
[0025] Before training the model in the model design and training module, you also need to set up the corresponding module components to process the collected data to ensure that the model can be trained on cleaner and higher-quality data, which helps to speed up the convergence of the model, improve the training speed, and reduce the risk of overfitting. At the same time, it can also enable the model to better adapt to new data, thereby improving the performance of the model in real applications and significantly improving the performance and effect of the model.
[0026] Preferably, the time feature extraction unit includes:
[0027] Data reading and format conversion component, used to read vehicle data files and convert time columns into datetime format;
[0028] Function definition component, used to define event alignment function, aligning events to the next and previous full five minutes respectively, ensuring that all timestamps fall within the same five-minute interval;
[0029] The data segmentation and data processing component is used to divide the data into multiple blocks using code and traverse each five-minute interval to extract the data subset within the time period, and calculate the data subset of each five-minute interval to form a complete time feature data set.
[0030] Since traffic data such as traffic volume has a strong correlation with time, hour and minute information can be extracted from the timestamp to create time features. In the real world, the recording time of traffic events often lags behind the actual occurrence time. Studies have shown that this time difference is about 5 minutes. Therefore, this application uses 5 minutes of traffic parameters as time features, thereby forming a complete time feature data set by extracting time features, converting time information into features that can be effectively used by the model, thereby improving prediction accuracy.
[0031] Preferably, the data cleaning and merging unit includes:
[0032] Data cleaning component, used to identify and process missing values, abnormal values, and duplicate values in the data imported from the data source, and to convert the data into different data types, perform spelling detection, and perform feature engineering processing on the data;
[0033] The data merging component is used to align different data sets by time using the merge_asof function to ensure that each row of data contains all relevant information and merge the calculation results of all blocks.
[0034] Since the data collected by the front-end monitoring equipment contain abnormal values in some time periods, corresponding data cleaning components are set up in this system to clean the data and eliminate some invalid data. In addition, data merging components are set up to merge data sets from different sources to ensure data consistency and select representative samples for analysis, thereby improving data quality and reliability.
[0035] Preferably, the result matching unit includes:
[0036] The safety level classification component is used to classify the situations corresponding to the traffic data recorded in the safety level information into three categories: 0, 1, and 2, which respectively correspond to normal situations, abnormal parking situations in highway tunnels, and traffic incidents in highway tunnels;
[0037] The information fusion component is used to create a copy data frame, update the safety level corresponding to the successfully matched traffic records into the copy data frame, and integrate and export them into an Excel file.
[0038] In this system, safety information is integrated into traffic data by matching results, ensuring that each traffic record can obtain the corresponding safety level according to time and section.
[0039] Preferably, the data balancing processing unit includes:
[0040] The SMOTE component is used to generate new minority class samples by connecting minority class samples and their neighboring data in the feature space;
[0041] A random downsampling component is used to reduce the number of majority class samples to balance the dataset.
[0042] Since there is an extremely unbalanced problem in the number of traffic event data samples, in this application, the SMOTE component is set to use the SMOTE method to generate more minority class samples to balance the imbalance between traffic event data and normal data, and a random downsampling method is used to reduce the number of majority class samples, thereby further balancing the data set.
[0043] Preferably, the K-fold validation method is used for cross-validation in each model training unit of the model design and training module, which effectively improves the generalization ability of the model, avoids overfitting, and improves the accuracy of model prediction.
[0044] Preferably, the system deployment module includes:
[0045] Model packaging component, used to package the trained model into a model file and upload it to the cloud server;
[0046] The environment configuration component is used to create a cloud instance in the cloud server platform and install the corresponding dependencies and configure the operating environment, as well as write API services to access the model through the API to ensure that the model can normally receive requests and return prediction results;
[0047] Monitoring and maintenance components are used to configure logging and monitoring to ensure service stability and performance.
[0048] Therefore, in this system, by utilizing the system deployment module, the trained stacked model can be quickly deployed to the cloud server platform, which improves the availability, flexibility and security of the model and makes the model application more efficient and convenient.
[0049] Compared with the prior art, the present invention has the following beneficial effects:
[0050] 1. Improve forecast accuracy
[0051] By integrating multiple models such as BP neural network, LSTM, GRU, random forest, GBDT, etc., this method can capture different features and patterns in traffic data and improve the accuracy and reliability of prediction. Time series models such as LSTM and GRU can effectively process and capture the temporal dependencies in time series data and have more accurate prediction capabilities for the occurrence of traffic events.
[0052] 2. Enhance system robustness
[0053] By stacking the outputs of multiple models and using logistic regression classifiers for ensemble learning, the system can comprehensively consider the outputs of different models, reduce the errors that may be caused by a single model, and improve overall robustness. The introduction of technologies such as SMOTE and random downsampling solves the problem of class imbalance in traffic event data, prevents the model from ignoring minority events, and improves prediction capabilities.
[0054] 3. Real-time and high efficiency
[0055] The method is designed as a real-time application that can quickly process and analyze traffic data, predict potential traffic incidents in real time, and provide timely warnings and response measures for highway management.
[0056] 4. Strong adaptability
[0057] This method is not only applicable to highway tunnel traffic event prediction, but can also be extended to other traffic scenarios, such as urban traffic management, bridge monitoring, etc. The system is designed to be flexible and can adjust and expand the model according to different data sources and requirements to adapt to different traffic prediction tasks.
[0058] 5. Innovation
[0059] This invention has significant innovations in multi-model fusion, real-time traffic event prediction and data imbalance processing, providing a new technical solution for highway traffic management. BRIEF DESCRIPTION OF THE DRAWINGS
[0060] Figure 1 It is a schematic diagram of the structure of the system of the present invention.
[0061] Figure 2 This is a flow chart of the BP model provided by the present invention.
[0062] Figure 3 Flowchart of the LSTM model provided by the present invention.
[0063] Figure 4 This is a flow chart of the random forest model provided by the present invention.
[0064] Figure 5 This is a flow chart of the gradient boosting decision tree model provided by the present invention.
[0065] Figure 6 This is a flow chart of the model fusion provided by the present invention. DETAILED DESCRIPTION
[0066] The drawings of the present invention are only for illustrative purposes and should not be construed as limiting the present invention. In order to better illustrate the following embodiments, some parts of the drawings may be omitted, enlarged or reduced, and do not represent the size of the actual product; it is understandable to those skilled in the art that some well-known structures and their descriptions in the drawings may be omitted.
[0067] Example 1
[0068] like Figure 1 As shown, this embodiment provides a real-time prediction system for highway traffic events, the system comprising: a data preparation module, used to collect data in real time and pre-process the data; a model design and training module, used to design and train several models using processed data; a model fusion module, used to fuse the trained models; a system deployment module, used to package the models and deploy them to a cloud service platform;
[0069] The data preparation module, the model design and training module and the model fusion module are connected in sequence, and the model design and training module and the model fusion module are connected to the cloud server platform through the system deployment module respectively; the cloud server platform is connected to the data preparation module for transmitting the data to be predicted to the model of the cloud server platform for prediction, and is connected to the result display module for real-time display of the prediction results;
[0070] Thus, in this application, by using the model fusion module to fuse the various models obtained by the model design and training modules to capture different features and patterns in traffic data, the accuracy and reliability of the prediction are greatly improved, and a time series model is set in the fused multiple models to effectively process and capture the time series dependency in the time series data, so as to have a more accurate prediction capability for the occurrence of traffic events. At the same time, the prediction probabilities of multiple models are used as feature inputs, and are input into the stacked model obtained by fusion for final prediction, so that the outputs of different models can be comprehensively considered, the errors that may be caused by a single model can be reduced, and the overall robustness can be improved. The model is also deployed in the cloud server platform, which can improve the availability of the model, make the application of the model more efficient and convenient, and can quickly process and analyze traffic data, predict potential traffic events in real time, and provide timely warnings and response measures for highway tunnel management. A result display module is set to intuitively display the prediction results to the user, so as to help the user to specify the corresponding action plan in time for the prediction results. In addition, the system is highly flexible and can also adjust and expand the model according to different data sources and requirements to adapt to different traffic prediction tasks.
[0071] Preferably, in the data preparation module, traffic data is first collected from a variety of data sources, including data from ETC, radar, high-definition camera, thermal imaging camera, traffic event detection system and other equipment, including traffic volume x1, traffic saturation x2, large vehicle ratio x3, average vehicle speed x4, hazardous chemical vehicles on the way x5, number of overheated vehicles x6, number of accidents per million kilometers x7, and data on tunnel longitudinal maximum slope x8 and road condition index x9 are collected from tunnel design data and regular inspection data. In addition to static data, all dynamic data have time information.
[0072] Then, the time feature extraction unit, data cleaning and merging unit, result matching unit and data balance processing unit are used to pre-process the data, including data cleaning, format conversion, missing value filling, etc., to ensure the quality of the data. According to the real-time traffic data, the traffic volume x1, traffic saturation x2, large vehicle ratio x3, average vehicle speed x4, hazardous chemical vehicles on the way x5, number of over-temperature vehicles x6, number of accidents per million kilometers x7 and other real-time traffic data are converted and counted, and useful features are extracted from the processed data to generate the input feature matrix for the prediction model.
[0073] Preferably, in the time feature extraction unit, the event information is converted into features that can be used by the model; the process includes reading data and converting the time format, defining a time alignment function, processing data in blocks, processing data in blocks, and merging data. This embodiment sets a data reading and format conversion component to read the vehicle data file and convert the time column to the datetime format; and sets a function definition component to define an event alignment function to align the event to the next and previous full five minutes, respectively, to ensure that all timestamps fall within a unified five-minute interval; in addition, a data block and data processing component is set to use code to divide the data into multiple blocks and traverse each five-minute interval to extract a data subset within the time period, and calculate the data subset of each five-minute interval to form a complete time feature data set.
[0074] Specifically, in this embodiment, 5 minutes of traffic parameters are used as time features. First, the vehicle data file is read and the date column is converted to datetime format to ensure the correct parsing and processing of time data. Then, the time is aligned to the next and previous full five minutes respectively by defining functions to ensure that all timestamps fall within a unified five-minute interval. In addition, in order to process large data sets, the code divides the data into multiple blocks, each containing 500,000 rows of data, so that data can be processed efficiently in memory. And according to the minimum and maximum time of the data, a time range of five-minute intervals from the start time to the end time is generated, and each five-minute interval is traversed to extract the data subset within the time period. By calculating the total number of vehicles, the number of large vehicles, the total traffic volume, the proportion of large vehicles, the average speed and traffic saturation for each five-minute interval of the dynamic data subset, a complete time feature data set is formed, and the time information is converted into a feature that can be effectively used by the model, thereby improving the prediction accuracy.
[0075] Preferably, invalid data is removed in the data cleaning and merging unit and the data is merged by aligning different data sets in time using the merge_asof function.
[0076] Specifically, a data cleaning component is set up in this unit to perform data cleaning. Since the data collected by the front-end monitoring equipment are missing or have outliers in some time periods, it is necessary to eliminate some invalid data, import data from the data source, and identify and process missing values, outliers and duplicate values. Then, the data type is converted, the data is standardized or normalized, the format is unified and the text data is cleaned, and spell checking and feature engineering processing are performed, thereby effectively improving the quality of the data.
[0077] In this unit, a data merging component is also set to merge data. The merge_asof function is used to align different data sets by time. This function will merge the closest time records according to the time order. The results_df is merged with the vehicle speed data, the number of over-temperature vehicles data, and the number of dangerous goods vehicles data respectively to ensure that each row of data contains all relevant information, and finally the calculation results of all blocks are merged. Since the tunnel is predicted in sections in this embodiment, each row of merged data merged_df is used and expanded into multiple rows, so that each row contains the static data of a tunnel section, which is achieved by looping through each row of data and combining it with the static data of the tunnel. Thus, through the above operations, data sets from different sources are merged to ensure the consistency of the data, and representative samples are selected for analysis, which improves the quality and reliability of the data.
[0078] Preferably, the safety information is integrated into the traffic data in the result matching unit and integrated into an Excel file;
[0079] Specifically, in this embodiment, by setting the security level division component and the information fusion component, the security information is integrated into the traffic data, ensuring that each traffic record can obtain the corresponding security level according to the time and section. First, the security level is divided into three categories: 0, 1, and 2, corresponding to the normal situation, abnormal parking situation in the highway tunnel, and traffic incidents in the highway tunnel. The data of abnormal parking situation and traffic incidents are recorded in the security level information. Each data includes the time of event occurrence, event type, and event occurrence section. The time column is converted to datetime type for accurate comparison. Then a copy data frame is created and a new column is initialized. The time period and section information are extracted by iterating each traffic record, and the records of the corresponding time range and section are matched in the security level data. If a match is found, the corresponding security level is updated to the copy data frame. Finally, the integrated data frame is exported to an Excel file, and the main traffic data and security level information are loaded from the Excel file, and the security information is effectively integrated into the traffic data, ensuring that each traffic record can obtain corresponding and accurate security level information according to the time and section.
[0080] Preferably, the imbalance between traffic event data and normal data is balanced in the data balancing processing unit;
[0081] Specifically, this is achieved by setting up a SMOTE component and a random downsampling component in this unit. First, the SMOTE method is used to generate more minority class samples to balance the imbalance between traffic event data and normal data. The SMOTE method generates new minority class samples by connecting minority class samples and their adjacent data in the feature space. For the minority sample x i , randomly select a sample x from its adjacent data nm , generate new samples, the formula is as follows:
[0082] x i =x i +λ·(x nn -x i ) (1)
[0083] Among them, x i is a minority sample, x nm is a random sample from adjacent data, and λ is a random number between 0 and 1.
[0084] The random downsampling component is then used to reduce the number of majority class samples using a random downsampling method to further balance the dataset.
[0085] Next, in this embodiment, the data is divided into a training set, a validation set, and a test set in a ratio of 6:2:2. The training set is used for model training, the validation set is used to adjust parameters and evaluate model performance, and the test set is used to evaluate and test the final model. The data is normalized and converted to a standard normal distribution with a mean of 0 and a variance of 1. First, it is used to fit and normalize the training set data to ensure that the training data conforms to the standard normal distribution. Then, the test set data is subjected to the same normalization process to maintain the consistency of the data distribution. Data normalization helps to improve the prediction accuracy and training efficiency of the model.
[0086] Preferably, the model design and training module described in this embodiment includes a BP model training unit, a LSTM model training unit, a GRU model training unit, a random forest model training unit and a gradient boosting decision tree training unit. Different hyperparameters are used for training in each training unit, and training is performed batch by batch through a data loader, and finally a validation set is used for performance evaluation.
[0087] Preferably, if Figure 2 As shown, Figure 2 The BP neural network model flow chart provided for this embodiment includes three main parts in the BP model training unit: input layer, hidden layer and output layer. In this model, the input layer has 13 neurons, and each neuron corresponds to a feature. In addition to the above-mentioned traffic data and tunnel static data, the 13 neurons also have the start time and end time every five minutes. The start time is divided into start hours and start minutes, and the end time is divided into end hours and end minutes. Therefore, the dimension of the input data is 13. The hidden layer is set to two layers. The first hidden layer has 64 neurons, which is responsible for extracting high-level features from the input data. The second hidden layer has 32 neurons, which are used to further abstract and combine the features extracted by the first hidden layer. The output layer contains three neurons, corresponding to the three categories in the classification task. The output of each neuron represents the predicted probability of a category. In the hidden layer, the ReLU activation function is used to alleviate the gradient vanishing problem and accelerate the training process. For negative input, ReLU outputs 0; for positive input, ReLU outputs the input value itself. In the output layer, the Softmax function is used to convert the output of the network into a probability distribution. The formula of the Softmax function is:
[0088]
[0089] Among them, z i is the output value of the i-th category, p i is the predicted probability of the category, j represents the sample, and the denominator in the formula is the exponential sum of the output values of all categories.
[0090] In order to prevent overfitting, the Dropout layer is introduced to reduce excessive dependence on training data by randomly discarding a part of neurons in the network. The model training uses the cross entropy loss function (Formula 3) to optimize the prediction accuracy of the model.
[0091]
[0092] Where N is the number of samples, K is the number of categories, and y j,k is the true label (0 or 1) of sample j in category k, and p i,k is the predicted probability of model i for category k. The Adam optimizer is also used in the training process, combining the momentum method and adaptive learning rate to calculate the momentum estimate of the gradient and the weighted moving average of the square of the gradient (Equation 4 and Equation 5), which are updated by the momentum decay rate (0.9) and the mean decay rate (0.999), respectively. Bias correction is performed to calculate unbiased estimates. The model parameters are updated according to the learning rate (0.001) and the corrected momentum and squared gradient average. The Adam optimizer component ensures the stability and efficiency of parameter updates by adaptively adjusting the learning rate in each training step.
[0093]
[0094] Among them, m t is the first-order moment estimate at time step t (i.e., the exponentially weighted moving average of the gradient), which is used to estimate the gradient; β1 is the momentum decay rate, m t-1 is the first-order moment estimate at time step t-1; v t is the second-order moment estimate at time step t (i.e., the exponentially weighted moving average of the squared gradient), which is used to estimate the instability of the gradient (i.e., the variance of the gradient); v t-1 is the second-order moment estimate at time step t-1, β2 is the mean decay rate, is the gradient at time step t, which is the derivative of the loss function with respect to the model parameters θ.
[0095] In order to improve the generalization ability of the model and avoid overfitting, the K-fold cross-validation method is used in the training process. In this embodiment, the K value of cross-validation is set to 5. In each iteration, a subset is selected as the validation set, and the remaining K-1 subsets are used as training sets. Repeat K times so that each subset is verified. At the same time, the Adam optimizer is combined for parameter optimization. By continuously iterating the above steps, the model gradually optimizes the parameters, so that the loss function converges and the prediction accuracy is improved.
[0096] Preferably, if Figure 3 As shown, Figure 3The LSTM neural network model flow chart provided for this embodiment is used in the LSTM model training unit to process multidimensional sequence data including time features, traffic data, tunnel static data and historical statistical data to predict the target variable "safety level". Input features include time features such as "start hour", "start minute", "end hour", "end minute", and "traffic volume", "large vehicle proportion", "traffic saturation", "average speed", "number of overheated vehicles", "number of hazardous chemicals vehicles", "maximum longitudinal slope of tunnel", "number of accidents per million kilometers" and "road condition index" and other indicators related to traffic conditions. Through these features, LSTM can capture the dynamic relationship between time series features and different variables, so as to effectively predict road safety risks. In the LSTM model, three gate mechanisms (forget gate, input gate and output gate) are introduced to control the flow of information, so that information can be effectively retained or forgotten when processing long time series. In this model, the key parameters of the LSTM model include: input_size (the dimension of the input feature, set to 13, that is, the 13 features mentioned above), hidden_size (the number of units in the LSTM hidden layer, set to 50), num_layers (the number of LSTM layers, set to 2) and output_size (the number of output categories, set to 3). In addition, in order to prevent overfitting, the Dropout layer is used in the LSTM model, and the dropout rate is set to 0.5. In the forward propagation process of LSTM, the forget gate (f t ) determines which parts of the historical information need to be discarded (Formula 6); then, the input gate (i t ) Combine the current input and the hidden state of the previous moment to determine which new information will be stored in the unit state (C t ) in (Formula 7); Then, through the candidate memory cells Generate new candidate information (Formula 8), and combine it with the output of the forget gate to update the current unit state (Formula 9); finally, the output gate ( t ) determines which parts of the current unit state will be passed to the hidden state at the next moment (Equations 10 and 11).
[0097] f t =σ(W f ·[h t-1 ,x t ]+b f ) (6)
[0098] i t =σ(W i ·[h t-1 ,x t ]+b i ) (7)
[0099]
[0100] o t =σ(W o ·[h t-1 ,x t ]+b o ) (10)
[0101] h t =o t *tanh(C t ) (11)
[0102] For model training, the data is first divided into training and validation sets and standardized. Then, the data is converted to PyTorch tensors and reshaped to fit the LSTM model. During training, the cross entropy loss function is used to calculate the difference between the predicted value and the actual label, and the model parameters are updated through the back-propagation algorithm. To further optimize the training process, the Adam optimizer is used in combination with weight decay to prevent overfitting. In each training cycle (epoch), the model traverses the training set, gradually adjusts the parameters, and uses the validation set to evaluate the model performance after each round, recording the best model parameters. After training, the model is loaded with the optimal parameters to ensure that it achieves the best performance on the validation set.
[0103] Preferably, the GRU model training unit includes an input layer, a GRU layer and a fully connected layer, and its flowchart is similar to the LSTM model flowchart. The input layer is used to receive input with a feature dimension of input_size (set to 13). The GRU layer is the main recurrent unit, and hidden_size (set to 50) is set as the dimension of the hidden state, and num_layers (set to 2) is the number of GRU layers. The GRU layer determines the update of the hidden state by the update gate and the reset gate. The fully connected layer maps the output of the GRU layer to the dimension of the target category, that is, output_size (set to 3, corresponding to 3 types of results). The GRU model controls the flow of information by introducing a gating mechanism, which mainly includes three parts: update gate, reset gate and candidate activation. Update gate z t It is used to control the update degree of the current hidden state, and the calculation is as shown in Equation 12. Reset gate r t It is used to determine how much of the previous state is forgotten, and is calculated as shown in formula 13. Current memory content Calculated by formula 14, the final hidden state h t Updated by Equation 15. The fully connected layer maps the output of the GUR model to the target category.
[0104] z t =σ(W Z ·[h t ,x t ]+bz ) (12)
[0105] r t =σ(W r ·[h t ,x t ]+b r ) (13)
[0106]
[0107]
[0108] During training, the data is resized to the shape [batch_size, seq_len, input_size], where seq_len = 1 (since each sample has only one time step), the batch size is 64, the learning rate is 0.0001, and the weight decay is 1e-4. The loss function is cross entropy loss, and the optimizer uses Adam with a learning rate of 0.0001 and a weight decay of 1e-4, and the model parameters are updated by gradient descent.
[0109] Preferably, if Figure 4 As shown, Figure 4 The random forest model flow chart provided for this embodiment includes parameter initialization and data preparation components, decision tree construction and training components, and integrated prediction components in the random forest model training unit. Specifically, the random forest model improves the accuracy of classification or regression tasks by constructing multiple decision trees. Each decision tree is generated by random sampling with replacement of the training data set, and a portion of features are randomly selected at each node to find the optimal split point, thereby reducing overfitting and improving the generalization ability of the model. The main parameters of the model include the number of decision trees (n_estimators = 100) and the maximum number of features for splitting (max_features = 42), where the more decision trees there are, the more stable the performance of the model is usually. During the training process, the model selects the optimal split point according to the characteristics of the input data and constructs the structure of the tree. By making independent predictions on each tree, the final output is obtained by voting (classifying) the prediction results of all trees. The prediction result of the random forest is the majority voting result (classification), as shown in Formula 16. The goal of the random forest model is to improve the accuracy and robustness of the overall prediction by reducing the high variance characteristics of a single decision tree.
[0110]
[0111] in, is the predicted value of the random forest, Ti(x) is the predicted category of the input sample by the i-th tree, and mode means taking the majority.
[0112] Preferably, if Figure 5 As shown, Figure 5 The gradient boosting decision tree model flow chart provided for this embodiment, in the gradient boosting decision tree training unit, the gradient boosting decision tree optimizes the prediction accuracy by gradually constructing a series of decision trees. Each new tree is trained on the residuals of the previous tree to reduce the error of the overall model. The training process includes initializing the model, and then iteratively calculating the prediction residuals of the current model and fitting these residuals with a new decision tree. The prediction results of each new tree are scaled by the learning rate to adjust the contribution to the model. The main parameters include the number of trees (n_estimators = 100), the learning rate (learning_rate = 0.1), and the maximum depth of the tree (max_depth = 3). The formula for model training is:
[0113] F m =F m-1 (x)+η·T m (x) (17)
[0114] where F m (x) represents the predicted value of the mth iteration, F m-1 (x) represents the predicted value of the m-1th iteration, T m (x) represents the predicted value of the mth decision tree, and η is the learning rate.
[0115] In this embodiment, each model is trained using different hyperparameters, each model is trained batch by batch through the data loader, and the performance is evaluated using the validation set, ensuring that the model has high prediction accuracy, can capture different features and patterns in traffic data, and improve the accuracy and reliability of prediction. In addition, time series models such as LSTM and GRU can effectively process and capture the time series dependencies in time series data, and have more accurate prediction capabilities for the occurrence of traffic events.
[0116] Preferably, the model fusion module includes:
[0117] A probability acquisition unit is used to obtain the predicted probability of the model output in each training unit in the model design and training module;
[0118] The stacked feature construction unit is used to splice the prediction probabilities of each model into a new feature matrix and generate a feature matrix dataset;
[0119] A stacking model building unit, used to integrate various models to generate a stacking model, and train it using a feature matrix data set;
[0120] The stacked model building unit also includes a logistic regression classifier, which learns the prediction results of each model to generate a final prediction.
[0121] Specifically, Figure 6 As shown, Figure 6 The model fusion flow chart provided for this embodiment, in this module, the prediction probabilities of the five models obtained in each training unit in the model design and training module are used as feature inputs, and a stacked model is constructed for final prediction. After the training is completed, the prediction results of the stacked model are evaluated through evaluation indicators (accuracy, precision, recall rate and F1 score).
[0122] First, the probability output of each model is obtained through the probability acquisition unit, and the get_probabilities function is used to predict each model. This function uses the eval mode of the model and forward propagates the input data to obtain the predicted probability of each category. The models include BP neural network, LSTM, GRU, random forest and gradient boosting decision tree. The prediction result generated by each model is a probability distribution. For example: in this embodiment, the predicted probability of test sample 1: [0.1, 0.7, 0.2], the predicted probability of test sample 2: [0.3, 0.4, 0.3], and the predicted probability of test sample 3: [0.05, 0.2, 0.75]. For each model i and sample j, the predicted probability of model i for sample j is p ij .
[0123] Then, the predicted probabilities of all models are concatenated into a new feature matrix using the stacked feature building unit. Specifically:
[0124] These features are used as input to the stacked model. The feature matrix is a two-dimensional array, where each row is the feature of a sample and contains the predicted probabilities of all models.
[0125] Construct the prediction probability matrix P of model i i , in M models, the prediction probability matrix Pi output by each model is an N×K matrix, where N is the number of samples and K is the number of categories. The prediction probability matrix P i As shown below:
[0126]
[0127] in, is the probability that sample j belongs to category k for model i.
[0128] For sample j, the predicted probability matrix P of each model i is i Concatenate by column to get the predicted probability feature vector S of sample j on all models j , if each model has K categories, then the predicted probability feature vector S jThe number of columns is M×K. The predicted probability feature vector S for each sample j is j for:
[0129]
[0130] Among them, S j is the predicted probability feature vector of sample j on all models.
[0131] Finally, the predicted probability feature vector S of N samples j is j The new feature matrix S is obtained by concatenating columns and generating a feature matrix dataset. This matrix contains the prediction information of all base models for each sample and will be used to train the stacked model.
[0132]
[0133] Each row S j It is the predicted probability concatenation feature of sample j on all models. Each column is the set of predicted probabilities of each model for a certain category.
[0134] Preferably, in the stacking model building unit, logistic regression is used as the final classifier of the stacking to train the feature matrix S data set. This classifier will learn how to combine the prediction results of each model to generate the final prediction, thereby obtaining the stacking model, wherein the formula of the logistic regression is:
[0135]
[0136] Where P(y=k|x) represents the probability that the target variable y is equal to category k given the input feature X; X represents the input feature, that is, the row of the feature matrix; and b k represents the weight and bias term of category k; K represents the number of categories; j represents the sample; and b j Represents the weight and bias term of sample j.
[0137] Logistic regression learns these weights and bias terms by maximizing the log-likelihood function. The logistic regression model is trained using the stacked feature matrix S and the true labels. The training process uses the training data (stacked features and corresponding labels) to optimize the weights W and bias b of the logistic regression model. The training process minimizes the loss function through an optimization algorithm to improve classification accuracy.
[0138] Preferably, after training is completed, the logistic regression model is evaluated using a validation set or a test set to determine its performance, including indicators such as accuracy, precision, recall, and F1 score, and to generate a confusion matrix. The logistic regression model will be able to make predictions on new data, obtain the stacked features of the new data, pass the new data through all the basic models to obtain the predicted probability, and splice it into a feature matrix, apply the logistic regression model, and input these features into the trained logistic regression model to obtain the final prediction results.
[0139] Preferably, the system described in this embodiment further includes a system deployment module, and the system deployment module includes:
[0140] Model packaging component, used to package the trained model into a model file and upload it to the cloud server;
[0141] The environment configuration component is used to create a cloud instance in the cloud server platform and install the corresponding dependencies and configure the operating environment, as well as write API services to access the model through the API to ensure that the model can normally receive requests and return prediction results;
[0142] Monitoring and maintenance components are used to configure logging and monitoring to ensure service stability and performance.
[0143] In this embodiment, by utilizing the system deployment module, the trained BP, LSTM, GRU, random forest, GBDT models and integrated stacking models can be quickly deployed to the cloud server platform production environment. Then the cloud service platform can directly receive the data to be predicted from the data preparation module for real-time prediction, which improves the availability, flexibility and security of the model and makes the model application more efficient and convenient.
[0144] In this embodiment, a result display module is also used to construct a user-friendly interface. The prediction results (i.e., the possibility of traffic incidents) generated by real-time prediction of the latest traffic data according to the stacking model can be displayed in real time in the user interface for the possibility of traffic incidents in each segmented highway tunnel, and displayed in different colors (normal situation (0) is indicated by green, abnormal parking situation in the highway tunnel (1) is indicated by yellow, and traffic incidents in the highway tunnel (2) are indicated by red). Decision suggestions are provided based on the prediction results to help users (such as traffic management personnel and drivers) formulate corresponding action plans to optimize traffic flow and improve road safety.
[0145] Example 2
[0146] This embodiment takes a single tunnel of a highway as an example, collects the traffic data of the tunnel within one year, the tunnel design data and the regular inspection data, and the tunnel is equipped with a traffic event monitoring system, a high-definition camera, a radar vision integrated machine, and an infrared thermal imaging camera. Combined with the ETC card port data in front of the tunnel entrance, various types of traffic raw data in the tunnel are obtained. From the multi-source heterogeneous data, the data within five minutes are sorted and selected as a sample. The various types of data are combined by time feature extraction, and the hour and minute information is extracted from the timestamp of the original data to create a time feature. The 5-minute traffic parameters are used as the time feature, and the data is read, the time format is converted to the datetime format, the time alignment function is defined, the data is processed in blocks, the data is processed in blocks, and the data is merged. Traverse each five-minute interval and extract the data subset within the time period. For each dynamic data subset of the five-minute interval, the total number of vehicles, the number of large vehicles, the total traffic flow, the proportion of large vehicles, the average speed and the traffic saturation are calculated to form a complete time feature data set. Since the data collected by the front-end monitoring equipment is missing or outliers in some time periods, it is necessary to eliminate some invalid data. Import data from the data source and identify and handle missing values, outliers, and duplicate values. Then, convert data types, standardize or normalize data, unify formats, clean text data, perform spell checking and feature engineering. Use the merge_asof function to align different data sets by time. Merge the results df with the speed data, the number of overheated vehicles data, and the number of dangerous goods vehicles data to ensure that each row of data contains all relevant information. Finally, merge the calculation results of all blocks.
[0147] Since the tunnel is divided into five sections, the number of accidents per million kilometers x7, the maximum longitudinal slope of the tunnel x8, and the road condition index x9 of each section are different. The rest of the data are the same. Therefore, one sample needs to be expanded into five samples according to the different sections, as shown in Table 1. The traffic events, event sections, and event time statistics in the tunnel are exported from the traffic event monitoring system. The safety level is divided into three categories: 0, 1, and 2, corresponding to normal conditions, abnormal parking conditions, and traffic events in the tunnel. Each piece of data of the exported tunnel traffic event includes the time of occurrence, event type, and event section. By iterating each traffic record, extracting the time period and section information, and matching the records of the corresponding time range and section in the safety level data. If a match is found, the corresponding safety level is updated to the copy data frame. Finally, the integrated data frame is exported to ensure that each record is accompanied by accurate safety level information. Through the above process, a data set with a data quantity of 527076 is obtained. The category distribution of the original data set: [0: 527039 1: 26 2: 10].
[0148]
[0149] Table 1
[0150] Preferably, since the number of traffic event data samples is extremely unbalanced, it is also necessary to comb the data set for sample balance. This method uses the SMOTE oversampling and downsampling method to oversample and downsample the traffic event data and non-traffic event data respectively. The traffic event data and the breakdown parking data are oversampled to 40,000 data, and the category distribution of the oversampled data set is: [0: 527039 1: 40000 2: 40000]. The remaining data is then downsampled to 40,000, and the category distribution of the downsampled data set is: [0: 40000 1: 40000 2: 40000].
[0151] Preferably, in this embodiment, each model is trained for two epochs, and the results of each training are as follows:
[0152] In the BP neural network model, its model design includes two hidden layers and one output layer. The network structure is: the input layer is connected to the first hidden layer (with 64 neurons), the first hidden layer is connected to the second hidden layer (with 32 neurons) through the ReLU activation function, and finally, the second hidden layer is connected to the output layer through the Dropout layer. The output layer is used to generate classification results. The model is trained using the Adam optimizer with a learning rate of 0.001 and a weight decay of 1e-2. During the training process, the loss is calculated by CrossEntropyLoss, and the weights are updated by back propagation. In each epoch, the model is trained on the training data, and the performance is evaluated on the validation data to calculate the accuracy. If the accuracy on the validation set improves, the state of the current model is saved. Finally, the model is evaluated by K-fold cross validation, the accuracy of each fold is output, and the average performance index is calculated. The training results are shown in Table 2:
[0153]
[0154] Table 2
[0155] As can be seen from Table 2, the results of the BP neural network model on the training set are: average accuracy: 0.9694, average precision: 0.9711, average recall: 0.9694, and average F1 score: 0.9692.
[0156] In the LSTM model, its design includes one LSTM layer and one fully connected layer. The LSTM layer has 50 hidden units and 2 layers, processing the input data sequence to capture the time series characteristics. The input data passes through the LSTM layer, where the hidden state and cell state are initialized to zero. The output of the LSTM layer is processed by the Dropout layer to prevent overfitting, and then passed to the fully connected layer to generate the final classification result. The model uses the Adam optimizer with a learning rate of 0.0005 and a weight decay of 1e-3. During the training process, CrossEntropyLoss is used to calculate the loss and optimize the network parameters through back propagation. Each epoch model is trained on the training set and the performance is evaluated on the validation set. K-fold cross validation is used for model evaluation to ensure the evaluation of the stability and generalization ability of the model. The LSTM model calculates the accuracy on the validation set and records the optimal model state for subsequent prediction and evaluation. The training results are shown in Table 3:
[0157]
[0158] Table 3
[0159] As can be seen from Table 3, the results of the LSTM model on the training set are: average accuracy: 0.9669, average precision: 0.9678, average recall: 0.9669, and average F1 score: 0.9668.
[0160] In the GRU model, its design includes a GRU layer and a fully connected layer. The GRU layer has 50 hidden units and 2 layers, which processes the input sequence data to capture the dynamic characteristics of the time series. The input of the model passes through the GRU layer, where the hidden state is initialized to zero. The output of the GRU layer is regularized by the Dropout layer to reduce the risk of overfitting, and then passed to the fully connected layer to generate the final classification prediction. The model uses the Adam optimizer, with the learning rate set to 0.0001 and the weight decay to 1e-4. During the training process, the loss is calculated using CrossEntropyLoss, and the parameters are optimized by back propagation. The model is trained on the training set and the performance is evaluated on the validation set. The stability and generalization ability of the GRU model are evaluated by K-fold cross validation. In each fold, the accuracy of the model on the validation set is recorded, and the best model state is saved for subsequent predictions and performance evaluation. The training results are shown in Table 4:
[0161]
[0162] Table 4
[0163] As can be seen from Table 4, the results of the GRU model on the training set are: average accuracy: 0.8285, average precision: 0.8376, average recall: 0.8285, and average F1 score: 0.8248.
[0164] In the random forest model, the design includes building a forest of multiple decision trees, each of which randomly selects features and samples during training to enhance the diversity and robustness of the model. The model is first trained on a balanced data set that has been processed with SMOTE and downsampling, and the classification accuracy is improved by integrating the prediction results of multiple decision trees. The model is trained on the training set and the fit method is used to learn the patterns in the data. In this embodiment, the accuracy of the random forest model on the test set is 0.9995.
[0165] In the gradient boosting decision tree model, its design is to iteratively construct a series of weak learners - decision trees, and each tree improves the model performance by gradually correcting the error of the previous tree. The training process starts with the initial model, calculates the residuals of each sample, and then trains a new decision tree on the residuals to minimize these residuals. This process is implemented by the ˋfitˋ method, passing the training data to the model. In each iteration, the new tree model is weighted and added to the existing model to optimize the loss function. After the training is completed, the model is evaluated on the test set to calculate its prediction accuracy. In this embodiment, the accuracy of the gradient boosting decision tree model on the test set is 0.9846. Preferably, in this embodiment, the fusion of the above models is also included to obtain the final stacking model. The stacking model uses a variety of basic classifiers, including BP neural network, LSTM model, GRU model, random forest classifier and gradient boosting classifier. The prediction results of each basic model on the training set and test set are used as new features to create a new data set. This data set contains the predicted values of all basic models for each sample, which is called "first layer prediction". Use the first layer predicted data set as input to train a new model, namely the "stacked model". Apply the stacked model to the test data set to obtain the final prediction results. In this embodiment, the results of the stacked model on the test set are: accuracy: 0.9998; average precision: 0.9998; average recall: 0.9998; average F1 score: 0.9998. The stacked model combines the advantages of multiple basic models, optimizes the prediction effect, and improves the overall performance of the model.
[0166] In summary, as shown in Table 5, Table 5 is a comparison of the indicators of each model provided in this embodiment. From the data in the table, it can be seen that each model obtained after training has excellent performance, and the stacked model obtained by the subsequent fusion of each model also has high prediction accuracy and reliability for the real-time prediction of highway tunnel traffic events.
[0167]
[0168]
[0169] Table 5
[0170] Further preferably, real-time prediction and display are also included in this embodiment. The front-end equipment collects real-time data of traffic volume x1, traffic saturation x2, proportion of large vehicles x3, average vehicle speed x4, hazardous chemicals vehicles on the way x5, and number of over-temperature vehicles x6. The fused stacking model can be used to make real-time predictions on the possibility of traffic incidents in each section of the tunnel and perform visual displays.
[0171] Obviously, the above embodiments of the present invention are merely examples for clearly illustrating the technical solution of the present invention, and are not intended to limit the specific implementation methods of the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the claims of the present invention shall be included in the protection scope of the claims of the present invention.
Claims
1. A real-time prediction system for highway traffic events, comprising: Data preparation module, used to collect data in real time and pre-process the data; Model design and training module, used to design and train several models using processed data; The model fusion module is used to fuse the trained models; the system deployment module is used to package the models and deploy them to the cloud service platform; The data preparation module, the model design and training module and the model fusion module are connected in sequence, and the model design and training module and the model fusion module are connected to the cloud server platform through the system deployment module respectively; the cloud server platform is connected to the data preparation module for transmitting the data to be predicted to the model of the cloud server platform for prediction, and is connected to the result display module for real-time display of the prediction results; It is characterized in that the model design and training module includes a BP model training unit, a LSTM model training unit, a GRU model training unit, a random forest model training unit and a gradient boosting decision tree training unit. Different hyperparameters are used for training in each training unit, and training is carried out batch by batch through a data loader. Finally, a validation set is used for performance evaluation.
2. A highway traffic incident real-time prediction system according to claim 1, characterized in that: The BP model training unit includes an input layer, a hidden layer and an output layer. First, the input data of the input layer is set to 13, and then the hidden layer is set to two layers, which is used to extract high-level features from the input data and abstractly combine them, and finally the prediction probability of each category is output through the output layer; at the same time, a cross entropy loss function component is set to optimize the prediction accuracy of the BP model, and an Adam optimizer component is set to adaptively adjust the learning rate to ensure the stability and efficiency of parameter updates; The LSTM model training unit introduces three gate mechanism components, namely, a forget gate, an input gate, and an output gate, which are used to control the flow of information so that information can be effectively retained or forgotten when processing long time series; the LSTM model also includes a back-propagation component for updating model parameters through a back-propagation algorithm; The GRU model training unit includes an input layer, a GRU layer and a fully connected layer, which are used to introduce a gating mechanism to control the flow of information; the GRU layer includes an update gate and a reset gate, which are used to determine the update of the hidden state; The random forest model training unit includes: a parameter initialization and data preparation component, which is used to initialize forest parameters and perform data preparation to generate input data; a decision tree construction and training component, which is used to select the optimal split point according to the characteristics of the input data to construct the structure of the decision tree and perform training; an integrated prediction component, which is used to perform independent prediction on each decision tree and obtain the final output by voting on the prediction results of all decision trees; The gradient boosting decision tree training unit includes an iterative optimization component for calculating the prediction residual of the current model and fitting the prediction residual with a new decision tree, thereby scaling the learning rate to optimize the model.
3. A highway traffic incident real-time prediction system according to claim 1, characterized in that: The model fusion module includes: A probability acquisition unit is used to obtain the predicted probability of the model output in each training unit in the model design and training module; The stacked feature construction unit is used to splice the prediction probabilities of each model into a new feature matrix and generate a feature matrix dataset; A stacking model building unit, used to integrate various models to generate a stacking model, and train it using a feature matrix data set; The stacked model building unit also includes a logistic regression classifier, which learns the prediction results of each model to generate a final prediction.
4. A highway traffic incident real-time prediction system according to claim 1, characterized in that: The data preparation module includes: A temporal feature extraction unit, used to convert event information into features that can be used by the model; Data cleaning and merging unit, used to remove invalid data and merge data by aligning different data sets by time using the merge_asof function; Result matching unit, used to integrate safety information into traffic data and integrate them into Excel files; The data balancing processing unit is used to balance the imbalance between traffic event data and normal data.
5. A highway traffic incident real-time prediction system according to claim 4, characterized in that: The time feature extraction unit includes: Data reading and format conversion component, used to read vehicle data files and convert time columns into datetime format; Function definition component, used to define event alignment function, aligning events to the next and previous full five minutes respectively, ensuring that all timestamps fall within the same five-minute interval; The data segmentation and data processing component is used to divide the data into multiple blocks using code and traverse each five-minute interval to extract the data subset within the time period, and calculate the data subset of each five-minute interval to form a complete time feature data set.
6. A highway traffic incident real-time prediction system according to claim 5, characterized in that: The data cleaning and merging unit includes: Data cleaning component, used to identify and process missing values, abnormal values, and duplicate values in the data imported from the data source, and to convert the data into different data types, perform spelling detection, and perform feature engineering on the data; The data merging component is used to align different data sets by time using the merge_asof function to ensure that each row of data contains all relevant information and merge the calculation results of all blocks.
7. A highway traffic incident real-time prediction system according to claim 6, characterized in that: The result matching unit includes: The safety level classification component is used to classify the situations corresponding to the traffic data recorded in the safety level information into three categories: 0, 1, and 2, which respectively correspond to normal situations, abnormal parking situations in highway tunnels, and traffic incidents in highway tunnels; The information fusion component is used to create a copy data frame, update the safety level corresponding to the successfully matched traffic records into the copy data frame, and integrate and export them into an Excel file.
8. A real-time prediction system for road or tunnel traffic events according to claim 7, characterized in that: The data balancing processing unit includes: The SMOTE component is used to generate new minority class samples by connecting minority class samples and their neighboring data in the feature space; A random downsampling component is used to reduce the number of majority class samples to balance the dataset.
9. A highway traffic incident real-time prediction system according to any one of claims 1-2, characterized in that: In each model training unit of the model design and training module, the K-fold validation method is used for cross-validation.
10. A highway traffic incident real-time prediction system according to any one of claims 1 to 8, characterized in that: The system deployment module includes: Model packaging component, used to package the trained model into a model file and upload it to the cloud server; The environment configuration component is used to create a cloud instance in the cloud server platform and install the corresponding dependencies and configure the operating environment, as well as write API services to access the model through the API to ensure that the model can normally receive requests and return prediction results; Monitoring and maintenance components are used to configure logging and monitoring to ensure service stability and performance.
Citation Information
Patent Citations
Smart city management method and system based on vehicle and road cloud collaboration
CN118736844A
Highway tunnel traffic accident prediction method based on convolutional neural network
CN118747954A