A traffic accident severity prediction method and system based on joint modeling of BERT and TabTransformer

By using a joint modeling approach combining BERT and TabTransformer, the structured and unstructured features of traffic accidents are extracted and fused, addressing the issues of insufficient utilization of textual information and class imbalance in existing technologies. This results in more accurate and generalized predictions of traffic accident severity.

CN122153774APending Publication Date: 2026-06-05HENAN UNIVERSITY

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
HENAN UNIVERSITY
Filing Date
2026-02-11
Publication Date
2026-06-05

AI Technical Summary

Technical Problem

Existing methods for predicting the severity of traffic accidents mainly rely on structured data, failing to fully utilize unstructured text information. Furthermore, they suffer from limitations in prediction accuracy and generalization ability in multi-source heterogeneous feature fusion and class imbalance handling.

Method used

By employing joint modeling with BERT and TabTransformer, key structural features of the accident and semantic features of the text are extracted, and gating modulation and deep fusion are performed. Combined with synthetic minority class oversampling and tomek linking to handle class imbalance, an accident severity prediction model is constructed.

Benefits of technology

It improves the accuracy and generalization ability of accident severity prediction, alleviates the class imbalance problem, enhances the interpretability of prediction results, and provides reliable technical support for traffic safety management.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure FT_1
    Figure FT_1
  • Figure FT_2
    Figure FT_2
  • Figure FT_3
    Figure FT_3
Patent Text Reader

Abstract

The application relates to a traffic accident severity prediction method and system based on BERT and TabTransformer joint modeling, which comprises the following steps: acquiring an original traffic accident data set, extracting accident key structured features and accident text semantic features from the original traffic accident data set; then acquiring text continuity feature units and basic structured feature units, and performing gate modulation processing on the corresponding basic structured feature units under the condition of each text continuity feature unit; subsequently, constructing a unified feature unit sequence and constructing a prediction model between accident features and accident severity categories through a machine learning process to perform accident severity prediction. The prediction method can fully mine the behavior information and environmental information contained in the accident text, and the principal component analysis method is used to improve the feature processing efficiency. The prediction method is significantly better than traditional machine learning models and deep learning models in terms of accuracy, recall rate and other key indicators, and has stable and superior prediction performance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of traffic safety and intelligent transportation data analysis technology, and in particular to a method and system for predicting the severity of traffic accidents based on joint modeling of BERT and TabTransformer. Background Technology

[0002] Traffic accidents are a significant factor affecting public safety and socio-economic development. With the increasing complexity of transportation systems, the frequency and scope of traffic accidents are expanding. Rapid and accurate prediction of accident severity is crucial for emergency response and dispatch, traffic control decisions, and accident risk prevention. Furthermore, with improvements in traffic information collection and management, accident data increasingly includes a large amount of unstructured text information, such as accident reports and police records. This type of text typically provides detailed descriptions of the accident process, driving behavior, collision methods, and related environmental factors, containing rich contextual semantic information and potential causal relationships.

[0003] In current technologies, traffic accident severity prediction widely employs data-driven methods. While some progress has been made in traffic accident prediction, several limitations remain when processing multi-source heterogeneous accident data. First, existing methods primarily rely on structured data features such as accident time, road conditions, weather conditions, and vehicle attributes, combined with traditional machine learning or deep learning models for modeling and analysis. However, these methods fail to fully exploit the deep semantic information contained in unstructured text such as accident descriptions, leading to the loss of key details and limiting further improvements in prediction accuracy. Second, current mainstream fusion methods, when dealing with the interaction between text semantic vectors and tabular features, employ relatively simplistic modeling approaches, making it difficult to capture the complex nonlinear relationships between heterogeneous features. In other words, while these methods can characterize the relationship between accident features and severity to some extent, their ability to express the complex causes of accidents remains limited. Furthermore, traffic accident data generally suffers from severe class imbalance (e.g., the number of fatal accidents is far less than that of minor accidents). Traditional models, lacking targeted sampling strategies, are prone to prediction bias, resulting in insufficient ability to identify severe accidents and impacting their generalization performance in actual traffic management.

[0004] It is evident that, in existing technologies, although accident data contains a large amount of unstructured textual information with rich contextual semantic information and potential causal relationships, this information is often ignored or only shallow feature extraction is performed, failing to be effectively integrated with structured features, which limits the accuracy of accident severity prediction and the generalization ability of the model. Summary of the Invention

[0005] To address the limitations of existing traffic accident severity prediction methods, which mainly rely on structured data and make insufficient use of textual information such as accident descriptions, and which suffer from limited prediction accuracy and generalization ability in multi-source heterogeneous feature fusion and class imbalance handling, this invention provides a traffic accident severity prediction method based on joint modeling of BERT and TabTransformer.

[0006] On the one hand, according to the design scheme provided by this invention, a method for predicting the severity of traffic accidents based on joint modeling of BERT and TabTransformer is provided, including the following:

[0007] Step 1: Obtain the original traffic accident dataset, process the original traffic accident dataset, and extract the key structured features and semantic features of the accident text. The original traffic accident dataset also contains accident severity category labels.

[0008] Step 2: The semantic features of the accident text are quantified into multiple text continuity feature units, and the key structured features of the accident are constructed into multiple basic structured feature units. The corresponding basic structured feature units are subjected to gated modulation processing based on each text continuity feature unit to obtain the modulated structured feature units.

[0009] Step 3: Construct a unified feature unit sequence by combining the text continuity feature units and the modulated structured feature units. Based on the unified feature unit sequence, construct a prediction model between accident features and accident severity categories through a machine learning process.

[0010] Step 4: Obtain the data to be predicted, and use the prediction model to obtain the prediction result of the accident severity of the data to be predicted.

[0011] Further, step 1 specifically includes:

[0012] The original traffic accident dataset is divided into structured accident data and accident text description data.

[0013] Accident structured features are extracted from the structured accident data, and the importance of these features is evaluated using a random forest algorithm. Key accident structured features are then extracted from the evaluated accident structured features.

[0014] The accident text description data is cleaned, and the cleaned accident text description data is serialized into a text sequence. The semantic features of the accident text are extracted from the text sequence.

[0015] Specifically, extracting structured accident features from the structured accident data includes:

[0016] The structured accident data is cleaned, and the structured accident features are extracted from the cleaned structured accident data.

[0017] The data cleaning process includes:

[0018] For missing values ​​in the structured accident data, the mean or median is used to fill in the missing values.

[0019] Outlier data in the structured accident data are identified and removed through statistical distribution analysis or threshold determination methods.

[0020] Specifically, extracting accident text semantic features from the text sequence includes:

[0021] The text sequence is processed by the multi-layer Transformer encoder of the BERT model to extract the initial text semantic features. Then, the initial text semantic features are reduced in dimensionality using the principal component analysis method. Finally, the reduced initial text semantic features are standardized to obtain the accident text semantic features.

[0022] Furthermore, step 2 also includes:

[0023] Statistical analysis was performed on the severity category labels to obtain a set of accident severity category labels;

[0024] The minority class samples in the accident severity category label set are expanded by synthetic minority class oversampling technology, and the noise introduced during the expansion process is cleaned up by tomek linking, so as to construct a training sample set with balanced accident severity categories. Feature units are obtained by using the key structured features of accidents and the semantic features of accident text in the training sample set.

[0025] Furthermore, the semantic features of the accident texts in the training sample set are numerically converted into text continuity feature units, specifically including:

[0026] Each semantic vector in the semantic features of the accident text is subjected to a learnable mapping to obtain each text continuity feature unit. :

[0027]

[0028] in, For learning parameters, For the first semantic vector of a sample It is a non-linear activation function. To unify the dimension of feature units.

[0029] Furthermore, the key structured features of the accident are constructed into basic structured feature units, specifically including:

[0030] The key structured features of the accident are divided into categorical features and continuous features. Categorical feature units and continuous feature units are constructed from the categorical features and continuous features respectively. The categorical feature units and continuous feature units are then unified into basic structured feature units.

[0031] The category-type feature unit Represented as:

[0032] ,

[0033] in, Indicates the first The j-th categorical feature of the sample, To unify the dimension of feature units;

[0034] The continuous feature unit Represented as:

[0035]

[0036] in, Indicates the first The j-th continuous feature of the sample, It is a non-linear activation function. These are learnable parameters.

[0037] Furthermore, each text continuity feature unit and its corresponding basic structured feature unit undergo gating modulation processing, specifically including:

[0038] Gating coefficients are generated using each text continuity feature unit as a condition and the corresponding basic structured feature unit. :

[0039]

[0040] in, For the first Text continuity feature units of the sample For the first The p-th basic structured feature unit of the sample, This represents element-wise multiplication. For the Sigmoid function, , For learnable parameters, To unify the dimension of feature units;

[0041] Using each of the aforementioned gating coefficients, combined with the corresponding text continuity feature units and basic structured feature units, the gated and modulated structured feature units are obtained. :

[0042] .

[0043] Furthermore, the aforementioned method of constructing a predictive model between accident features and accident severity categories through machine learning specifically includes:

[0044] The unified feature unit sequence is input into the TabTransformer encoder to obtain the feature representation output by the encoder. The feature representation is then input into the fully connected layer for classification prediction to obtain the accident severity prediction result.

[0045] During model training, based on the accident severity prediction results, the model is optimized using the cross-entropy loss function, and the model parameters are iteratively updated using the backpropagation algorithm, ultimately resulting in a trained traffic accident severity prediction model.

[0046] On the other hand, the present invention also provides a traffic accident severity prediction system based on joint modeling of BERT and TabTransformer, comprising:

[0047] Feature extraction module: used to acquire the original traffic accident dataset, process the original traffic accident dataset, and extract key structured features and semantic features of the accident text. The original traffic accident dataset also contains accident severity category labels.

[0048] Feature unit modulation module: used to quantify the semantic features of the accident text into multiple text continuous feature units, construct the key structured features of the accident into multiple basic structured feature units, and perform gated modulation processing on the corresponding basic structured feature units with each text continuous feature unit as a condition to obtain the modulated structured feature units.

[0049] Model building module: used to construct a unified feature unit sequence by combining the text continuity feature units and the modulated structured feature units, and to build a prediction model between accident features and accident severity categories based on the unified feature unit sequence through a machine learning process;

[0050] Result prediction module: used to acquire the data to be predicted and use the prediction model to obtain the accident severity prediction result of the data to be predicted.

[0051] The beneficial effects of this invention are:

[0052] (1) By introducing a pre-trained BERT model to perform contextual semantic modeling on accident description texts, we can fully explore the behavioral and environmental information contained in the accident texts, and combine the principal component analysis method to perform feature dimensionality reduction on the texts to improve the effectiveness of feature representation.

[0053] (2) Deeply integrate text semantic features with accident-related structured numerical features, and use the TabTransformer model to model the complex interaction relationship between multidimensional features, effectively improving the accuracy and generalization ability of accident severity prediction.

[0054] (3) By combining synthetic minority oversampling technology and Tomek linking downsampling technology, the class imbalance problem in accident data is alleviated, and the Shapley additive interpretation method is introduced to enhance the interpretability of the prediction results, providing reliable technical support for traffic accident analysis and emergency decision-making. The overall method has a clear structure and good engineering application value. Attached Figure Description

[0055] Figure 1 A flowchart illustrating a traffic accident severity prediction method based on joint modeling of BERT and TabTransformer provided in an embodiment of the present invention;

[0056] Figure 2 A schematic diagram of the architecture of a traffic accident severity prediction system based on joint modeling of BERT and TabTransformer provided for an embodiment of the present invention;

[0057] Figure 3 This is a comparison chart of data volume changes before and after data balancing, provided for an embodiment of the present invention. Detailed Implementation

[0058] To make the objectives, technical solutions, and advantages of this invention clearer and more understandable, the technical solutions of the embodiments of this invention will be clearly described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this invention, not all embodiments. Based on the embodiments of this invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this invention.

[0059] like Figure 1 As shown, this embodiment of the invention provides a method for predicting the severity of traffic accidents based on joint modeling of BERT and TabTransformer, including:

[0060] S101. Obtain the original traffic accident dataset, process the original traffic accident dataset, and extract the key structured features and semantic features of the accident text. The original traffic accident dataset also contains accident severity category labels.

[0061] Further, S101 specifically includes:

[0062] The original traffic accident dataset is divided into structured accident data and accident text description data.

[0063] Accident structured features are extracted from the structured accident data, and the importance of these features is evaluated using a random forest algorithm. Key accident structured features are then extracted from the evaluated accident structured features.

[0064] The accident text description data is cleaned, and the cleaned accident text description data is serialized into a text sequence. The semantic features of the accident text are extracted from the text sequence.

[0065] Specifically, historical traffic accident data is obtained as the raw traffic accident dataset, which originates from publicly available traffic accident datasets from traffic management departments. This raw traffic accident dataset contains both structured accident data and unstructured accident text data. The structured accident data includes numerical or categorical features such as accident occurrence time, road type, weather conditions, vehicle type, and speed limits. The unstructured accident text data mainly consists of accident descriptions, police reports, or on-site records.

[0066] The acquired raw traffic accident dataset is parsed and its types are identified. The raw traffic accident dataset is then divided to obtain a structured accident data set. , and accident text description data set This provides a foundation for subsequent separate processing and joint modeling.

[0067] Furthermore, to address the issues of missing values, outliers, and noisy data in the structured accident data, the structured accident data is cleaned. Structured accident features are extracted from the cleaned structured accident data. For missing values, they are filled using the mean or median, calculated using the following formula:

[0068]

[0069] in, Represents the original feature values. Indicates the number of samples.

[0070] Outliers are identified and removed using statistical distribution analysis or threshold determination methods. After handling missing and outlier values, continuous numerical features are normalized to eliminate differences in the dimensions of different features. The normalization formula is as follows:

[0071]

[0072] in, These are the normalized eigenvalues.

[0073] Furthermore, to reduce the impact of redundant features on model training and improve the efficiency and generalization ability of the prediction model, a random forest algorithm is used to evaluate the feature importance of the cleaned accident structured features. The random forest is trained on samples using multiple decision trees, where features... The importance can be expressed as:

[0074]

[0075] Where M represents the number of decision trees, Representation of features In the The change in Gini index or information gain brought about by each decision tree. Based on the calculated feature importance scores, the structured features of the accident are ranked, and features with importance higher than a preset threshold are selected as the set of key structured features of the accident.

[0076]

[0077] in, This is the threshold for feature selection.

[0078] Through the above steps, the original traffic accident dataset is cleaned, standardized, and its features are selected, resulting in high-quality input data for subsequent text semantic modeling and accident severity prediction.

[0079] Furthermore, for unstructured text data describing accidents (i.e., accident text description data), the text content is cleaned and standardized. Specifically, this includes removing invalid characters, punctuation marks, and redundant information, performing word segmentation, and standardizing the text format. Let the cleaned text be represented as:

[0080]

[0081] The above processing ensures the integrity and consistency of the text's semantic information, providing high-quality input for subsequent semantic feature extraction.

[0082] Specifically, the obtained accident description text data after cleaning As text input data, the text undergoes serialization processing. First, the text is segmented into words based on the vocabulary of the pre-trained language model, and start and end markers are added to the beginning and end of the text respectively, converting the text into a word sequence representation.

[0083]

[0084] in, Indicates the word elements after word segmentation. This indicates the maximum text length. Text shorter than the maximum length will be padded; text exceeding the maximum length will be truncated to ensure consistent input formatting.

[0085] Furthermore, semantic features of the accident text are extracted from the text sequence, specifically including:

[0086] The text sequence is processed by the multi-layer Transformer encoder of the BERT model to extract the initial text semantic features. Then, the initial text semantic features are reduced in dimensionality using the principal component analysis method. Finally, the reduced initial text semantic features are standardized to obtain the accident text semantic features.

[0087] Specifically, semantic features of accident text are extracted based on the BERT model. The encoded text sequence is input into a pre-trained BERT model for contextual semantic modeling. The BERT model processes the word sequence through a multi-layer Transformer encoder, and its self-attention mechanism can be represented as follows:

[0088]

[0089] in, These represent the query matrix, key matrix, and value matrix, respectively. The dimension is vector. Through multi-layer attention computation, the BERT model outputs a context semantic vector corresponding to each word, and finally selects the output vector corresponding to the special tag [CLS] as the semantic representation of the entire accident description text: ,in, A high-dimensional semantic feature vector representing the accident text.

[0090] Since the initial text semantic features output by BERT have a high dimensionality, directly co-modeling them with the key structured features of the accident may increase computational complexity. Therefore, dimensionality reduction processing is performed on the initial text semantic features. Principal component analysis is used to compress the initial text semantic features, and the dimensionality reduction process can be expressed as follows:

[0091]

[0092] in, It is the projection matrix composed of the eigenvectors of the characteristic covariance matrix. This represents the initial semantic features of the text after dimensionality reduction. By selecting principal components whose cumulative contribution rate reaches a preset threshold, the initial semantic features of the text are effectively compressed, reducing the feature dimensionality while preserving semantic information as much as possible.

[0093] Initial text semantic features after dimensionality reduction Standardization is performed to ensure uniform distribution characteristics, facilitating subsequent integration with the key structured features of the accident. The standardization process is as follows:

[0094]

[0095] in, and These represent the mean and standard deviation of the text features, respectively.

[0096] After the above processing, the final set of semantic features of the accident text used for joint modeling is obtained:

[0097]

[0098] The extraction and representation of semantic features of accident texts are completed, providing input for subsequent fusion with key structured features of accidents and training of traffic accident severity prediction models.

[0099] S102. The semantic features of the accident text are quantified into multiple text continuity feature units, and the key structured features of the accident are constructed into multiple basic structured feature units. The corresponding basic structured feature units are subjected to gated modulation processing based on each text continuity feature unit to obtain the modulated structured feature units.

[0100] Furthermore, S102 also includes:

[0101] Statistical analysis was performed on the severity category labels to obtain a set of accident severity category labels;

[0102] The minority class samples in the accident severity category label set are expanded by synthetic minority class oversampling technology, and the noise introduced during the expansion process is cleaned up by tomek linking, so as to construct a training sample set with balanced accident severity categories. Feature units are obtained by using the key structured features of accidents and the semantic features of accident text in the training sample set.

[0103] Specifically, to address the issue of uneven sample distribution across different accident severity levels, a combination of Synthetic Minority Over-sampling Technique (SMOTE) and Tomek Links downsampling techniques is used for sample balancing.

[0104] After extracting the key structured features and semantic features of the accident text, the severity category labels of the traffic accident samples in the original traffic accident dataset are obtained, and statistical analysis is performed on the severity category labels of the traffic accident samples. Let the set of accident severity category labels be:

[0105]

[0106] in, Indicates the first Each sample corresponds to an accident severity level. Statistical analysis of the number of samples in each category revealed significant differences in sample size between different accident severity categories. The number of samples from serious accidents (such as serious injuries or deaths) was far fewer than that from minor accidents, resulting in an imbalanced category distribution.

[0107] To avoid bias towards the majority class during model training, the sample data is balanced before entering the model training process:

[0108] Minority class oversampling processing based on synthetic minority class oversampling technology is performed, specifically including: for accident severity categories with a small sample size, synthetic minority class oversampling is used to expand the minority class samples. For any minority class sample... Select the nearest neighbor sample in its feature space New synthetic samples are generated as follows:

[0109]

[0110] in, These are random coefficients. New sample points are generated through interpolation in the feature space, making the minority class samples more evenly distributed within the feature space. Using this method, the joint feature vector composed of the semantic features of the accident text and the key structural features of the accident is simultaneously oversampled, ensuring the consistency of the generated samples in the multi-dimensional feature space.

[0111] Next, the noise sample cleaning process using tomek linking includes: after the oversampling operation, to avoid introducing noisy samples or sample overlap issues, the tomek linking method is further used to clean the samples. For sample pairs... If the following conditions are met:

[0112]

[0113]

[0114] Then sample pairs These are considered as a pair of Tomek links. For sample points belonging to the majority class, they are removed from the training set to reduce boundary overlap between different classes and improve sample discriminative power.

[0115] The construction of the sample set after joint sampling is specifically achieved by combining synthetic minority class oversampling with tomek link cleaning to construct a training sample set that balances the accident severity categories.

[0116]

[0117] in, This represents the processed structured features. This represents the corresponding text semantic features. This indicates the number of samples after sampling. Through a joint sampling strategy, while ensuring the number of samples in the minority class, sample overlap and noise interference are reduced, resulting in a more reasonable distribution of different accident severity categories in the feature space. This provides a more balanced data foundation for subsequent joint modeling and accident severity prediction model training.

[0118] Further, S102 specifically includes:

[0119] The above steps have yielded a set of semantic features for the accident text. , of which The dimensionality-reduced semantic vector corresponding to each sample is denoted as This step will Adaptive numericalization is converted into textual continuity feature units (tokens), and based on these textual continuity feature units, the basic structured feature units are gated and modulated to construct a unified input sequence for TabTransformer.

[0120] First, for the dimensionality-reduced semantic vector Learnable mappings are performed to obtain text continuity feature units:

[0121]

[0122] in, For learning parameters, It is a non-linear activation function. To unify the dimension of feature units, basic structured feature units are then constructed for the categorical and continuous features of the key structured data of the accident. Let the first... The categorical features of the samples are Continuous characteristics are ,but:

[0123] Categorical feature units:

[0124] ,

[0125] Continuous feature unit:

[0126]

[0127] in, These are learnable parameters.

[0128] For a unified representation, all basic structured feature units are denoted as... and define:

[0129]

[0130] To enable textual semantic information to participate in structured feature representation through "conditional modulation," textual continuity feature units are employed. As a condition, for each basic structured feature unit Generate gating coefficients and complete modulation fusion. The gating coefficients are defined as follows:

[0131]

[0132] And the structured feature units after gating modulation are obtained:

[0133]

[0134] in, This represents element-wise multiplication. For the Sigmoid function, , These are learnable parameters. Through the above process, a continuous numerical representation of the semantic vector of the accident text is achieved, enabling it to exert differentiated influence on different structured feature units in a conditional gating manner.

[0135] S103. Construct a unified feature unit sequence by combining the text continuity feature unit with the modulated structured feature unit. Based on the unified feature unit sequence, construct a prediction model between accident features and accident severity categories through a machine learning process.

[0136] Specifically, the unified feature unit sequence construction and TabTransformer input representation process includes: combining the text continuity feature units obtained in the above steps with the structured feature units after conditional gating modulation to form the input sequence of TabTransformer. For the first... For each sample, a unified input matrix is ​​constructed as follows:

[0137]

[0138] in, For the reason Text continuity feature units obtained through adaptive numericalization For the first A structured feature unit after conditional gating modulation The dimension is the feature unit dimension.

[0139] The unified feature unit sequence is input into TabTransformer, and feature interaction modeling is performed through a multi-layer Transformer encoding structure to learn the higher-order dependencies between continuous and structured feature units, as well as among structured feature units themselves. The layered Transformer encoding process is represented as follows:

[0140]

[0141] in This represents the number of coding layers.

[0142] The It consists of a multi-head self-attention mechanism and a feedforward network, and employs residual connections and layer normalization to improve training stability. The calculation formula for the multi-head self-attention mechanism is:

[0143]

[0144] in, These represent the query matrix, key matrix, and value matrix, respectively. This is the scaling factor.

[0145] Furthermore, the feature representation output from the TabTransformer encoder is fed into a fully connected layer for classification prediction, yielding the accident severity prediction result:

[0146]

[0147] in, This represents the output of the last Transformer layer. and These are the weight matrix and the bias term, respectively.

[0148] During model training, the severity category labels of real accidents are used. As a monitoring signal, the cross-entropy loss function is used to optimize the model, and its loss function is expressed as:

[0149]

[0150] The model parameters are updated using the backpropagation algorithm until the loss function converges, resulting in a trained traffic accident severity prediction model.

[0151] After the model training is completed, the trained model parameters are saved for use in the subsequent accident severity prediction stage to ensure that the model can run stably in the real application environment.

[0152] S104. Obtain the data to be predicted, and use the prediction model to obtain the prediction result of the accident severity of the data to be predicted.

[0153] Based on the prediction method of this invention, the unstructured text information containing a large amount of rich contextual semantic information and potential causal relationships in traffic accident data can be fully utilized. This information is then deeply extracted and fused with structured features. The prediction model obtained based on this can achieve more accurate prediction results of accident severity and stronger generalization ability.

[0154] On the other hand, such as Figure 2 As shown, the present invention also provides a traffic accident severity prediction system based on joint modeling of BERT and TabTransformer, comprising:

[0155] Feature extraction module: used to acquire the original traffic accident dataset, process the original traffic accident dataset, and extract key structured features and semantic features of the accident text. The original traffic accident dataset also contains accident severity category labels.

[0156] Feature unit modulation module: used to quantify the semantic features of the accident text into multiple text continuous feature units, construct the key structured features of the accident into multiple basic structured feature units, and perform gated modulation processing on the corresponding basic structured feature units with each text continuous feature unit as a condition to obtain the modulated structured feature units.

[0157] Model building module: used to construct a unified feature unit sequence by combining the text continuity feature units and the modulated structured feature units, and to build a prediction model between accident features and accident severity categories based on the unified feature unit sequence through a machine learning process;

[0158] Result prediction module: used to acquire the data to be predicted and use the prediction model to obtain the accident severity prediction result of the data to be predicted.

[0159] This invention proposes a traffic accident severity prediction system based on joint modeling of BERT and TabTransformer. By combining a feature extraction module, a feature unit modulation module, a model building module, and a result prediction module, it can solve the problems of existing traffic accident severity prediction methods that mainly rely on structured data and do not make sufficient use of textual information such as accident descriptions. It fully explores the complex interaction between deep semantic features and structured features in the text, thereby improving the accuracy of accident severity prediction.

[0160] It should be noted that the traffic accident severity prediction system based on joint modeling of BERT and TabTransformer provided in this embodiment of the invention is to implement the above method embodiment, and its specific functions can be referred to the above method embodiment.

[0161] To verify the effectiveness of the method and system proposed in this invention, the following experiments were also conducted:

[0162] This invention verifies its effectiveness through accident severity prediction and interpretability analysis. It utilizes the output traffic accident severity prediction results and combines the Shapley Additive Explanations (SHAP) method to analyze the contribution of various accident characteristics to the prediction results.

[0163] The unified sequence representation composed of continuous text feature units and gated structured feature units is input into the model. The model encodes and calculates the input features and outputs the predicted probability corresponding to each accident severity category.

[0164]

[0165] in, Indicates the number of accident severity categories. This indicates that the accident belongs to the first The predicted probability of the class. By determining the maximum value of the predicted probability, the final prediction result of the accident severity is obtained:

[0166]

[0167] To improve the interpretability of accident severity prediction results, this invention introduces the Shapley additive interpretation method to analyze the feature contribution of the model prediction results. Based on the Shapley value concept in game theory, this method quantifies the influence of each feature on the prediction results by calculating the marginal contribution of each input feature to the model prediction results under different feature combinations.

[0168] For any accident sample, the prediction result can be expressed as:

[0169]

[0170] in, This represents the model's predicted output for this accident sample. This represents the baseline output value of the model when there are no feature inputs. Indicates the first The contribution value of each feature to the prediction result. This represents the total number of input features.

[0171] The SHAP value of the i-th feature is calculated by weighting all possible feature subsets, and its expression is:

[0172]

[0173] in, For all feature sets, For features not included a subset of Indicates using only subsets The model's predicted value when the feature is specified.

[0174] By applying Shapley additive interpretation, the contribution values ​​corresponding to the key structured features of an accident and the semantic features of the accident text are calculated. This clarifies the positive or negative contribution of different features to the accident severity prediction results, thereby identifying the influencing factors that play a key role in determining accident severity and providing auxiliary basis for accident cause analysis and risk assessment. The predicted accident severity level and corresponding predicted probability are used as the final output results. The output format includes, but is not limited to, accident severity category labels, probability distribution results, and feature contribution information. The prediction results can be used in traffic accident risk assessment, emergency resource dispatch, and traffic safety management systems to provide decision support for traffic management departments.

[0175] Furthermore, the experimental results of this invention fully verify the effectiveness and superiority of the method proposed in this invention. For example... Figure 3 As shown in the comparison chart of data volume changes before and after data balancing, it can be seen that the minority class samples have increased while the majority class boundary samples have decreased. This demonstrates that the sample balancing method of the present invention can alleviate the class imbalance problem in accident data and provide a fairer sample basis for subsequent model training.

[0176] As shown in Tables 1 to 3, the proposed model achieved the best performance across all key evaluation metrics on three different traffic accident datasets, with overall performance significantly outperforming the benchmark models. Particularly noteworthy is the F1-Score, which measures the overall performance of the imbalanced classification task. The proposed method achieved 0.9366 on the US_Accidents 2019–2023 dataset, 0.7695 on the UK_Accidents 2005–2017 dataset, and 0.8855 on the UK_Accidents 2019–2023 dataset, all significantly higher than other models. These results clearly demonstrate that the proposed method has significant advantages in complex imbalanced traffic accident data scenarios, especially in the identification of a minority of serious accidents.

[0177] Table 1 shows the performance of each model on the US_Accidents 2019-2023 dataset.

[0178]

[0179] Table 2 shows the performance of each model on the UK_Accidents 2005-2017 dataset.

[0180]

[0181] Table 3. Performance of each model on the UK_Accidents 2019-2023 dataset

[0182]

[0183] As can be seen, the traffic accident severity prediction method and system proposed in this invention, based on joint modeling of BERT and TabTransformer, achieves accurate modeling of accident severity by deeply integrating the semantic representation and structured numerical features of accident description text. Specifically, firstly, the accident description text is semantically encoded using the BERT model, effectively mining the behavioral and causal relationship information contained in the text, and the feature processing efficiency is improved by using principal component analysis as a dimensionality reduction strategy. Based on the text semantics, gating coefficients of structured feature units are generated, key structured features are retained and interactively modeled, and the dependencies between feature units are learned under the TabTransformer self-attention mechanism. Experimental results show that this method significantly outperforms traditional machine learning models and deep learning models in multiple key indicators such as precision, recall, and F1 score, demonstrating stable and superior prediction performance.

[0184] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for predicting the severity of traffic accidents based on joint modeling using BERT and TabTransformer, characterized in that, Include: Step 1: Obtain the original traffic accident dataset, process the original traffic accident dataset, and extract the key structured features and semantic features of the accident text. The original traffic accident dataset also contains accident severity category labels. Step 2: The semantic features of the accident text are quantified into multiple text continuity feature units, and the key structured features of the accident are constructed into multiple basic structured feature units. The corresponding basic structured feature units are subjected to gated modulation processing based on each text continuity feature unit to obtain the modulated structured feature units. Step 3: Construct a unified feature unit sequence by combining the text continuity feature units and the modulated structured feature units. Based on the unified feature unit sequence, construct a prediction model between accident features and accident severity categories through a machine learning process. Step 4: Obtain the data to be predicted, and use the prediction model to obtain the prediction result of the accident severity of the data to be predicted.

2. The traffic accident severity prediction method based on joint modeling of BERT and TabTransformer as described in claim 1, characterized in that, Step 1 specifically includes: The original traffic accident dataset is divided into structured accident data and accident text description data. Accident structured features are extracted from the structured accident data, and the importance of these features is evaluated using a random forest algorithm. Key accident structured features are then extracted from the evaluated accident structured features. The accident text description data is cleaned, and the cleaned accident text description data is serialized into a text sequence. The semantic features of the accident text are extracted from the text sequence.

3. The traffic accident severity prediction method based on joint modeling of BERT and TabTransformer as described in claim 2, characterized in that, Extracting structured accident features from the structured accident data specifically includes: The structured accident data is cleaned, and the structured accident features are extracted from the cleaned structured accident data. The data cleaning process includes: For missing values ​​in the structured accident data, the mean or median is used to fill in the missing values. Outlier data in the structured accident data are identified and removed through statistical distribution analysis or threshold determination methods.

4. The method for predicting the severity of traffic accidents based on joint modeling of BERT and TabTransformer as described in claim 2, characterized in that, Extracting accident text semantic features from the text sequence specifically includes: The text sequence is processed by the multi-layer Transformer encoder of the BERT model to extract the initial text semantic features. Then, the initial text semantic features are reduced in dimensionality using the principal component analysis method. Finally, the reduced initial text semantic features are standardized to obtain the accident text semantic features.

5. The traffic accident severity prediction method based on joint modeling of BERT and TabTransformer as described in claim 1, characterized in that, Step 2 further includes: Statistical analysis was performed on the severity category labels to obtain a set of accident severity category labels; The minority class samples in the accident severity category label set are expanded by synthetic minority class oversampling technology, and the noise introduced during the expansion process is cleaned up by tomek linking, so as to construct a training sample set with balanced accident severity categories. Feature units are obtained by using the key structured features of accidents and the semantic features of accident text in the training sample set.

6. The traffic accident severity prediction method based on joint modeling of BERT and TabTransformer as described in claim 1, characterized in that, The semantic features of the accident texts in the training sample set are numerically converted into continuous text feature units, specifically including: Each semantic vector in the semantic features of the accident text is subjected to a learnable mapping to obtain each text continuity feature unit. : in, For learning parameters, For the first semantic vector of a sample It is a non-linear activation function. To unify the dimension of feature units.

7. The traffic accident severity prediction method based on joint modeling of BERT and TabTransformer as described in claim 1, characterized in that, The key structured features of the accident are constructed into basic structured feature units, specifically including: The key structured features of the accident are divided into categorical features and continuous features. Categorical feature units and continuous feature units are constructed from the categorical features and continuous features respectively. The categorical feature units and continuous feature units are then unified into basic structured feature units. The category-type feature unit Represented as: , in, Indicates the first The j-th categorical feature of the sample, To unify the dimension of feature units; The continuous feature unit Represented as: in, Indicates the first The j-th continuous feature of the sample, It is a non-linear activation function. These are learnable parameters.

8. The traffic accident severity prediction method based on joint modeling of BERT and TabTransformer as described in claim 1, characterized in that, Gated modulation processing is performed on each text continuity feature unit and its corresponding basic structured feature unit, specifically including: Each text continuity feature unit is used as a condition, and combined with the corresponding basic structured feature unit to generate gating coefficients. : in, For the first Text continuity feature units of the sample For the first The p-th basic structured feature unit of the sample, This represents element-wise multiplication. For the Sigmoid function, , For learnable parameters, To unify the dimension of feature units; Using each of the aforementioned gating coefficients, combined with the corresponding text continuity feature units and basic structured feature units, the gated and modulated structured feature units are obtained. : 。 9. The method for predicting the severity of traffic accidents based on joint modeling of BERT and TabTransformer as described in claim 1, characterized in that, The aforementioned method of constructing a predictive model between accident features and accident severity categories through machine learning specifically includes: The unified feature unit sequence is input into the TabTransformer encoder to obtain the feature representation output by the encoder. The feature representation is then input into the fully connected layer for classification prediction to obtain the accident severity prediction result. During model training, based on the accident severity prediction results, the model is optimized using the cross-entropy loss function, and the model parameters are iteratively updated using the backpropagation algorithm, ultimately resulting in a trained traffic accident severity prediction model.

10. A traffic accident severity prediction system based on joint modeling of BERT and TabTransformer as described in claim 1, characterized in that, Include: Feature extraction module: used to acquire the original traffic accident dataset, process the original traffic accident dataset, and extract key structured features and semantic features of the accident text. The original traffic accident dataset also contains accident severity category labels. Feature unit modulation module: used to quantify the semantic features of the accident text into multiple text continuous feature units, construct the key structured features of the accident into multiple basic structured feature units, and perform gated modulation processing on the corresponding basic structured feature units with each text continuous feature unit as a condition to obtain the modulated structured feature units. Model building module: used to construct a unified feature unit sequence by combining the text continuity feature units and the modulated structured feature units, and to build a prediction model between accident features and accident severity categories based on the unified feature unit sequence through a machine learning process; Result prediction module: used to acquire the data to be predicted and use the prediction model to obtain the accident severity prediction result of the data to be predicted.