A method and system for predicting the duration of a highway accident

CN122886883APending Publication Date: 2026-10-09BEIJING UNIV OF TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611154730.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-31
Publication Date
2026-10-09

AI Technical Summary

Technical Problem

[0003]目前事故持续时间预测技术主要分为三类:第一类为统计模型方法,基于概率分布假设或生存分析框架建模,如风险函数模型等,具备较强的数学解释性,但对复杂非线性耦合关系的拟合能力有限;第二类为传统机器学习方法,如随机森林、梯度提升树等集成学习算法,可通过非线性映射学习多源交通特征与事故持续时间的关联规律,适应能力优于统计模型,但对长尾分布的极端场景处理不足;第三类为深度学习方法,依托神经网络的多层非线性结构实现高维特征自动提取,具备端到端建模能力,但对数据量要求高,小样本长尾场景下易出现过拟合或系统性偏差

Benefits of technology

1.本发明构建了参数化全局学习与非参数化局部记忆融合的预测架构,通过TabPFN基础模型学习全局非线性映射关系,同时依托相似事故检索提取局部历史经验,有效弥补了传统回归模型被海量短时样本主导、对长时事故系统性低估的缺陷,实现了对长尾长时事故的精准建模。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122886883A_ABST
    Figure CN122886883A_ABST
Patent Text Reader

Abstract

The application discloses a kind of expressway accident duration prediction method and system, belong to intelligent transportation technical field.The application is directed to the problems that existing method is easily dominated by short-time accident sample, long-time accident exists systematic underestimation, lack of risk quantization and graded early warning capability, long and short-time prediction accuracy is difficult to take into account, adopts TabPFN to construct basic predictor to learn global feature mapping relationship, estimates multistage threshold long-time risk probability based on verification set residual distribution, fuses scene features and risk signal to retrieve similar accident to extract local historical evidence vector, and carries out selective adjustment to long tail underestimation sample by triple gate mechanism and bounded correction strategy.The application effectively improves long-time accident identification accuracy, takes into account short-time prediction stability and long-time prediction accuracy, can synchronously output duration prediction value and graded risk early warning information, has strong cross-scene generalization capability, and is suitable for expressway accident emergency disposal and traffic control scheduling decision support.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of intelligent transportation and highway traffic safety management technology, specifically relating to a method and system for predicting the duration of highway accidents. Background Technology

[0002] Accurately predicting the duration of traffic accidents is a core foundation for assessing highway traffic conditions, analyzing congestion spread patterns, and developing emergency response strategies. Accident duration refers to the time interval from the occurrence or reporting of a traffic accident until the road returns to normal traffic flow.

[0003] Currently, accident duration prediction technologies are mainly divided into three categories: The first category is statistical modeling methods, which are based on probability distribution assumptions or survival analysis frameworks, such as risk function models. These methods have strong mathematical interpretability, but their ability to fit complex nonlinear coupling relationships is limited. The second category is traditional machine learning methods, such as ensemble learning algorithms like random forests and gradient boosting trees. These algorithms can learn the correlation between multi-source traffic features and accident duration through nonlinear mapping, and their adaptability is better than statistical models. However, they are not good at handling extreme scenarios with long-tailed distributions. The third category is deep learning methods, which rely on the multi-layer nonlinear structure of neural networks to achieve automatic extraction of high-dimensional features. These methods have end-to-end modeling capabilities, but they require a large amount of data and are prone to overfitting or systematic bias in small-sample, long-tailed scenarios.

[0004] Existing technologies still have significant shortcomings in practical engineering applications: First, model training is easily dominated by short-term accident samples, which account for a larger proportion, and tends to fit the central trend of duration, resulting in a systematic underestimation of long-term accidents, which account for a small proportion but have a large impact. Second, long-term accidents are affected by multiple factors such as accident type, vehicle composition, road occupation range, road environment, and handling conditions. The sparse sample makes it difficult for the model to fully learn its characteristic patterns, and its generalization ability in extreme scenarios is weak. Third, existing research focuses on the point prediction accuracy of duration, lacks a quantitative characterization of the risk probability of long-term accidents, cannot provide early warning information exceeding key management thresholds, and is difficult to support graded response and dynamic resource pre-positioning decisions. Fourth, the models generally adopt a globally unified learning approach, lacking a mechanism for identifying and selectively correcting potentially long-tailed underestimated samples, making it difficult to simultaneously ensure the stability of short-term accident prediction and the accuracy of long-term accident prediction.

[0005] Therefore, there is an urgent need for a highway accident duration prediction scheme that can adapt to long-tail distribution characteristics, take into account both global prediction stability and long-term accident prediction accuracy, and output multiple levels of risk probability. Summary of the Invention

[0006] This invention aims to at least solve one of the technical problems existing in the prior art. Therefore, one objective of this invention is to propose a method and system for predicting the duration of highway accidents. By integrating parametric global prediction with non-parametric local historical evidence, it achieves accurate prediction and risk quantification of long-tail, long-duration accidents, while ensuring the stability of short-duration accident prediction, thus meeting the hierarchical decision-making needs of highway traffic safety management.

[0007] To achieve the above objectives, the present invention provides a method for predicting the duration of highway accidents, comprising the following steps: S1: Obtain the raw data of highway accidents, clean the raw data, encode the categorical variables and standardize the numerical variables, set the accident duration as the prediction target, and construct a structured feature vector of accidents containing multi-dimensional features; perform distribution transformation on the target variable to alleviate the influence of right skew distribution, and then divide it into training set, validation set and test set according to a preset ratio to form an accident dataset; S2: Train a TabPFN table regression model based on the training set as the basic predictor. Learn the global mapping relationship between accident features and duration through the basic predictor. Input the structured feature vector of the accident to be predicted into the basic predictor. After inverse transformation and non-negativity constraint processing, obtain the basic duration prediction value of the accident to be predicted. S3: Based on the predicted base duration and the actual duration of each sample in the validation set, calculate the validation residuals and construct an empirical residual set; superimpose the empirical residual set one by one onto the predicted base duration of the accident to be predicted to generate the simulated duration distribution of the accident to be predicted; based on the simulated duration distribution, statistically obtain the long-term risk probability that the duration of the accident to be predicted exceeds each preset management threshold. S4: Construct a historical accident database using accident samples from the training set. Combine the structured features and long-term risk probability of the accident to be predicted to calculate the comprehensive similarity distance between the accident to be predicted and each sample in the historical accident database. Sort the samples by comprehensive similarity distance from smallest to largest and select the first preset number of samples to form a similar accident neighborhood. Extract the multi-dimensional duration statistical features of the similar accident neighborhood and combine them to form a local historical evidence vector. S5: Based on the predicted base duration of the accident to be predicted, the long-term risk probability, and the local historical evidence vector, determine whether the accident to be predicted meets the long-tail correction condition; if the correction condition is met, calculate the correction weight and construct the fusion correction term, and adjust the predicted base duration after bounded pruning constraints to obtain the final predicted duration value; if the correction condition is not met, directly use the predicted base duration value as the final predicted duration value. S6: Output the predicted final duration of the accident to be predicted, and the corresponding long-term risk probability exceeding each preset management threshold.

[0008] Preferably, in step S1, the structured feature vector includes five dimensions: spatiotemporal features, environmental features, vehicle features, accident features, and traffic impact features; the target variable is logarithmically transformed to alleviate the impact of the right-skewed distribution on model training; in the prediction stage, it is restored to a minute-level time scale through exponential inverse transformation; and non-negative constraints are applied to the inverse transformation results.

[0009] Preferably, in step S3, the empirical residual set is calculated only from the validation set and remains fixed during the testing and prediction phases, without participating in parameter updates; the preset management thresholds include at least three levels: 60 minutes, 90 minutes, and 120 minutes, corresponding to the output of three levels of long-term risk probabilities.

[0010] Preferably, in step S4, the comprehensive similarity distance is obtained by weighted combination of numerical feature distance, category feature distance and long-term risk signal distance, and the Gaussian distance metric is used to adapt to both numerical and category features; wherein the long-term risk signal distance is calculated based on the long-term risk probability of an accident exceeding 120 minutes.

[0011] Preferably, in step S4, the multi-dimensional duration statistical features include the mean, median, high quantile, standard deviation, and coefficient of variation of the duration of similar accidents, as well as the proportion of long-duration accidents in the neighborhood of similar accidents.

[0012] Preferably, in step S5, the long-tail correction condition simultaneously satisfies three constraints: First, the predicted base duration falls within the preset long-tail candidate range; Second, the long-term risk probability of the accident to be predicted is higher than the preset risk threshold. Third, the difference between the median duration and the predicted baseline duration in the neighborhood of similar accidents is higher than the preset difference gating threshold.

[0013] Preferably, in step S5, the correction weight is calculated by the evidence reliability of the neighborhood of similar accidents, the long-tail tendency score of the neighborhood, and the long-term risk probability of the accident to be predicted itself; the fusion correction term is constructed based on the difference between the median duration of similar accidents and the basic prediction value, and the correction term is bounded by a preset maximum correction magnitude to limit the correction magnitude range of a single sample.

[0014] A highway accident duration prediction system includes: The data preprocessing module is used to acquire raw data of highway accidents, perform data cleaning, feature encoding, target variable transformation and dataset partitioning operations, and output an accident dataset containing structured feature vectors. The TabPFN basic prediction module is used to train a tabular regression model based on the training set, learn the global mapping relationship between accident features and duration, and output the basic duration prediction value of the accident to be predicted. The long-term risk estimation module is used to construct an empirical residual set based on the prediction residuals of the validation set, generate the simulated duration distribution of the accident to be predicted, and statistically output the long-term risk probability that exceeds the multi-level management threshold. The similar accident retrieval module is used to build a historical accident database with the training set, calculate the comprehensive similarity distance by combining scene features and risk signals, retrieve the neighborhood of similar accidents and extract local historical evidence vectors. The risk gating fusion module is used to determine the correction conditions based on the basic duration prediction value, long-term risk probability and local historical evidence vector, perform bounded correction on samples that meet the conditions, and output the final duration prediction value. The results output module is used to output the final predicted duration value and the long-term risk probability corresponding to each level threshold.

[0015] Preferably, the similar accident retrieval module uses a weighted Goal distance metric to calculate the similarity distance between samples by comprehensively considering differences in numerical features, differences in category features, and differences in long-term risk signals, and retrieves a preset number of the most similar historical accidents.

[0016] Preferably, the risk gating fusion module is equipped with triple gating judgment conditions and maximum correction range constraints. It performs prediction correction only on long-tail candidate samples that simultaneously meet the gating conditions, and retains the basic prediction results for short-term accidents that do not meet the conditions.

[0017] The advantages of this invention compared to the prior art are: Compared with the prior art, the present invention has the following beneficial effects: 1. This invention constructs a prediction architecture that integrates parametric global learning and non-parametric local memory. It learns global nonlinear mapping relationships through the TabPFN basic model, and extracts local historical experience by relying on similar accident retrieval. This effectively makes up for the shortcomings of traditional regression models that are dominated by massive short-term samples and systematically underestimate long-term accidents, and achieves accurate modeling of long-tail long-term accidents.

[0018] 2. This invention realizes multi-threshold long-term risk probability quantification and dual-drive similarity retrieval. Based on the basic prediction results and the residual distribution of the validation set, it can directly output the risk probability of an accident exceeding different management thresholds. At the same time, it incorporates risk signals into similarity measurement, forming a retrieval mechanism driven by scene features and risk signals, so that local historical evidence can be matched with accident scenes and long-tail risks at the same time, improving the pertinence of correction.

[0019] 3. This invention employs risk gating and bounded correction strategies to ensure global stability. It dynamically identifies potentially underestimated samples through triple gating conditions and selectively corrects only long-term incidents that meet the conditions. Combined with difference gating and correction magnitude constraints, it avoids interference from retrieval noise on short-term incident prediction, achieving robust prediction across the entire range of short, medium, and long-term timeframes.

[0020] 4. This invention has strong engineering generalization and implementation capabilities. The basic predictor reuses the prior knowledge of the pre-trained table model, eliminating the need for cumbersome feature engineering and deep parameter tuning. It is highly adaptable to cross-regional and multi-source data distribution differences and can be quickly deployed in traffic safety management systems on different highway sections. Attached Figure Description

[0021] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0022] Figure 1 This is a schematic diagram of the overall process of the highway accident duration prediction method of the present invention. Detailed Implementation

[0023] The embodiments of this application are described in detail below. Examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain this application, and should not be construed as limiting this application.

[0024] In the description of this application, it should be noted that, unless otherwise expressly specified and limited, the terms "installation," "connection," and "joining" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; they can refer to the internal communication of two components or the interaction between two components. Those skilled in the art can understand the specific meaning of the above terms in this application according to the specific circumstances.

[0025] The present invention will now be described in further detail with reference to the accompanying drawings.

[0026] Example 1: As Figure 1 As shown, the method of the present invention mainly includes: data preprocessing and dataset construction, TabPFN basic predictor construction, long-term accident risk estimation, local historical evidence extraction based on similar accident retrieval, risk gating fusion and bounded correction, and output of accident duration prediction results.

[0027] S1: Data preprocessing and dataset construction.

[0028] In this embodiment, accident records from the Beijing-Harbin Expressway from 2019 to 2021 are used as research data to construct a model for predicting the duration of expressway accidents. The original accident data includes the time of the accident, the location of the accident, the direction of travel, weather and road conditions, the composition of the vehicles involved, the type of accident, the lane occupancy status, the traffic operation status, the type of blockage, the affected lanes, and information related to the accident handling process.

[0029] First, the original accident records are cleaned, removing accident samples with severe omissions, illogical timelines, or unusable target variables. Then, the categorical variables in the accident data are uniformly coded, and fields that could potentially cause information leakage are removed to ensure the rigor of the model training process.

[0030] Accident duration is used as the prediction target, defined as the time interval from the occurrence or reporting of a traffic accident to the restoration of normal traffic flow. Based on the mechanism of accident duration formation, each accident is represented as a structured tabular feature vector: in Indicates accident eigenvectors, The spatiotemporal characteristics of the accident are indicated, including the time of the accident, whether it occurred at night, the day of the week, whether it was a weekend, the month, the season, the area of ​​the accident, the direction of travel, the distance from the upstream service area, and the distance from the upstream traffic node. It indicates environmental characteristics, including weather, visibility, road surface condition, road conditions, and whether it is in a construction zone; The characteristics of the vehicles involved include the number of vehicles involved, vehicle type, vehicle usage, whether heavy trucks or hazardous chemical vehicles are involved; It indicates the characteristics of the accident, including the type of accident, whether it is a multi-vehicle accident, the extent of vehicle damage, and possible causes; It indicates the characteristics of traffic impact, including traffic operation status, type of blockage, and number of lanes affected.

[0031] Since accident durations typically exhibit a right-skewed distribution, a logarithmic transformation is applied to the accident duration to mitigate the impact of extremely long-duration accidents on model training. in, For the accident before the transformation The duration of the accident, This represents the transformed duration of the accident. Simultaneously, the prediction result needs to be restored to a minute scale through an inverse exponential transform, and a non-negativity constraint is applied to the inverse transform result: in, To represent the first value obtained after inverse transformation and applying nonnegativity constraints The predicted duration of the accident. To represent the first output of the model The predicted value of the accident on a logarithmic scale. Represents an exponential function. This means that the prediction result will be restricted to non-negative values.

[0032] Finally, the processed accident samples were randomly divided into training, validation, and test sets in a ratio of 8:1:1.

[0033] S2: Construct the TabPFN basic predictor.

[0034] Given a training set: in, Indicates the first The structured feature vector of the accident, Indicates the corresponding duration of the accident. This indicates the number of training samples.

[0035] The TabPFN basic predictor can be represented as: in, This represents a TabPFN table regression model. For the first The basic prediction of the accident on a logarithmic scale.

[0036] Subsequently, the logarithmic-scaled predictions are inversely transformed to a minute-scale, and a non-negativity constraint is applied: in, This represents the base duration prediction value obtained after inverse transformation and application of nonnegativity constraints. The TabPFN base predictor is mainly used to learn the global regression relationship of accident duration, capturing the overall mapping pattern of accident features to duration from all training samples.

[0037] S3: Long-term accident risk assessment.

[0038] To determine whether a current incident poses a long-term risk, this invention estimates the probability of long-term incident risk based on the duration prediction results of TabPFN and the residual distribution of the validation set. The residual distribution is estimated only from the validation set and remains fixed during the testing phase, not participating in any parameter updates. This design maintains consistency in regression predictions while avoiding the model complexity and training burden introduced by independent classifiers.

[0039] Let the validation set be: in, Indicates the first Accident characteristics of a verification sample Indicates the actual duration of the accident. This indicates the number of validation set samples. The validation set samples are input into the TabPFN base prediction model to obtain the base prediction values ​​on a logarithmic scale, which are then inversely transformed to a minute scale to obtain... The verification residual is defined as: This yields the empirical residual set of the validation set: For any test accident , the residual set Stack them one by one to their point estimates Above, and apply nonnegativity constraints to generate the simulation duration: in, Indicates the first The verification residuals are summed up to the first... The simulated duration is obtained after the basic predicted value of the accident to be predicted is taken.

[0040] Based on the duration distribution obtained from the simulation, it is estimated that the duration of the accident exceeds the threshold. Long-term risk probability: in, This is an indicator function that takes the value 1 if the condition within the parentheses is true, and 0 otherwise. Indicates the first The random variable representing the actual duration of the accident; Indicates the first The duration of the accident exceeded the threshold. The estimated probability.

[0041] This embodiment sets three key management thresholds. Each accident can be assigned three long-term risk probabilities. ,in, This indicates the probability that the accident will last for more than 60 minutes. This indicates the probability of exceeding 90 minutes. This indicates the probability of exceeding 120 minutes.

[0042] S4: Local Historical Evidence Extraction Based on Similar Incident Retrieval This embodiment constructs a historical accident database from the training set accident samples and uses it as a non-parametric memory unit to extract local historical evidence through similar accident retrieval. Let the historical accident database be: in, Indicates the first Accident characteristics of each training sample, This indicates the actual duration of the incident. This indicates the number of training samples.

[0043] For any predictable accident The similar accident retrieval module starts from Choose the one most similar to it A set of similar accidents is formed from historical accident samples: in, Indicates the first The neighborhood of similar accidents corresponding to the accident. To retrieve the number of neighbors, the Gaussian distance metric is used to calculate the similarity between accidents, since accident features include both numerical and categorical variables. (Sample) and samples The distance between them is defined as: in, Indicates the distance of numerical features; Represents the distance between category features; Indicates the distance of long-term risk signals; , and These represent the corresponding weight parameters.

[0044] For numerical feature sets The numerical variables are normalized, and the mean absolute difference is used to represent the numerical distance: in, and Representing samples respectively and samples In the Normalized values ​​on each numerical feature Indicates the number of numerical features.

[0045] For categorical feature sets Category distance is represented using an inconsistent ratio: in, and Representing samples respectively and samples In the The values ​​of each category feature; As an indicator function, when two samples are at the th... When the values ​​of the categorical features are inconsistent, this item is set to 1; otherwise, it is set to 0. Indicates the number of category features.

[0046] In addition to accident scene characteristics, long-term risk probability is included in the search distance. As the main long-tail risk signal, the sample and samples The risk distance between them is defined as: in, For historical accidents Long-tail risk signals.

[0047] Based on comprehensive distance For each sample to be predicted The training set samples are sorted in ascending order of distance, and the top samples are selected. One sample is used as a similar historical event: in, This indicates selecting the option with the smallest distance. Training samples.

[0048] After obtaining the set of similar accidents, the statistical characteristics of their durations are extracted as local historical evidence. Let the actual duration corresponding to the set of similar accidents be... for: based on Construct the average duration of similar accidents , median and high quantiles They are respectively: in, express Quantiles. This article focuses primarily on higher quantiles, such as... and To characterize the long duration level in the neighborhood of similar accidents.

[0049] Simultaneously, the standard deviation and coefficient of variation of the duration of similar accidents were calculated: in, To prevent extremely small constants with a denominator of zero, the mean and median are used to characterize the general duration level of similar accidents, the high quantiles are used to characterize the long duration level in the neighborhood of similar accidents, and the standard deviation and coefficient of variation are used to measure the stability of the duration distribution in the neighborhood of similar accidents.

[0050] Furthermore, the proportion of long-duration accidents in the neighborhood of similar accidents is calculated. : The above statistics are combined into a local historical evidence vector: in, Indicates the first The context of similar historical accidents is retrieved. This context does not directly replace the basic prediction value, but serves as local historical evidence in the subsequent risk gating fusion module to determine whether the basic prediction results need to be corrected, and the direction and extent of the correction.

[0051] S5: Risk Gating Fusion and Bounded Correction.

[0052] To address the issue that the base model in predicting the duration of long-tailed accidents tends to underestimate long-term accidents, this invention constructs a risk-gated fusion and bounded correction module. This module comprehensively utilizes the TabPFN base prediction value, long-term risk probability, and local historical evidence from similar accidents to selectively correct long-term accidents that may have underestimated risks; for accidents that do not meet the correction conditions, the base prediction result remains unchanged.

[0053] For any predictable accident Determine whether it meets the long-tail correction condition. The long-tail correction condition includes: First, the baseline predicted value needs to be included in the long-tail candidate interval: in, This represents the long-tail candidate threshold. This condition is used to exclude obvious short-term incidents and avoid unnecessary corrections to short-term samples.

[0054] Second, the long-term risk probability of the current accident needs to exceed the risk threshold: in, This represents the long-term risk gating threshold. This condition is used to ensure that the modified sample has a high long-term accident risk.

[0055] Third, there needs to be a sufficient difference between the median duration of similar accidents and the baseline prediction: in, This represents the difference gating threshold. This condition is used to determine whether the retrieved evidence provides valid information that differs from the base prediction. If the median duration of similar accidents is close to the base prediction, it indicates that the retrieved evidence is basically consistent with the base model's judgment, and no additional correction is needed.

[0056] Based on the above three collaborative constraints, a gating function is defined to indicate whether the current sample satisfies the correction conditions: in, This is an indicator function that takes the value 1 if the condition within the parentheses is true, and 0 otherwise. When, it indicates the first The accident satisfies the long-tail correction condition; when When this occurs, it indicates that the accident will not be corrected.

[0057] To further control the influence of local historical evidence from similar accidents on the basic prediction results, this invention constructs a modified weighting. This weight is determined by the reliability of local evidence, the intensity of long-term risk, and the intensity of prediction discrepancies.

[0058] Based on the degree of fluctuation in the duration distribution of similar accidents in their neighborhood, the reliability of the retrieved evidence is defined as follows: in, This indicates the reliability of evidence retrieved from similar incidents. When the duration differences within the neighborhood of similar incidents are small, Lower A higher value indicates more stable retrieval evidence; conversely, when the duration of neighboring regions varies greatly, the uncertainty of retrieval evidence increases, and its correction weight should be reduced accordingly.

[0059] Secondly, a fusion weight is constructed by combining the long-tail tendency of similar accident neighborhoods and the long-term risk probability of the current accident itself. Let... This indicates the proportion of similar accidents that lasted more than 120 minutes. Let the average long-term risk probability of a neighborhood of similar accidents be represented. Then, the neighborhood long-tail propensity score is defined as: Building upon this, the neighborhood long-tail tendency score is further combined with the risk probability of the current incident exceeding 120 minutes to obtain sample-level fusion weights: in,, This represents the clipping function.

[0060] For accidents that meet the gating conditions, the original correction term is constructed based on the difference between the median duration of similar accidents and the baseline prediction: in, Indicates the original correction term. The fusion coefficient controls the strength of the correction applied to the baseline prediction by the retrieved evidence. If the median duration of similar accidents is higher than the baseline prediction, the correction term is positive, indicating an upward adjustment for potentially underestimated long-term accidents; if the median duration of similar accidents is lower than the baseline prediction, the correction term is negative, indicating a downward adjustment for potentially overestimated accidents.

[0061] S54: Bounded correction.

[0062] To avoid over-correction due to evidence retrieval, the original correction terms are subject to bounded pruning: in, Indicates the final revision. This represents the maximum correction magnitude. This constraint limits the correction magnitude for a single sample to a reasonable range, thereby improving the stability of the model's predictions.

[0063] S6: Output of the predicted duration of the accident.

[0064] For a highway accident to be predicted, firstly, its structured feature vector is input, and the basic duration prediction value is obtained using the TabPFN basic predictor; secondly, the long-term risk probability of the accident exceeding different management thresholds is calculated based on the empirical residual distribution of the validation set; thirdly, local historical evidence is extracted based on the similar accident retrieval module; finally, the risk gating fusion and bounded correction module determines whether correction is needed, and outputs the final accident duration prediction result. Simultaneously, output the long-term risk probability of accidents exceeding different management thresholds: The output results can be used for highway traffic operation status assessment, accident impact range determination, long-term accident early warning, emergency response plan formulation, and rescue resource dispatch decision-making.

[0065] After completing model training and prediction output, in order to verify the application effect of the method of the present invention in the actual traffic accident duration prediction task, a test set was used to verify and analyze the model performance.

[0066] This invention sets up evaluation metrics from two aspects. The first type of metric is used to evaluate the regression prediction accuracy of accident duration, including Mean Absolute Error (MAE), Root Mean Square Error (RMSE), and Mean Absolute Percentage Error (MAPE). The second type of metric is used to evaluate the model's ability to identify long-term accidents. Using 60 minutes, 90 minutes, and 120 minutes as thresholds, the accident duration is converted into binary labels, and evaluated using precision, recall, and F1 score. The metrics are calculated as follows.

[0067] To verify the effectiveness of the method of this invention, a comparative experiment was conducted with traditional machine learning methods and deep learning methods. The specific comparison results are as follows.

[0068] (1) Overall prediction effect

[0069] (2) Interval prediction effect

[0070] (3) 60-minute threshold prediction effect

[0071] (4) 90-minute threshold prediction effect

[0072] (5) 120-minute threshold prediction effect

[0073] In summary, the method proposed in this invention demonstrates good performance in both accident duration prediction and long-term accident risk identification. Regarding overall prediction accuracy, this invention achieves lower MAE, RMSE, and MAPE, indicating that it can more accurately estimate the duration of highway accidents and effectively reduce duration prediction errors. In terms of long-term risk identification, this invention exhibits good risk discrimination ability and comprehensive classification performance at the three key thresholds of 60, 90, and 120 minutes. These results show that this invention can not only output accurate accident duration predictions but also provide reliable risk identification results for accidents exceeding key management thresholds, further supporting graded response to highway accidents, pre-positioning of clearing resources, and early warning of long-term accidents.

[0074] Example 2: This example provides a highway accident duration prediction system that implements the above prediction method. The system is deployed on the intelligent traffic control platform of the highway operation and management center and is connected to the highway historical accident database, real-time traffic monitoring system and emergency resource dispatch system. After receiving the accident report, it can output the duration prediction results and graded risk warning information in real time to support traffic control and emergency response decisions.

[0075] The system comprises a data preprocessing module for sequential data interaction, a TabPFN basic prediction module, a long-term risk estimation module, a similar accident retrieval module, a risk gating fusion module, and a result output module. The specific functions and execution processes of each module are as follows: 1. Data Preprocessing Module: This module accesses the original database of highway accidents, acquiring a full set of original accident records including spatiotemporal information, environmental conditions, vehicle composition, accident morphology, and traffic impact. The module first performs data cleaning, removing unqualified samples with severe missing data, abnormal temporal logic, or invalid target variables. Then, it performs unified encoding on categorical features, standardizes numerical features, and removes fields with the risk of information leakage. Next, it sets the accident duration as the prediction target, constructs a structured feature vector containing five dimensions: spatiotemporal, environmental, vehicle, accident, and traffic impact, and performs a logarithmic transformation on the target variable to mitigate the right-skewed distribution. Finally, it divides all samples into training, validation, and test sets according to a preset ratio, and outputs the divided datasets and structured feature vectors to the TabPFN basic prediction module, long-term risk estimation module, and similar accident retrieval module.

[0076] 2. TabPFN Basic Prediction Module: This module receives the training set output by the data preprocessing module and trains a TabPFN table regression model using the logarithmically transformed duration as the label, learning the global nonlinear mapping relationship between accident features and duration. After the model training is complete, it receives the structured feature vector of the accident to be predicted and outputs the basic prediction results at the logarithmic scale; after inverse exponential transformation and nonnegativity constraint processing, it obtains the basic duration prediction value at the minute scale, and outputs the prediction value to the long-term risk estimation module and the risk gating fusion module respectively.

[0077] 3. Long-term risk estimation module: This module receives the validation set output by the data preprocessing module and the basic prediction results of the validation set output by the TabPFN basic prediction module. It calculates the residual between the actual duration and the predicted value of each validation sample, and constructs a fixed set of empirical residuals. For the accident to be predicted, the module receives the basic duration prediction value output by the TabPFN basic prediction module, and successively superimposes the set of empirical residuals onto this prediction value to generate a simulated duration distribution of the accident to be predicted. Based on this distribution, it statistically obtains the long-term risk probability of the accident duration exceeding three management thresholds: 60 minutes, 90 minutes, and 120 minutes, and outputs the three levels of risk probabilities to the similar accident retrieval module and the risk gating fusion module, respectively.

[0078] 4. Similar Incident Retrieval Module: This module receives the training set output by the data preprocessing module and constructs it into a searchable historical accident database. For the accident to be predicted, the module simultaneously receives its structured feature vector and the long-term risk probability output by the long-term risk estimation module. It calculates the numerical feature distance, category feature distance, and long-term risk signal distance between the accident to be predicted and each sample in the historical accident database, and obtains the comprehensive similarity distance by weighted summation. After sorting the comprehensive distances from smallest to largest, a preset number of the most similar samples are selected to form a similar accident neighborhood. Statistical features such as the mean, median, high quantile, standard deviation, coefficient of variation, and proportion of long-term accidents within this neighborhood are extracted and combined to form a local historical evidence vector, which is then output to the risk gating fusion module.

[0079] 5. Risk Gating Fusion Module: This module simultaneously receives the base duration prediction value output by the TabPFN base prediction module, the long-term risk probability output by the long-term risk estimation module, and the local historical evidence vector output by the similar accident retrieval module. The module first determines whether the predicted accident needs correction through three gating conditions: first, checking whether the base prediction value enters the long-tail candidate interval; second, checking whether the long-term risk probability is higher than the risk gating threshold; and third, checking whether the difference between the median duration of similar accidents and the base prediction value is higher than the difference gating threshold.

[0080] If all three conditions are met, the module calculates the reliability of evidence and the long-tail tendency score based on local historical evidence, and obtains a correction weight by combining the long-term risk probability of the event to be predicted. It constructs an original correction term based on the difference between the median duration of similar events and the baseline prediction value, and performs bounded pruning by a preset maximum correction magnitude. The final correction term is then superimposed on the baseline prediction value to obtain the final duration prediction value. If the correction conditions are not met, the baseline duration prediction value is directly used as the final prediction result. The module outputs the final duration prediction value to the result output module.

[0081] 6. Result Output Module: This module receives the final duration prediction value from the risk gating fusion module and the three-level long-term risk probability from the long-term risk estimation module, and outputs it in a formatted manner according to the interface specifications of the traffic control platform. The output results can be simultaneously pushed to the accident early warning subsystem, emergency dispatch subsystem, and road condition release subsystem for long-term accident graded early warning, rescue resource pre-positioning, congestion propagation prediction, and public travel information dissemination.

[0082] When the system is running, it can achieve a second-level prediction response after an accident is reported, without the need for tedious manual feature engineering and parameter tuning. At the same time, relying on the pre-training prior and gating correction mechanism of the basic model, it can achieve stable prediction results with only a small amount of local data fine-tuning when deployed across road sections and regions, and has strong engineering implementation and promotion value.

[0083] Finally, any aspects not fully described in this invention utilize existing mature products and technologies.

[0084] The present invention and its embodiments have been described above. This description is not restrictive, and the accompanying drawings are only one embodiment of the present invention; the actual structure is not limited thereto. In conclusion, if those skilled in the art are inspired by this description and design similar structures and embodiments without departing from the spirit of the invention, such designs should fall within the protection scope of the present invention.

Claims

1. A method for predicting the duration of a highway accident, characterized in that, Includes the following steps: S1: Obtain raw data of highway accidents, clean the raw data, encode categorical variables and standardize numerical variables, set the accident duration as the prediction target, and construct a structured feature vector of accidents containing multi-dimensional features. The target variable is logarithmically transformed to mitigate the influence of the right skewed distribution, and then divided into training set, validation set and test set according to a preset ratio to form the accident dataset; S2: Train a TabPFN table regression model based on the training set as a basic predictor, and learn the global mapping relationship between accident features and duration through the basic predictor; input the structured feature vector of the accident to be predicted into the basic predictor, and after exponential inverse transformation and non-negativity constraint processing, obtain the basic duration prediction value of the accident to be predicted. S3: Based on the predicted base duration and the actual duration of each sample in the validation set, calculate the validation residual and construct an empirical residual set; superimpose the empirical residual set one by one onto the predicted base duration of the accident to be predicted to generate a simulated duration distribution of the accident to be predicted; based on the simulated duration distribution, statistically obtain the long-term risk probability that the duration of the accident to be predicted exceeds each preset management threshold. S4: Construct a historical accident database using accident samples from the training set. Combine the structured features and long-term risk probability of the accident to be predicted to calculate the comprehensive similarity distance between the accident to be predicted and each sample in the historical accident database. Sort the samples by comprehensive similarity distance from smallest to largest and select the first preset number of samples to form a similar accident neighborhood. Extract the multi-dimensional duration statistical features of the similar accident neighborhood and combine them to form a local historical evidence vector. S5: Based on the predicted base duration of the accident to be predicted, the long-term risk probability, and the local historical evidence vector, determine whether the accident to be predicted meets the long-tail correction condition; if the correction condition is met, calculate the correction weight and construct the fusion correction term, and adjust the predicted base duration after bounded pruning constraints to obtain the final predicted duration. If the correction conditions are not met, the base duration prediction value will be used directly as the final duration prediction value. S6: Output the predicted final duration of the accident to be predicted, and the corresponding long-term risk probability exceeding each preset management threshold.

2. The method for predicting the duration of highway accidents according to claim 1, characterized in that: In step S1, the structured feature vector includes five dimensions: spatiotemporal features, environmental features, vehicle features, accident features, and traffic impact features. The target variable is logarithmically transformed to alleviate the impact of the right-skewed distribution on model training. In the prediction stage, the time scale is restored to the minute level through exponential inverse transformation, and non-negativity constraints are applied to the inverse transformation results.

3. The method for predicting the duration of highway accidents according to claim 1, characterized in that: In step S3, the empirical residual set is calculated only from the validation set and remains fixed during the testing and prediction phases, without participating in parameter updates; the preset management threshold includes at least three levels: 60 minutes, 90 minutes, and 120 minutes, corresponding to the output of three levels of long-term risk probabilities.

4. The method for predicting the duration of highway accidents according to claim 1, characterized in that: In step S4, the comprehensive similarity distance is obtained by weighted combination of numerical feature distance, category feature distance and long-term risk signal distance, and the Gower distance metric is used to adapt to both numerical and category features. The long-term risk signal distance is calculated based on the long-term risk probability of an accident exceeding 120 minutes.

5. The method for predicting the duration of highway accidents according to claim 1, characterized in that: In step S4, the multi-dimensional duration statistical features include the mean, median, high quantile, standard deviation, and coefficient of variation of similar accident durations, as well as the proportion of long-duration accidents in the neighborhood of similar accidents.

6. The method for predicting the duration of highway accidents according to claim 1, characterized in that: In step S5, the long-tail correction condition simultaneously satisfies three constraints: First, the predicted base duration falls within the preset long-tail candidate range; Second, the long-term risk probability of the accident to be predicted is higher than the preset risk threshold. Third, the difference between the median duration and the predicted baseline duration in the neighborhood of similar accidents is higher than the preset difference gating threshold.

7. The method for predicting the duration of highway accidents according to claim 1, characterized in that: In step S5, the correction weight is calculated by the evidence reliability of the neighborhood of similar accidents, the long-tail tendency score of the neighborhood, and the long-term risk probability of the accident to be predicted itself. The fusion correction term is constructed based on the difference between the median duration of similar accidents and the basic predicted value. The correction term is bounded by a preset maximum correction magnitude to limit the range of correction magnitude for a single sample.

8. A highway accident duration prediction system, characterized in that, include: The data preprocessing module is used to acquire raw data of highway accidents, perform data cleaning, feature encoding, target variable transformation and dataset partitioning operations, and output an accident dataset containing structured feature vectors. The TabPFN basic prediction module is used to train a tabular regression model based on the training set, learn the global mapping relationship between accident features and duration, and output the basic duration prediction value of the accident to be predicted. The long-term risk estimation module is used to construct an empirical residual set based on the prediction residuals of the validation set, generate the simulated duration distribution of the accident to be predicted, and statistically output the long-term risk probability that exceeds the multi-level management threshold. The similar accident retrieval module is used to build a historical accident database with the training set, calculate the comprehensive similarity distance by combining scene features and risk signals, retrieve the neighborhood of similar accidents and extract local historical evidence vectors. The risk gating fusion module is used to determine the correction conditions based on the basic duration prediction value, long-term risk probability and local historical evidence vector, perform bounded correction on samples that meet the conditions, and output the final duration prediction value. The results output module is used to output the final predicted duration value and the long-term risk probability corresponding to each level threshold.

9. The highway accident duration prediction system according to claim 8, characterized in that: The similar accident retrieval module uses a weighted Gaussian distance metric to calculate the similarity distance between samples by combining differences in numerical features, differences in category features, and differences in long-term risk signals, and retrieves a preset number of the most similar historical accidents.

10. The highway accident duration prediction system according to claim 8, characterized in that: The risk gating fusion module is equipped with triple gating judgment conditions and maximum correction range constraints. It only performs prediction correction on long-tail candidate samples that simultaneously meet the gating conditions, and retains the basic prediction results for short-term accidents that do not meet the conditions.