An accident prediction method and system fusing time mixing effect and machine learning
By generating high-quality sampled data using the WGAN-GP model and combining it with the T-MEXGB model, the problem of class imbalance in traffic safety data was solved, improving the accuracy of real-time accident prediction, especially in predicting minority classes.
Patent Information
- Application Number
- CN202411559065.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-04
- Publication Date
- 2026-02-27
- Estimated Expiration
- 2044-11-04
AI Technical Summary
Existing technologies struggle to address the imbalance problem in traffic safety data. Machine learning models perform poorly in predicting the minority class, and the complexity of data formatting and the insufficient quality of sampling methods in deep convolutional generative adversarial networks affect the accuracy of real-time accident prediction.
The WGAN-GP model is used for data balancing to generate high-quality sampled data, and combined with the T-MEXGB model for real-time accident prediction. By using a fusion method of temporal mixture effects and machine learning, a dataset is generated and trained to improve prediction accuracy.
The high-quality sampling data generated by the WGAN-GP model improves the accuracy of real-time accident prediction models, solves the class imbalance problem, and improves the performance of predicting minority classes.
Smart Images

Figure CN119719836B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of expressway traffic safety evaluation, and in particular to an accident prediction method and system fusing time mixing effect and machine learning. BACKGROUND
[0002] The purpose of accident risk prediction is to study the internal relationship between traffic accidents and dynamic traffic flow operation characteristics, scientifically estimate and predict potential accident risks, and thus put forward systematic traffic safety management measures in terms of traffic organization, traffic control, traffic guidance, etc. Class imbalance is a serious problem in accident occurrence data sets, which means that the observation data of one class is significantly more than that of another class. This imbalance leads to machine learning models showing higher accuracy in predicting the majority class and 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 handling class imbalance in traffic safety data. Synthetic minority methods have been widely accepted, but artificial intelligence-based methods need further research. Existing studies use deep convolutional generative adversarial networks for class balancing in real-time collision prediction research, but deep convolutional generative adversarial networks need to format data into two-dimensional data sets, adding 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 generated by sampling methods and only studies their effectiveness in prediction models, which affects the accuracy of real-time accident prediction using prediction models. SUMMARY
[0004] The present application relates to the field of expressway traffic safety evaluation, and in particular to an accident prediction method and system fusing time mixing effect and machine learning.
[0005] The object of the present application can be achieved by the following technical solutions:
[0006] According to a first aspect of the present application, there is provided an accident prediction method fusing time mixing effect and machine learning, the method comprising:
[0007] acquiring traffic state data and traffic accident data containing time categories, and dividing the traffic state data into accident data and non-accident data based on the traffic accident data, taking the accident data as a training data set of a data balancing model; the data balancing model is a WGAN-GP;
[0008] The balanced accident data is generated by using the trained data balancing model, the accident data, the balanced accident data and the non-accident data are integrated to obtain a first data set, and the first data set is preprocessed and used as a training data set of a real-time accident prediction model; the real-time accident prediction model is a T-MEXGB;
[0009] The real-time traffic state data is input into the trained real-time accident prediction model, and an accident prediction result is output.
[0010] As a preferred technical solution, the time categories include a weekday ordinary time period, a weekday peak time period, a holiday ordinary time period and a holiday peak time period.
[0011] As a preferred technical solution, the method for dividing the accident data is as follows:
[0012] The road network is divided into multiple scene road segments based on the positions of traffic monitors;
[0013] Traffic state data and traffic accident data of each scene road segment are acquired, the traffic state data includes vehicle average speed, traffic flow, speed variance and vehicle mix degree, and the traffic accident data is 01 data, i.e., 1 for accident and 0 for non-accident;
[0014] The time point and scene road segment information of accident occurrence are identified;
[0015] Traffic state data of the corresponding scene road segment within a first preset time before the time point of accident occurrence is acquired, and the traffic state data within the first preset time before the time point of accident occurrence is used as first traffic state data;
[0016] The first traffic state data is divided into multiple time slices according to a second preset time, and each time slice includes time category information;
[0017] The accident data is obtained based on the first traffic state data with time slices.
[0018] As a preferred technical solution, the method for dividing the non-accident data is as follows:
[0019] Traffic state data of the same time point and scene road segment information but on different dates and without accident occurrence is acquired, and traffic state data within a first preset time before the time point is selected, and the traffic state data within the first preset time before the time point is used as second traffic data;
[0020] The second traffic state data is divided into multiple time slices according to a second preset time, and each time slice includes time category information;
[0021] The non-accident data is obtained based on the second traffic state data with time slicing.
[0022] As a preferred technical solution, the data balancing model comprises a generator and a discriminator, and the training process comprises:
[0023] The accident data is standardized and used as a training data set of the data balancing model, and the accident data is divided into a training set and a test set according to a first preset ratio, and a training period is set;
[0024] A batch of real accident data in the training set is randomly extracted as input of the generator, and a batch of fake accident data is output;
[0025] The real accident data and the fake accident data are input into the discriminator, the loss and the gradient penalty term are calculated by the inserted gradient penalty function and the loss function, and the parameters of the discriminator and the generator are updated using the gradient descent method, and the process is repeated until the maximum training period;
[0026] The data balancing model with updated parameters is evaluated in performance using the test set, and the data balancing model with optimal performance is selected.
[0027] As a preferred technical solution, 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 dimension of the accident data; the activation function of the first three layers is ReLU activation function, and the activation function of the last layer is Tanh activation function; the first layer of the discriminator has an input dimension of the dimension of the accident data and an output dimension of 1024; the second layer has an input dimension of 1024 and an output dimension of 512; the third layer has an input dimension of 512 and an output dimension of 256; the fourth layer has an input dimension of 256 and an output dimension of 1; and the activation function is LeakyReLU activation function with a negative slope of 0.2.
[0028] As a preferred technical solution, the method for obtaining the first data set comprises:
[0029] Balanced accident data is generated using the trained data balancing model;
[0030] The balanced accident data and the accident data are integrated to obtain mixed data.
[0031] The mixed data and the non-accident data are mixed according to a second preset ratio to obtain the first data set.
[0032] As a preferred technical solution, the real-time accident prediction model comprises a classifier and a prediction result output module, and the training process comprises:
[0033] The preprocessed first dataset is divided into a training set and a validation set according to a third preset ratio;
[0034] Initialize the parameters of the classifier and prediction output module, train the real-time accident prediction model using the training set, and fine-tune the parameters of the classifier and prediction output module using the hyperparameter grid search method.
[0035] The accuracy of the real-time accident prediction model after parameter tuning was verified using a validation set, and the parameters with the highest accuracy were 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 as follows:
[0037] The real-time traffic status data is input into the trained classifier, and the classification result is output.
[0038] Based on the classification results, a linear mixed benefit method is used to predict whether an accident will occur. The expression is:
[0039] y i =X i β+Z i u i +∈ i ,
[0040] Among them, y i This represents the accident prediction result, and the data type is binary classification; X i Z represents the fixed effects characteristic matrix of the accident; β represents the fixed effects coefficient of the accident; i Indicator representing time category; u i Represents the random effects of an accident; ∈ i is the error term; i is the classification category.
[0041] According to a second aspect of the present invention, an accident prediction system that integrates temporal mixing effects and machine learning is provided, the system being used to implement the above-described method.
[0042] Compared with existing technologies, this invention uses the WGAN-GP model for data balancing. The gradient penalty function introduced by the WGAN-GP model solves the problems of gradient vanishing and parameter distribution extremism during training, generating high-quality sampling data. The real-time prediction model is trained based on the generated high-quality sampling data, making the output results of the real-time prediction model more accurate when predicting accidents. Attached Figure Description
[0043] Figure 1 This is a schematic diagram of the method flow of this invention application;
[0044] Figure 2 A schematic diagram of the framework of the method of the present application;
[0045] Figure 3 A link unit graph based on accident data variables of the present application;
[0046] Figure 4 A case area accident occurrence prediction traffic variable influence contribution graph. DETAILED DESCRIPTION
[0047] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor should fall within the scope of protection of the present application.
[0048] Unless otherwise defined, technical terms or scientific terms used in the present application should be understood as the common meanings thereof by those skilled in the art. The terms "one", "a", "an", "the", and similar terms in the present application do not represent quantity limitation, but can represent singular or plural. The terms "include", "contain", "have", and any variations thereof in the present application are intended to cover non-exclusive inclusion; for example, a process, method, system, product or device including a series of steps or modules (units) is not limited to the listed steps or units, but can further include steps or units not listed, or can further include other steps or units inherent to the process, method, product or device. The terms "connect", "connected", "couple" and similar terms in the present application are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect. The term "multiple" in the present application refers to two or more. The term "and / or" describes the association relationship between the associated objects, which means that there can be three relationships, for example, "A and / or B" can mean that A exists alone, A and B exist together, and B exists alone. The character " / " generally represents an "or" relationship between the associated objects. The terms "first", "second", "third" and the like in the present application are only to distinguish similar objects, and do not represent a specific order of the objects.
[0049] The present embodiment takes the traffic accident situation of Xi'an Ring Expressway as an example to provide a real-time accident prediction method combining time mixing effect and machine learning, the flowchart of which is Figure 1 , the block diagram is shown in Figure 2 , which includes the following steps:
[0050] S1, select the regional around the city highway scene, a total of 16 groups of traffic flow monitoring devices composed of a nose camera and a speed radar are arranged, the road network is divided into multiple scene sections according to the positions of the traffic monitors, the monitor section where the accident occurs is represented as the accident section, the section where the previous monitoring device closest to the accident section is represented as the upstream section, and the section where the next monitoring device closest to the accident section is represented as the downstream section, and a schematic diagram is shown in Figure 3
[0051] S2, obtain the training data set of the data balancing model and train the data balancing model:
[0052] S21, select the sampling time as two months, and divide the sampling time into four time categories according to the ordinary time period of weekdays, the peak time period of weekdays, the ordinary time period of holidays and the peak time period of holidays;
[0053] S22, collect the traffic state data and traffic accident data of the regional around the city highway within two months containing time categories, divide the traffic state data into accident data and non-accident data, take the accident data as the training data set of the data balancing model, and the data balancing model is a WGAN-GP model; wherein the detailed steps of obtaining the accident data are:
[0054] A2, obtain the traffic state data and traffic accident data of each scene section, wherein the traffic state data includes vehicle average speed, traffic flow, speed variance and vehicle mixing degree, and the type of traffic accident data is 01 data, i.e. accident occurs as 1 and non-accident as 0.
[0055] A3, identify the time point and scene section information of the accident occurrence.
[0056] A4, obtain the traffic state data of the corresponding scene section within 30 minutes before the time point of the accident occurrence, and take the traffic state data of the period as the first traffic state data.
[0057] A5, divide the first traffic state data into 7 time slices with an interval of 5 minutes, and each time slice includes time category information.
[0058] A6, obtain the accident data based on the first traffic state data with time slices.
[0059] The detailed steps of obtaining the non-accident data are:
[0060] B1, obtain the traffic state data of the same time point and scene section information as the accident occurrence, but on different dates, select the traffic state data within the first preset time before the time point, and take the traffic state 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 with 5 minutes interval, and each time slice includes time category information;
[0062] B3, obtaining non-accident data based on the second traffic state data with time slices.
[0063] S23, training the data balancing model based on the training data set, specifically including:
[0064] S231, after standardizing the accident data, taking the accident data as the training data set of the data balancing model, dividing the accident data into a training set and a test set according to a ratio of 8:2, setting a training period as 2000, and setting a learning rate as 0.0002;
[0065] S232, randomly extracting a batch of real accident data in the training set as a generator input and outputting a batch of fake accident data;
[0066] S233, inputting the real accident data and the fake accident data into a discriminator, calculating a loss and a gradient penalty term by a gradient penalty function and a loss function, and updating parameters of the discriminator and the generator by using a gradient descent method, and repeating until a maximum training period, wherein a beta parameter b1 of an Adam optimizer is 0.5, a beta parameter b2 is 0.999, and a gradient penalty coefficient lambda_gp is 10;
[0067] S234, evaluating the performance of the data balancing model with updated parameters by using the test set, and selecting a data balancing model with optimal performance.
[0068] The parameter settings of the optimal data balancing model are as follows: the input dimension of the first layer of the generator is 100, the output dimension is 256; the input dimension of the second layer is 256, the output dimension is 512; the input dimension of the third layer is 512, the output dimension is 1024; the input dimension of the fourth layer is 1024, the output dimension is the dimension of the accident data; the activation function of the first three layers is ReLU activation function, and the activation function of the last layer is Tanh activation function; the input dimension of the first layer of the discriminator is the dimension of the accident data, the output dimension is 1024; the input dimension of the second layer is 1024, the output dimension is 512; the input dimension of the third layer is 512, the output dimension is 256; the input dimension of the fourth layer is 256, the output dimension is 1; the activation function is LeakyReLU activation function, and the negative slope is 0.2.
[0069] S3, obtaining a training data set of a real-time accident prediction model and training the real-time accident prediction model:
[0070] S31, generating balanced accident data by using the trained data balancing model, and integrating the balanced accident data and the accident data to obtain mixed data;
[0071] S32. Mix the mixed data and non-accident data according to a ratio to obtain the first dataset, 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] The first dataset was preprocessed and used as the training dataset for the real-time accident prediction model; and the real-time accident prediction model was T-MEXGB, which included a classifier and a prediction result output module.
[0073] S33. Train a real-time accident prediction model using the training dataset, specifically including the following steps:
[0074] S331. Divide the preprocessed first dataset into a training set and a validation set in an 8:2 ratio.
[0075] S332. Initialize the parameters of the classifier and prediction result output module, train the real-time accident prediction model using the training set, and fine-tune the parameters of the classifier and prediction result output module using the hyperparameter grid search method.
[0076] S333. Use the validation set to verify the accuracy of the real-time accident prediction model after parameter tuning, and select the parameter with the highest accuracy as the final parameter of the real-time accident prediction model.
[0077] S4. Input the real-time traffic condition data into the real-time accident prediction model and output the accident prediction results:
[0078] S41. Input the real-time traffic status data into the trained classifier and output the classification result;
[0079] S42. Based on the classification results, the linear mixed benefit method is used to predict whether an accident will occur. The expression is:
[0080] y i =X i β+Z i u i +∈ i ,
[0081] Among them, y i This represents the accident prediction result, and the data type is binary classification; X i Z represents the fixed effects characteristic matrix of the accident; β represents the fixed effects coefficient of the accident; i Indicator representing time category; u i Represents the random effects of an accident; ∈ i is the error term; i is the classification category.
[0082] The real-time accident prediction model provided in the embodiment can also be used to draw a SHAP dependence graph of each traffic state data, for observing the influence degree of each type of traffic state data in the upstream road section, the current road section and the downstream road section on the occurrence of the accident, wherein the calculation of the Shapley value is based on the following formula:
[0083]
[0084] wherein φ i represents the Shapley value of the traffic state data i, N represents the set of all traffic state data, S represents a feature subset not containing the traffic state data i, and v(S) represents the model output containing only the traffic state data subset S. The dependence graph drawn is shown in Figure 4 It can be seen from the dependence graph that the speed of the vehicle in the upstream road section and the traffic flow in the downstream road section are the main causes of the traffic accident.
[0085] The embodiment also provides an accident prediction system fusing the time mixing effect and machine learning, for implementing the above method.
[0086] The above merely provides a specific embodiment of the present application, but the protection scope of the present application is not limited to this. Any person skilled in the art can easily think of various equivalent modifications or replacements within the technical range disclosed in the present application, and these modifications or replacements should be covered in the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.
Claims
1. An accident prediction method integrating temporal mixture effects and machine learning, characterized in that, The method includes: Traffic state data and traffic accident data containing time categories are acquired, and traffic state data are divided into accident data and non-accident data based on traffic accident data. Accident data is used as the training dataset for a data balancing model; the data balancing model is WGAN-GP. The performance of the updated data balancing model was evaluated using a test set, and the data balancing model with the best performance was selected. Balanced accident data is generated using a trained data balancing model. Accident data, balanced accident data, and non-accident data are integrated to obtain a first dataset. After preprocessing, the first dataset is used as the training dataset for a real-time accident prediction model. The real-time accident prediction model is T-MEXGB. The real-time traffic condition data is input into the trained real-time accident prediction model, and the accident prediction results are output. 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 the training dataset for the data balancing model. The accident data is divided into a training set and a test set according to a first preset ratio, and a training period is set. A batch of real accident data is randomly selected from the training set as input to the generator, which then outputs a batch of fake accident data. The generator's first layer 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; and the fourth layer has an input dimension of 1024 and an output dimension equal to the dimension of the accident data. The first three layers use the ReLU activation function, and the last layer uses the Tanh activation function. Real and fabricated accident data are input into the discriminator. The loss and gradient penalty terms are calculated using the inserted gradient penalty function and loss function. The parameters of the discriminator and generator are updated using gradient descent. This process is repeated until the maximum training epoch is reached. The first layer of the discriminator has the same input dimension as the accident data and an output dimension of 1024. The second layer has the same input dimension of 1024 and an output dimension of 512. The third layer has the same input dimension of 512 and an output dimension of 256. The fourth layer has the same input dimension of 256 and an output dimension of 1. The activation function for all layers is LeakyReLU with a negative slope of 0.
2.
2. The accident prediction method according to claim 1, which integrates temporal mixture effects and machine learning, is characterized in that... The time categories include weekday normal hours, weekday peak hours, holiday normal hours, and holiday peak hours.
3. The accident prediction method according to claim 1, which integrates temporal mixture effects and machine learning, is characterized in that... The method for dividing the aforementioned accident data is as follows: The road network is segmented into multiple scene segments based on the location of traffic monitors; Acquire traffic status data and traffic accident data for various road segments. The traffic status data includes average vehicle speed, traffic flow, speed variance, and vehicle mixing degree. The traffic accident data is 01 data, i.e., 1 represents an accident and 0 represents no accident. Identify the time and location of the accident; Obtain traffic status data of the corresponding road segment within a first preset time period before the time of the accident, and use the traffic status data within the first preset time period before the accident as the first traffic status data. The first traffic status data is divided into multiple time slices according to the second preset time, and each time slice includes time category information; Accident data is obtained based on the first traffic state data with time slices.
4. The accident prediction method according to claim 3, which integrates temporal mixture effects and machine learning, is characterized in that... The method for dividing the aforementioned non-accident data is as follows: Obtain traffic status data that is the same as the time and location of the accident but on a different date, and that has not been involved in the accident. Select the traffic status data within a first preset time period before the time point and use the traffic status data within the first preset time period before the time point as the second traffic data. The second traffic status data is divided into multiple time slices according to the second preset time, and each time slice includes time category information. Non-accident data is obtained based on second traffic state data with time slices.
5. The accident prediction method according to claim 1, which integrates temporal mixture effects and machine learning, is characterized in that... The method for obtaining the first dataset is as follows: Generate equilibrium accident data using a trained data balancing model; The balanced accident data and accident data are integrated to obtain hybrid data; The mixed data and non-accident data are mixed according to a second preset ratio to obtain the first dataset.
6. The accident prediction method according to claim 1, which integrates temporal mixture effects and machine learning, is characterized in that... The real-time accident prediction model includes a classifier and a prediction result output module, and its training process includes: The preprocessed first dataset is divided into a training set and a validation set according to a third preset ratio; Initialize the parameters of the classifier and prediction output module, train the real-time accident prediction model using the training set, and fine-tune the parameters of the classifier and prediction output module using the hyperparameter grid search method. The accuracy of the real-time accident prediction model after parameter tuning was verified using a validation set, and the parameters with the highest accuracy were selected as the final parameters of the real-time accident prediction model.
7. The accident prediction method according to claim 6, which integrates temporal mixture effects and machine learning, is characterized in that... The steps for outputting the accident prediction results are as follows: The real-time traffic status data is input into the trained classifier, and the classification result is output. Based on the classification results, a linear mixed benefit method is used to predict whether an accident will occur. The expression is: , in, This represents the accident prediction results, and the data type is binary classification. This is the fixed effects feature matrix for the occurrence of the accident; The fixed effects coefficient representing the occurrence of the accident; Indicator representing time category; Indicates the random effects that cause an accident; This is the error term; i For classification categories.
8. An accident prediction system integrating temporal mixture effects and machine learning, characterized in that, The system is used to implement the method described in any one of claims 1-7.
Citation Information
Patent Citations
Bearing fault diagnosis method based on improved WGAN-GP and Alxnet
CN115962946A
Traffic accident severity prediction method and system and computer equipment
CN117829370A