Accident prediction method and system fusing time mixing effect and machine learning
By using the WGAN-GP model to balance data and generate high-quality sampled data in traffic accident risk prediction, and training the T-MEXGB model with time mixed effects, the problem of class imbalance and insufficient data generation quality is solved, significantly improving the accuracy of real-time accident prediction.
Patent Information
- Application Number
- CN202411559065.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-04
- Publication Date
- 2025-03-28
- Estimated Expiration
- 2044-11-04
AI Technical Summary
The existing technology has class imbalance problems in traffic accident risk prediction, resulting in machine learning models performing well in predicting most classes but not in predicting fewer classes. At the same time, the complexity and negligence of deep convolutional generative adversarial networks in data formatting and sampling methods data generation quality affects the result accuracy of real-time accident prediction.
The WGAN-GP model is used for data balancing, high-quality sampled data is generated through gradient penalty function, and the real-time accident prediction model T-MEXGB is trained based on these data, integrating the time mixing effect to improve prediction accuracy.
Generating high-quality balanced data sets through the WGAN-GP model improves the accuracy of the real-time accident prediction model, solves the problem of class imbalance and insufficient data generation quality, and improves the accuracy of accident prediction.
Smart Images

Figure CN119719836A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of highway traffic safety assessment, and in particular to an accident prediction method and system integrating time mixing effect and machine learning. Background Art
[0002] The purpose of accident risk prediction is to study the intrinsic connection between traffic accidents and the operating characteristics of dynamic traffic flow, to scientifically estimate and predict the potential accident risks, and to propose systematic traffic safety management measures in terms of traffic organization, traffic control, and traffic guidance. Class imbalance is a serious problem in accident occurrence datasets, which refers to the fact that there are significantly more observations in one class than in another. This imbalance causes machine learning models to show higher accuracy in predicting the majority class, but poorer prediction performance in predicting the minority class.
[0003] Existing studies have shown that class balancing methods such as sampling methods and algorithmic methods are effective methods for dealing with class imbalance in traffic safety data. The synthetic minority method has been widely accepted, but artificial intelligence-based methods need further research. Existing studies have used deep convolutional generative adversarial networks for class balancing in real-time collision prediction research, but deep convolutional generative adversarial networks require data to be formatted into two-dimensional data sets, which adds complexity to the development of real-time accident prediction models. Although the Wasserstein generative adversarial network method overcomes this problem, current research ignores the quality of data generation by the sampling method and only studies its effectiveness in the prediction model, which affects the accuracy of the results of real-time accident prediction using the prediction model. Summary of the invention
[0004] The purpose of the present invention is to overcome the defects of the above-mentioned prior art and to provide an accident prediction method and system that integrates time mixing effect and machine learning.
[0005] The purpose of the present invention can be achieved by the following technical solutions:
[0006] According to a first aspect of the present invention, there is provided an accident prediction method integrating time mixing effect and machine learning, the method comprising:
[0007] Obtaining traffic status data and traffic accident data containing time categories, and dividing the traffic status data into accident data and non-accident data based on the traffic accident data, and using the accident data as a training data set for a data balancing model; the data balancing model is WGAN-GP;
[0008] Generate balanced accident data using the trained data balance model, integrate the accident data, balanced accident data and non-accident data to obtain a first data set, and pre-process the first data set as a training data set for a real-time accident prediction model; the real-time accident prediction model is T-MEXGB;
[0009] The traffic status data collected in real time is input into the trained real-time accident prediction model to output the accident prediction results.
[0010] As a preferred technical solution, the time categories include ordinary time periods on weekdays, peak time periods on weekdays, ordinary time periods on holidays, and peak time periods on holidays.
[0011] As a preferred technical solution, the method for dividing the accident data is:
[0012] Segment the road network into multiple scene segments based on the locations of traffic monitors;
[0013] Obtain traffic status data and traffic accident data for each scene section, wherein the traffic status data includes average vehicle speed, traffic flow, speed variance and vehicle mixing degree, and the type of traffic accident data is 01 data, that is, 1 is for an accident and 0 is for no accident;
[0014] Identify the time point and scene section information of the accident;
[0015] Acquire traffic status data of a corresponding scene road section within a first preset time before the time point of the accident, and use the traffic status data within the first preset time before the accident as first traffic status data;
[0016] Dividing the first traffic status data into a plurality of time slices according to a second preset time, and each time slice includes time category information;
[0017] Accident data are obtained based on the first traffic status data with time slices.
[0018] As a preferred technical solution, the method for dividing the non-accident data is:
[0019] Acquire traffic status data without an accident on a different date and with the same time point and scene road section information as the accident occurrence, select the traffic status data within a first preset time before the time point, and use the traffic status data within the first preset time before the time point as the second traffic data;
[0020] Dividing the second traffic status data into a plurality of time slices according to a second preset time, and each time slice includes time category information;
[0021] Non-accident data is obtained based on the second traffic status data with time slices.
[0022] As a preferred technical solution, the data balancing model includes a generator and a discriminator, and the training process includes:
[0023] After the accident data is standardized, it is used as a training data set for the data balance model, and the accident data is divided into a training set and a test set according to a first preset ratio, and a training cycle is set;
[0024] Randomly extract a batch of real accident data from the training set as the generator input and output a batch of forged accident data;
[0025] The real accident data and the fake accident data are input into the discriminator, the loss and gradient penalty terms are calculated by the inserted gradient penalty function and loss function, and the parameters of the discriminator and generator are updated using the gradient descent method, and the process is repeated until the maximum training cycle;
[0026] Use the test set to evaluate the performance of the data balancing model after updating the parameters, and select the data balancing model with the best performance.
[0027] As an optimal technical solution, in the trained data balancing model, the first layer input dimension of the generator is 100, and the output dimension is 256; the second layer input dimension is 256, and the output dimension is 512; the third layer input dimension is 512, and the output dimension is 1024; the fourth layer input dimension is 1024, and the output dimension is the dimension of the accident data; the activation functions of the first three layers are ReLU activation functions, and the last layer is Tanh activation function; the first layer input dimension of the discriminator is the dimension of the accident data, and the output dimension is 1024; the second layer input dimension is 1024, and the output dimension is 512; the third layer input dimension is 512, and the output dimension is 256; the fourth layer input dimension is 256, and the output dimension is 1; the activation functions are all LeakyReLU activation functions, and the negative slope is 0.2.
[0028] As a preferred technical solution, the method for obtaining the first data set is:
[0029] Generate balanced accident data using the trained data balancing model;
[0030] Integrating the balance accident data with the accident data to obtain mixed data;
[0031] The mixed data and the non-accident data are mixed according to a second preset ratio to obtain a first data set.
[0032] As a preferred technical solution, the real-time accident prediction model includes a classifier and a prediction result output module, and its training process includes:
[0033] Dividing the preprocessed first data set into a training set and a validation set according to a third preset ratio;
[0034] Initialize the parameters of the classifier and prediction result output module, use the training set to train the real-time accident prediction model, and use the hyperparameter grid search method to tune the parameters of the classifier and prediction result output module;
[0035] The validation set is used to verify the accuracy of the real-time accident prediction model after parameter tuning, and the parameters with the highest accuracy are selected as the final parameters of the real-time accident prediction model.
[0036] As a preferred technical solution, the step of outputting the accident prediction result is:
[0037] Input the real-time collected traffic status data into the trained classifier and output the classification results;
[0038] Based on the classification results, the linear mixed benefit method is used to estimate whether an accident will occur. The expression is:
[0039] y i =X i β+Z i u i +∈ i ,
[0040] Among them, y i Represents the accident prediction result, the type is binary data; X i is the fixed effect characteristic matrix of accidents; β represents the fixed effect coefficient of accidents; Z i Indicator indicating the time category; u i represents the random effect of the accident; ∈ i is the error term; i is the classification category.
[0041] According to a second aspect of the present invention, there is provided an accident prediction system integrating time mixing effects and machine learning, wherein the system is used to implement the above method.
[0042] Compared with the prior art, the present invention uses the WGAN-GP model for data balance. The gradient penalty function introduced by the WGAN-GP model solves the problems of gradient vanishing and parameter distribution extremity during training. It can generate high-quality sampling data and train the real-time prediction model based on the generated high-quality sampling data, so that the output results of the real-time prediction model when predicting accidents are more accurate. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1 A schematic diagram of the method flow chart of the present invention;
[0044] Figure 2 It is a schematic diagram of the framework of the method of the present invention;
[0045] Figure 3 A road section unit diagram based on accident data variables of the present invention;
[0046] Figure 4 Contribution diagram of traffic variables impact on accident prediction in the case area. DETAILED DESCRIPTION
[0047] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0048] Unless otherwise defined, the technical terms or scientific terms involved in this application should be understood by people with ordinary skills in the technical field to which this application belongs. The words "one", "a", "a", "the" and the like involved in this application do not indicate a quantitative limitation, and may represent the singular or plural. The terms "include", "comprise", "have" and any of their variations involved in this application are intended to cover non-exclusive inclusions; for example, a process, method, system, product or device that includes a series of steps or modules (units) is not limited to the listed steps or units, but may also include steps or units that are not listed, or may also include other steps or units inherent to these processes, methods, products or devices. The words "connect", "connected", "coupled" and the like involved in this application are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The "multiple" involved in this application refers to two or more. "And / or" describes the association relationship of associated objects, indicating that there may be three relationships, for example, "A and / or B" can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the objects before and after are in an "or" relationship. The terms "first", "second", "third", etc. involved in this application are only used to distinguish similar objects and do not represent a specific ordering of the objects.
[0049] This embodiment provides a real-time accident prediction method integrating time mixing effect and machine learning based on the traffic accident situation of Xi'an Ring Expressway. The flow chart is as follows: Figure 1 , the block diagram is as follows Figure 2 As shown, the following steps are included:
[0050] S1. Select the regional ring expressway scene, deploy a total of 16 groups of traffic flow monitoring devices consisting of camera bayonet cameras and speed radars, divide the road network into multiple scene sections according to the location of the traffic monitors, and indicate the section where the monitor detected the accident as the accident section, the section where the previous monitoring device closest to the accident section is located as the upstream section, and the section where the next monitoring device closest to the accident section is located as the downstream section. The schematic diagram is shown in the figure. Figure 3 shown.
[0051] S2. Obtain the training data set of the data balancing model and train the data balancing model:
[0052] S21. Select a sampling period of two months, and divide the sampling period into four time categories: normal working hours, peak working hours, normal holiday hours, and peak holiday hours;
[0053] S22. Collect traffic status data and traffic accident data of regional ring expressways within two months including time categories, divide the traffic status data into accident data and non-accident data, and use the accident data as the training data set of the data balance model, and the data balance model is the WGAN-GP model; wherein the detailed steps of obtaining the accident data are as follows:
[0054] A2. Obtain traffic status data and traffic accident data for each scene section, wherein the traffic status data includes average vehicle speed, traffic flow, speed variance and vehicle mixing degree, and the type of traffic accident data is 01 data, that is, 1 for an accident and 0 for no accident.
[0055] A3. Identify the time point and scene road section information of the accident.
[0056] A4. Obtain the traffic status data of the corresponding scene road section within 30 minutes before the time point of the accident, and use the traffic status data of this period as the first traffic status data.
[0057] A5. Divide the first traffic status data into 7 time slices at intervals of 5 minutes, and each time slice includes time category information.
[0058] A6. Obtain accident data based on the first traffic status data with time slices.
[0059] The detailed steps to obtain non-accident data are:
[0060] B1. Obtain traffic status data without an accident on a different date with the same time point and scene road section information as the accident occurrence, and select the traffic status data within a first preset time before the time point, and use the traffic status data within the first preset time before the time point as the second traffic data;
[0061] B2, dividing the first traffic state data into 7 time slices at intervals of 5 minutes, and each time slice includes time category information;
[0062] B3. Obtain non-accident data based on the second traffic status data with time slices.
[0063] S23, training the data balancing model based on the training data set, specifically including:
[0064] S231, standardize the accident data and use it as a training data set for the data balance model, and divide the accident data into a training set and a test set in a ratio of 8:2, and set the training cycle to 2000 and the learning rate to 0.0002;
[0065] S232, randomly extracting a batch of real accident data from the training set as input to the generator and outputting a batch of forged accident data;
[0066] S233, input the real accident data and the forged accident data into the discriminator, calculate the loss and gradient penalty terms by the inserted gradient penalty function and loss function, and use the gradient descent method to update the parameters of the discriminator and the generator, and repeat until the maximum training cycle, wherein the beta parameters b1 and b2 of the Adam optimizer are 0.5 and 0.999, and the gradient penalty coefficient lambda_gp is 10;
[0067] S234. Use the test set to evaluate the performance of the data balancing model after the parameters are updated, and select the data balancing model with the best performance.
[0068] Among them, the parameters of the optimal data balancing model are set as follows: the first layer input dimension of the generator is 100, and the output dimension is 256; the second layer input dimension is 256, and the output dimension is 512; the third layer input dimension is 512, and the output dimension is 1024; the fourth layer input dimension is 1024, and the output dimension is the dimension of the accident data; the activation functions of the first three layers are ReLU activation functions, and the last layer is Tanh activation function; the first layer input dimension of the discriminator is the dimension of the accident data, and the output dimension is 1024; the second layer input dimension is 1024, and the output dimension is 512; the third layer input dimension is 512, and the output dimension is 256; the fourth layer input dimension is 256, and the output dimension is 1; the activation functions are all LeakyReLU activation functions, and the negative slope is 0.2.
[0069] S3. Obtain the training data set of the real-time accident prediction model and train the real-time accident prediction model:
[0070] S31, using the trained data balancing model to generate balanced accident data, and integrating the balanced accident data with the accident data to obtain mixed data;
[0071] S32, mixing the mixed data and the non-accident data according to a ratio to obtain a first data set, wherein the ratio includes 1:1000, 1:500, 1:100, 1:50, 1:20, 1:10, 1:5, 1:4, 1:2 or 1:1;
[0072] After preprocessing, the first data set is used as a training data set for a real-time accident prediction model; and the real-time accident prediction model is T-MEXGB, including a classifier and a prediction result output module;
[0073] S33, using the training data set to train the real-time accident prediction model, specifically including the following steps:
[0074] S331, dividing the preprocessed first data set into a training set and a validation set in a ratio of 8:2;
[0075] S332, initializing classifier and prediction result output module parameters, using the training set to train the real-time accident prediction model, and using the hyperparameter grid search method to tune the classifier and prediction result output module parameters;
[0076] S333. Use the verification set to verify the accuracy of the real-time accident prediction model after parameter tuning, and select the parameters with the highest accuracy as the final parameters of the real-time accident prediction model.
[0077] S4. Input the real-time collected traffic status data into the real-time accident prediction model and output the accident prediction results:
[0078] S41, inputting the real-time collected traffic status data into the trained classifier and outputting the classification result;
[0079] S42. Based on the classification results, the linear mixed benefit method is used to estimate whether an accident will occur. The expression is:
[0080] y i =X i β+Z i u i +∈ i ,
[0081] Among them, y i Represents the accident prediction result, the type is binary data; X i is the fixed effect characteristic matrix of the accident; β represents the fixed effect coefficient of the accident; Z i Indicator indicating the time category; u i represents the random effect of the accident; ∈ i is the error term; i is the classification category.
[0082] The real-time accident prediction model provided in this embodiment can also be used to draw a SHAP dependency graph of various traffic state data to observe the influence of various traffic state data on the occurrence of accidents in the upstream section, the current section and the downstream section, wherein the calculation of the Shapley value is based on the following formula:
[0083]
[0084] Among them, φ i represents the Shapley value of traffic state data i, N represents the set of all traffic state data, S represents the feature subset that does not contain traffic state data i, and v(S) represents the model output that only contains the traffic state data subset S. The dependency graph is drawn as follows Figure 4 As shown, it can be seen that the speed of vehicles on the upstream section and the traffic flow on the downstream section are the main causes of traffic accidents.
[0085] This embodiment also provides an accident prediction system that integrates time mixing effects and machine learning to implement the above method.
[0086] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed by the present invention, and these modifications or replacements should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.
Claims
1. An accident prediction method integrating time mixing effect and machine learning, characterized in that: The method includes: Obtaining traffic status data and traffic accident data containing time categories, and dividing the traffic status data into accident data and non-accident data based on the traffic accident data, and using the accident data as a training data set for a data balancing model; the data balancing model is WGAN-GP; Generate balanced accident data using the trained data balance model, integrate the accident data, balanced accident data and non-accident data to obtain a first data set, and pre-process the first data set as a training data set for a real-time accident prediction model; the real-time accident prediction model is T-MEXGB; The traffic status data collected in real time is input into the trained real-time accident prediction model to output the accident prediction results.
2. The accident prediction method integrating time mixing effect and machine learning according to claim 1 is characterized in that: The time categories include normal working hours on weekdays, peak working hours on weekdays, normal working hours on holidays, and peak working hours on holidays.
3. The accident prediction method integrating time mixing effect and machine learning according to claim 1 is characterized in that: The method of dividing the accident data is: Segment the road network into multiple scene segments based on the locations of traffic monitors; Obtain traffic status data and traffic accident data for each scene section, wherein the traffic status data includes average vehicle speed, traffic flow, speed variance and vehicle mixing degree, and the type of traffic accident data is 01 data, that is, 1 is for an accident and 0 is for no accident; Identify the time point and scene section information of the accident; Acquire traffic status data of a corresponding scene road section within a first preset time before the time point of the accident, and use the traffic status data within the first preset time before the accident as first traffic status data; Dividing the first traffic state data into a plurality of time slices according to a second preset time, and each time slice includes time category information; Accident data are obtained based on the first traffic status data with time slices.
4. The accident prediction method integrating time mixing effect and machine learning according to claim 3 is characterized in that: The method of dividing the non-accident data is: Acquire traffic status data without an accident on a different date and with the same time point and scene road section information as the accident occurrence, select the traffic status data within a first preset time before the time point, and use the traffic status data within the first preset time before the time point as the second traffic data; Dividing the second traffic status data into a plurality of time slices according to a second preset time, and each time slice includes time category information; Non-accident data is obtained based on the second traffic status data with time slices.
5. The accident prediction method integrating time mixing effect and machine learning according to claim 1 is characterized in that: The data balancing model includes a generator and a discriminator, and the training process includes: After the accident data is standardized, it is used as a training data set for the data balance model, and the accident data is divided into a training set and a test set according to a first preset ratio, and a training cycle is set; Randomly extract a batch of real accident data from the training set as the generator input and output a batch of forged accident data; The real accident data and the fake accident data are input into the discriminator, the loss and gradient penalty terms are calculated by the inserted gradient penalty function and loss function, and the parameters of the discriminator and generator are updated using the gradient descent method, and the process is repeated until the maximum training cycle; Use the test set to evaluate the performance of the data balancing model after updating the parameters, and select the data balancing model with the best performance.
6. The accident prediction method integrating time mixing effect and machine learning according to claim 5 is characterized in that: In the trained data balancing model, the first layer of the generator has an input dimension of 100 and an output dimension of 256; the second layer has an input dimension of 256 and an output dimension of 512; the third layer has an input dimension of 512 and an output dimension of 1024; the fourth layer has an input dimension of 1024 and an output dimension of the accident data; the activation functions of the first three layers are ReLU activation functions, and the last layer is Tanh activation function; The first layer input dimension of the discriminator is the dimension of the accident data, and the output dimension is 1024; the second layer input dimension is 1024, and the output dimension is 512; the third layer input dimension is 512, and the output dimension is 256; the fourth layer input dimension is 256, and the output dimension is 1; the activation function is the LeakyReLU activation function, and the negative slope is 0.
2.
7. The accident prediction method integrating time mixing effect and machine learning according to claim 1 is characterized in that: The method for obtaining the first data set is: Generate balanced accident data using the trained data balancing model; Integrating the balance accident data with the accident data to obtain mixed data; The mixed data and the non-accident data are mixed according to a second preset ratio to obtain a first data set.
8. The accident prediction method integrating time mixing effect and machine learning according to claim 1 is characterized in that: The real-time accident prediction model includes a classifier and a prediction result output module, and its training process includes: Dividing the preprocessed first data set into a training set and a validation set according to a third preset ratio; Initialize the parameters of the classifier and prediction result output module, use the training set to train the real-time accident prediction model, and use the hyperparameter grid search method to tune the parameters of the classifier and prediction result output module; The validation set is used to verify the accuracy of the real-time accident prediction model after parameter tuning, and the parameters with the highest accuracy are selected as the final parameters of the real-time accident prediction model.
9. The accident prediction method integrating time mixing effect and machine learning according to claim 8, characterized in that: The steps of outputting the accident prediction results are: Input the real-time collected traffic status data into the trained classifier and output the classification results; Based on the classification results, the linear mixed benefit method is used to estimate whether an accident will occur. The expression is: y i =X i β+Z i u i +∈ i , Among them, y i Represents the accident prediction result, the type is binary data; X i is the fixed effect characteristic matrix of accidents; β represents the fixed effect coefficient of the accident; Z i Indicator indicating the time category; u i represents the random effect of the accident; ∈ i is the error term; i is the classification category.
10. An accident prediction system integrating time mixing effect and machine learning, characterized in that: The system is used to implement the method described in any one of claims 1 to 9.
Citation Information
Patent Citations
Deep learning based urban expressway accident prediction method
CN108198415A
Expressway real-time traffic accident risk assessment method based on deep learning
CN112562337A
Bearing fault diagnosis method based on improved WGAN-GP and Alxnet
CN115962946A
Fine-grained traffic state estimation method based on ETC portal data
CN117392845A
Traffic accident severity prediction method and system and computer equipment
CN117829370A