A traffic accident risk prediction method and related apparatus
By employing dual heterogeneous graph neural networks and dynamic hypergraph convolution techniques, the problems of integrating multi-source heterogeneous data and modeling high-order relationships were solved, enabling accurate prediction and decision support for traffic risks, and improving the efficiency and safety of traffic management.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HAINAN UNIV
- Filing Date
- 2026-05-15
- Publication Date
- 2026-07-24
AI Technical Summary
Existing technologies face challenges in integrating multi-source heterogeneous data, lack the ability to model high-order relationships, and suffer from a disconnect between spatiotemporal features and high-order correlation features, resulting in insufficient accuracy in traffic risk prediction.
We employ a dual heterogeneous graph neural network (DHGNN), dynamic hypergraph convolution, and a spatiotemporal dual cross-attention mechanism to achieve dual feature encoding of heterogeneous entity nodes and associated hyperedges, construct a temporal knowledge hypergraph, and perform feature fusion and optimization.
It achieves unified representation of multi-source heterogeneous traffic data, improves the accuracy of traffic risk prediction and decision-making precision in complex scenarios, and enhances the accuracy of traffic risk assessment and congestion trend prediction.
Smart Images

Figure CN122453162A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of intelligent transportation technology, and in particular to a method and related apparatus for predicting traffic accident risks. Background Technology
[0002] Today, the number of motor vehicles and the mileage of roads are continuously increasing. While the coverage and efficiency of the road traffic network are constantly improving, the distribution range, evolution speed, and control difficulty of road traffic risks are also rising simultaneously. This has become a prominent issue threatening the safety of people's lives and property, disrupting normal traffic management order, and hindering the high-quality development of the transportation industry. The hidden, sudden, and interconnected nature of road traffic risks not only increases the safety hazards for the public but also burdens traffic management departments with risk investigation, early warning, and control. Furthermore, it places higher demands on the refinement, intelligence, and forward-looking nature of road traffic governance. Therefore, constructing an efficient and precise traffic risk prevention and control decision-making system, providing scientific and timely guidance for risk investigation, early warning, and control decisions, has significant social value and practical significance for improving the modernization level of road traffic management, preventing and mitigating road traffic risks, reducing the traffic accident rate, and ensuring public travel safety and smooth road traffic.
[0003] With the deep application of big data technology and the iterative upgrading of artificial intelligence algorithms, utilizing massive amounts of historical traffic accident data, road environment data, traffic operation data, and time-series correlation data to deeply explore the generation patterns, causal mechanisms, and evolutionary characteristics of road traffic risks, and achieving accurate assessment, early warning, hierarchical control, and scientific decision-making regarding traffic risks, has become an important direction for the construction of intelligent transportation systems and the modernization of road traffic governance capabilities. A data-driven intelligent traffic risk prevention and control decision-making system can not only monitor road traffic operation status in real time and quickly capture risk and hazard signals, but also provide multi-dimensional decision-making basis and solution support for traffic risk prevention and control based on historical data and real-time information. This intelligent prevention and decision-making capability can help traffic management departments to identify risks and hazards in advance, accurately issue early warning information, optimize the allocation of prevention and control police forces, the layout of prevention and control resources, and road segment control strategies, thereby significantly improving the efficiency and accuracy of traffic risk prevention and control, effectively preventing traffic accidents and reducing their harmful consequences. Furthermore, scientific traffic risk prevention and control decision-making guidance can also help traffic management departments summarize accident handling experience, improve emergency response plans, optimize the layout of road traffic safety prevention and control, and further enhance the resilience of the road traffic system and its ability to respond to emergencies.
[0004] However, existing technologies still have drawbacks:
[0005] 1. Difficulty in integrating multi-source heterogeneous data: Traffic data contains structured, semi-structured and unstructured information. Existing models lack effective multimodal feature fusion and unified coding mechanisms, and cannot make full use of traffic information across all dimensions. They often can only process single-type data or achieve shallow feature splicing, resulting in information silos and restricting the inference accuracy of subsequent models.
[0006] 2. Insufficient ability to model high-order relationships: Traditional graph neural networks can only capture pairwise binary relationships between entities such as roads, events, and environments, and cannot model multi-segment collaborative congestion, multi-factor joint influence, and other multi-dimensional high-order interactions; existing hypergraph solutions mostly adopt static fixed structures, which cannot adapt to the temporal dynamic changes of traffic scenarios, and are difficult to capture the real-time evolution of traffic risks, which seriously restricts the decision-making accuracy in complex traffic scenarios.
[0007] 3. The spatiotemporal features and higher-order correlation features are separated, and the fusion of multi-dimensional features is insufficient: Existing time-series traffic prediction models mostly adopt a parallel architecture of time and space dual attention, which cannot achieve deep cross-fusion of time-series features and spatial topological features, resulting in the separation of spatiotemporal features; at the same time, they cannot deeply coordinate the dual correlation features of heterogeneous entities, the higher-order correlation features of hypergraphs and the temporal dependency features, and cannot fully explore the multi-dimensional interactive features of traffic risk causes. The feature representation ability is insufficient, which ultimately leads to the accuracy of traffic risk assessment and congestion situation prediction failing to meet the actual management and control needs. Summary of the Invention
[0008] To address the aforementioned technical problems, this invention proposes a traffic accident risk prediction method and related apparatus. By synergistically fusing Dual Heterogeneous Graph Neural Network (DHGNN), dynamic hypergraph convolution, spatiotemporal-dual cross attention, and temporal knowledge hypergraph, it achieves accurate assessment and interpretable decision-making regarding traffic risks.
[0009] To achieve the above objectives, the technical solution of the present invention is as follows:
[0010] A method for predicting traffic accident risks includes the following steps:
[0011] Acquire multi-source heterogeneous traffic data and perform preprocessing;
[0012] Based on the preprocessed multi-source heterogeneous traffic data, a dual heterogeneous graph neural network is used to perform dual feature encoding of heterogeneous entity nodes and associated hyperedges to obtain the features of heterogeneous entity nodes and the association features of heterogeneous hyperedges.
[0013] A temporal knowledge hypergraph is constructed based on heterogeneous entity node features and associated hyperedge features, and the node embedding in the temporal knowledge hypergraph is optimized based on dynamic hypergraph convolution to obtain heterogeneous features of the hypergraph.
[0014] Using the hypergraph heterogeneous features optimized by dynamic hypergraph convolution as input, the feature weights are adjusted from the temporal dimension and the heterogeneous entity dimension through the spatiotemporal duality cross-attention mechanism to obtain spatiotemporal cross-fusion features; the hypergraph heterogeneous features and the spatiotemporal cross-fusion features are cross-fused to obtain comprehensive features;
[0015] Traffic accident risk prediction is based on the aforementioned comprehensive features.
[0016] Preferably, the preprocessing includes removing outliers, missing values, or duplicate values.
[0017] Preferably, a dual heterogeneous graph neural network is used to perform dual feature encoding of heterogeneous entity nodes and associated hyperedges to obtain heterogeneous entity node features and heterogeneous hyperedge association features, including the following steps:
[0018] The formula for feature mapping of heterogeneous entity nodes is defined as follows:
[0019]
[0020] In the formula, heterogeneous nodes Features of heterogeneous entity nodes extracted by DHGNN heterogeneous nodes The corresponding original multi-source heterogeneous features, The feature mapping weight matrix for heterogeneous nodes. For the feature mapping bias term of heterogeneous nodes, It is a non-linear activation function;
[0021] The formula for heterogeneous hyperedge correlation feature mapping is defined as follows:
[0022]
[0023] In the formula, heterogeneous hyperedge Heterogeneous hyperedge correlation features extracted by DHGNN heterogeneous hyperedge The corresponding heterogeneous association characteristics, The weight matrix for the eigenmap of heterogeneous hyperedges. This is the bias term for the heterogeneous hyperedge feature map.
[0024] Preferably, constructing a temporal knowledge hypergraph based on heterogeneous entity node features and associated hyperedge features includes the following steps:
[0025] The formula for feature mapping of heterogeneous nodes in a temporal knowledge hypergraph is defined as follows:
[0026]
[0027] In the formula, For the embedding feature vectors of heterogeneous nodes in the hypergraph, These are the features of the heterogeneous entity nodes corresponding to the heterogeneous nodes. The feature mapping weight matrix for heterogeneous nodes. For bias terms;
[0028] The formula for the feature mapping of heterogeneous hyperedges in a temporal knowledge hypergraph is defined as follows:
[0029]
[0030] In the formula, For the embedding feature vector of the heterogeneous hyperedge, Let be the set of heterogeneous nodes connected by heterogeneous hyperedges. Let be the size of the heterogeneous node set. It is the weight matrix of the heterogeneous hyperedge feature mapping.
[0031] Preferably, the node embedding in the temporal knowledge hypergraph is optimized based on dynamic hypergraph convolution to obtain heterogeneous features of the hypergraph, including the following steps:
[0032] The formula for dynamic hypergraph convolution is defined as follows:
[0033]
[0034] In the formula, For the first The heterogeneous features of the hypergraph after dynamic hypergraph convolution optimization at each time step. For containing heterogeneous nodes The set of superedges The heterogeneous convolution weight matrix, This is the self-connection weight matrix for heterogeneous nodes. For the first Always Beyond the Edge heterogeneous nodes The association weight is updated using the following formula:
[0035] .
[0036] Preferably, using the heterogeneous features of the hypergraph optimized by dynamic hypergraph convolution as input, the feature weights are adjusted from the temporal dimension and the heterogeneous entity dimension through a spatiotemporal-dual cross-attention mechanism to obtain spatiotemporal cross-fusion features, including the following steps:
[0037] The formula for calculating the temporal-aware attention weight in the spatiotemporal-dual cross-attention mechanism is as follows:
[0038]
[0039] In the formula, For the first Temporal attention weights at each moment This is the temporal attention query vector;
[0040] The temporal features are calculated based on time-aware attention weights, using the following formula:
[0041]
[0042] In the formula, These are the aggregated temporal features;
[0043] The formula for calculating the attention weights for duality perception is as follows:
[0044]
[0045] In the formula, heterogeneous nodes Heterogeneous nodes with neighbors Duality attention weights heterogeneous nodes The set of neighboring nodes, This is the attention weight matrix for dual relations; Neighboring heterogeneous nodes Hypergraph heterogeneous features optimized by dynamic hypergraph convolution; To connect heterogeneous nodes Heterogeneous nodes with neighbors The heterogeneous hyperedge correlation features corresponding to the hyperedges
[0046] The duality-aware attention weights are used to calculate duality features, as shown in the following formula:
[0047]
[0048] In the formula, The dual relation features after aggregation.
[0049] Based on temporal and duality features, spatiotemporal cross-fusion features are obtained, as shown in the following formula:
[0050]
[0051] In the formula, For the first The spatiotemporal cross-fusion characteristics of time, This is a spatiotemporal cross-weight matrix used to achieve deep cross-interaction between temporal features and duality features. The weight matrix and bias terms of the fusion layer;
[0052] The heterogeneous features of the hypergraph and the spatiotemporal cross-fusion features are cross-fused to obtain a comprehensive feature, as shown in the following formula:
[0053]
[0054] In the formula, For the first Time Node The comprehensive characteristics, For the first Hypergraph heterogeneous features optimized by time-varying dynamic hypergraph convolution. To fix the fusion weight coefficients, satisfy ; Learnable weight matrix for feature interaction; It represents the Hadamardi (or Hadama) stack.
[0055] Preferably, the traffic accident risk prediction is based on the comprehensive features, using the following formula:
[0056]
[0057] In the formula, This represents the probability of an accident occurring on the target road section. To predict the weight matrix, To predict the bias term, This is the activation function.
[0058] Based on the above, the present invention also discloses a traffic accident risk prediction system, comprising:
[0059] The acquisition module is used to acquire multi-source heterogeneous traffic data and perform preprocessing.
[0060] The feature extraction module is used to obtain the features of heterogeneous entity nodes and the association features of heterogeneous hyperedges by using dual heterogeneous graph neural networks to perform dual feature encoding of heterogeneous entity nodes and associated hyperedges based on preprocessed multi-source heterogeneous traffic data.
[0061] An optimization module is constructed to build a temporal knowledge hypergraph based on heterogeneous entity node features and associated hyperedge features, and to optimize the node embedding in the temporal knowledge hypergraph based on dynamic hypergraph convolution to obtain heterogeneous features of the hypergraph.
[0062] The fusion module is used to take the heterogeneous features of the hypergraph optimized by dynamic hypergraph convolution as input, and adjust the feature weights from the temporal dimension and the heterogeneous entity dimension through the spatiotemporal duality cross attention mechanism to obtain spatiotemporal cross-fusion features; and cross-fuse the hypergraph heterogeneous features and the spatiotemporal cross-fusion features to obtain comprehensive features.
[0063] The prediction module is used to predict traffic accident risks based on the comprehensive features.
[0064] Based on the foregoing, the present invention also discloses a computer device, comprising: a memory for storing a computer program; and a processor for executing the computer program to implement any of the methods described above.
[0065] Based on the above, the present invention also discloses a readable storage medium storing a computer program, which, when executed by a processor, implements any of the methods described above.
[0066] Based on the above technical solution, the beneficial effects of the present invention are:
[0067] 1) To address the shortcomings of existing technologies in integrating multi-source heterogeneous data, this invention employs a dual heterogeneous graph neural network (DHGNN) to complete the dual feature encoding of heterogeneous entity nodes and associated hyperedges, thereby achieving a unified representation of multi-source heterogeneous traffic data, breaking down information silos, and providing full-dimensional feature support for subsequent modeling.
[0068] 2) To address the shortcomings of existing technologies in modeling high-order relationships, this invention constructs a temporal knowledge hypergraph model, which combines a temporally driven dynamic hyperedge generation and pruning mechanism to achieve accurate modeling of diverse high-order interaction relationships in traffic scenarios. At the same time, it dynamically adapts to the temporal evolution of traffic states, significantly improving decision-making accuracy in complex scenarios.
[0069] 3) To address the shortcomings of existing technologies, such as the separation of spatiotemporal features and high-order correlation features, and the insufficient fusion of multi-dimensional features, this invention constructs a spatiotemporal-dual relationship cross-attention mechanism to replace the traditional dual attention mechanism. This mechanism achieves deep cross-fusion of temporal features and high-order correlation features of the hypergraph, generating more representative comprehensive features and further improving the accuracy of traffic risk assessment and congestion prediction. Attached Figure Description
[0070] Figure 1 This is a schematic diagram of a traffic accident risk prediction method in one embodiment. Detailed Implementation
[0071] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention.
[0072] like Figure 1 As shown in the figure, this embodiment provides a method for predicting traffic accident risks, including the following steps:
[0073] Step 1: Acquire multi-source heterogeneous traffic data and perform preprocessing.
[0074] In this embodiment, multi-source heterogeneous traffic data is collected, including structured data, semi-structured data, and unstructured data, as follows:
[0075] Structured data includes six major categories: traffic operation status (traffic flow, vehicle speed, traffic density, congestion level, intersection queue length, signal timing scheme), road infrastructure (segment information, segment length, number of lanes, road grade, slope, curvature, traffic light location, parking lot entrances and exits), basic traffic accident information (detailed traffic accident records (implicitly including time, location, type, severity, number of casualties, historical accident frequency), accident statistics), meteorology and environment (weather conditions, temperature, precipitation, wind speed, visibility, road surface slipperiness, warning level), traffic control (control start and end time, controlled road sections, construction road occupation duration), and sensor and floating car basic data (monitoring images, geomagnetic flow data, floating car GPS coordinates, driving speed).
[0076] Semi-structured data includes five major categories: detailed records of traffic accidents (accident scene investigation records, accident determination reports, insurance claim reports), traffic incident logs (event records from traffic command centers, 122 emergency call records), traffic control announcements (government-issued control notices, construction notices), weather forecast messages (structured + text hybrid weather forecast documents), and Hainan regional characteristic data (tourist attraction visitor flow forecasts, port ferry scheduling logs, and major event support plans).
[0077] Unstructured data includes four main categories: video and image data (surveillance footage, checkpoint images, accident scene photos), free text data (social media traffic sentiment, netizens' travel feedback, news reports on traffic events), audio data (traffic radio broadcasts, 122 emergency call recordings), and Hainan regional characteristic data (typhoon on-site monitoring videos, coastal road wave impact videos, scenic area crowd monitoring videos).
[0078] The collected multi-source heterogeneous traffic data is preprocessed, including removing outliers, missing values or duplicate values, and completing the spatiotemporal alignment and standardization of the data.
[0079] Step 2: Based on the preprocessed multi-source heterogeneous traffic data, a dual heterogeneous graph neural network is used to perform dual feature encoding of heterogeneous entity nodes and associated hyperedges to obtain the features of heterogeneous entity nodes and the associated features of heterogeneous hyperedges.
[0080] In this embodiment, structured data from a Hainan urban traffic scenario is standardized and embedded to generate initial features for heterogeneous entity nodes. Semi-structured data is used to supplement node features after parsing, and also to generate heterogeneous association features. After standardization and embedding mapping, unstructured data can be used to supplement node features and construct hyperedge association features. This invention innovatively introduces a dual heterogeneous graph neural network (DHGNN) to complete the dual feature encoding of heterogeneous entity nodes and associated hyperedges, generating a fusion feature set with node-hyperedge dual attributes and heterogeneous features. This breaks through the limitations of the universality of traditional dual structures, improves the representation ability of complex traffic data, and adapts to the processing needs of multi-source heterogeneous traffic data in Hainan cities.
[0081] This paper standardizes and embeds structured traffic data (traffic flow, speed, road segment attributes, weather indicators, accident statistics, etc., including traffic data specific to Hainan) and performs feature encoding and dimension alignment on unstructured data (surveillance images, text records, etc.). A Dual Heterogeneous Graph Neural Network (DHGNN) is used to perform dual feature encoding of heterogeneous entity nodes and relational hyperedges. The network adopts a node-hyperedge dual parallel architecture, containing two independent encoding branches: a heterogeneous node encoding branch and a heterogeneous hyperedge encoding branch. These branches model the individual attributes of traffic entities and the relationships between entities, respectively, solving the problem that relational features are dominated by node features in traditional hypergraph models. The two encoding branches use the same network structure but independent learnable parameters, mapping the original features of heterogeneous nodes and heterogeneous hyperedges to the same-dimensional feature space, outputting heterogeneous entity node features. Correlation features with heterogeneous hyperedges These two features together constitute a dual heterogeneous fusion feature set, providing a complete "entity-relationship" binary representation for the subsequent construction of a temporal knowledge hypergraph.
[0082] The feature mapping formula for heterogeneous entity nodes in the heterogeneous node encoding branch is defined as follows:
[0083]
[0084] In the formula, heterogeneous nodes Features of heterogeneous entity nodes extracted by DHGNN heterogeneous nodes The initial characteristics of the corresponding heterogeneous entity nodes (including characteristics related to the transportation characteristics of Hainan region). The feature mapping weight matrix for heterogeneous nodes. For the feature mapping bias term of heterogeneous nodes, It is a non-linear activation function (using the ReLU function).
[0085] The formula for the heterogeneous hyperedge correlation feature mapping in the heterogeneous hyperedge coding branch is defined as follows:
[0086]
[0087] In the formula, heterogeneous hyperedge Heterogeneous hyperedge correlation features extracted by DHGNN heterogeneous hyperedge The corresponding heterogeneous association characteristics, The weight matrix for the eigenmap of heterogeneous hyperedges. For the heterogeneous hyperedge feature mapping bias term, It is a non-linear activation function (using the ReLU function).
[0088] By interactively fusing heterogeneous node features and heterogeneous hyperedge association features, a unified set of dual heterogeneous fusion features is formed, providing feature inputs containing high-order association attributes and heterogeneous features for subsequent temporal knowledge hypergraph modeling, thus adapting to the association modeling needs of heterogeneous entities in Hainan's urban transportation.
[0089] Step 3: Construct a temporal knowledge hypergraph based on heterogeneous entity node features and associated hyperedge features, and optimize the node embedding in the temporal knowledge hypergraph based on dynamic hypergraph convolution to obtain heterogeneous features of the hypergraph.
[0090] In this embodiment, based on the dual heterogeneous fusion feature set, a heterogeneous entity set and a relation set are defined in the field of urban transportation in Hainan. The entities include heterogeneous entities such as road segments, vehicles, weather, and accident types, and the relations include temporal associations, higher-order associations, and heterogeneous associations between entities, which fully integrates the regional transportation association characteristics of Hainan.
[0091] A temporal knowledge hypergraph structure is constructed, including a node layer and a hyperedge layer. The node layer corresponds to various heterogeneous entities in the urban transportation field of Hainan, and the hyperedge layer corresponds to the multi-dimensional associations between heterogeneous entities, realizing the dual representation of heterogeneous entities and associations.
[0092] The dual heterogeneous fusion feature set is mapped to the nodes and hyperedges of the temporal knowledge hypergraph, and a corresponding feature vector is assigned to each heterogeneous node and hyperedge. The hypergraph training algorithm is adopted, combined with the characteristics of Hainan urban traffic data, and the hypergraph structure and feature parameters are iteratively optimized to capture the temporal dependency relationship and high-order association features between heterogeneous entities. Finally, a basic representation model that can characterize the association of multi-source heterogeneous information in Hainan urban traffic is generated.
[0093] The formula for feature mapping of heterogeneous nodes in a temporal knowledge hypergraph is defined as follows:
[0094]
[0095] In the formula, For the embedding feature vectors of heterogeneous nodes in the hypergraph, These are the dual heterogeneous features corresponding to heterogeneous nodes. The feature mapping weight matrix for heterogeneous nodes. For bias terms, The activation function is ReLU.
[0096] The formula for the feature mapping of heterogeneous hyperedges in a temporal knowledge hypergraph is defined as follows:
[0097]
[0098] In the formula, For the embedding feature vector of the heterogeneous hyperedge, Let be the set of heterogeneous nodes connected by heterogeneous hyperedges. Let be the size of the heterogeneous node set. It is the weight matrix of the heterogeneous hyperedge feature mapping.
[0099] In this embodiment, a time-driven dynamic hyperedge generation and pruning mechanism is introduced. This mechanism uses 1 minute as the minimum time step and extracts heterogeneous hyperedge association features in real time based on three types of data (structured, semi-structured and unstructured data). Based on the heterogeneous hyperedge association features, the hyperedge set of the time-series knowledge hypergraph is dynamically updated, so that the hypergraph structure can dynamically adapt to the evolution of traffic conditions in Hainan cities.
[0100] Dynamic hyperedge generation and pruning mechanisms based on heterogeneous hyperedge association features The core criterion is as follows: when extracting relationships between entities from new input data, corresponding heterogeneous hyperedge association features are generated through DHGNN encoding. If heterogeneous hyperedge correlation features If the L2 norm exceeds the generation threshold (set to 0.6), a new hyperedge is generated; for existing hyperedges, their corresponding heterogeneous hyperedge association features are updated in real time. If heterogeneous hyperedge correlation features If the L2 norm is below the pruning threshold (set to 0.1) for 5 consecutive time steps, it is considered an invalid hyperedge and is pruned.
[0101] A dynamic hypergraph convolution operator is used to perform convolution operations on the features of heterogeneous nodes in the hypergraph. By aggregating the feature information of heterogeneous nodes connected by hyperedges and combining the dynamically updated weights of hyperedges, the embedding representation of heterogeneous nodes is optimized, thereby enhancing the model's ability to capture dynamic changes in urban traffic conditions in Hainan.
[0102] The formula for dynamic hypergraph convolution is defined as follows:
[0103]
[0104] In the formula, For the first The heterogeneous features of the hypergraph after dynamic hypergraph convolution optimization at each time step. For containing heterogeneous nodes The set of superedges The heterogeneous convolution weight matrix, This is the self-connection weight matrix for heterogeneous nodes. For the first Always Beyond the Edge heterogeneous nodes The association weights (dynamically generated by an adaptive hyperedge update mechanism combined with Hainan's transportation characteristics) are updated using the following formula:
[0105]
[0106] In the formula, the association weights between the hyperedge and heterogeneous nodes are normalized by the Softmax function. Combined with the characteristics of traffic changes in Hainan, the hyperedge weights are dynamically and adaptively adjusted to adapt to the temporal changes in traffic conditions in Hainan.
[0107] Step 4: Using the hypergraph heterogeneous features optimized by dynamic hypergraph convolution as input, the feature weights are adjusted from the temporal dimension and the heterogeneous entity dimension through the spatiotemporal duality cross-attention mechanism to obtain spatiotemporal cross-fusion features. The hypergraph heterogeneous features and the spatiotemporal cross-fusion features are then cross-fused to obtain comprehensive features.
[0108] In this embodiment, a spatiotemporal-dual relationship cross-attention architecture (temporal-aware attention + dual-relationship-aware attention + spatiotemporal cross-fusion) is constructed. Temporal-aware attention is used to assign weights to Hainan's urban traffic features in the temporal dimension, strengthening the feature weights of key time nodes (such as morning and evening rush hours, holidays, and periods of severe weather) and weakening the interference of irrelevant time nodes. Dual-relationship-aware attention is used to capture the correlation weights between heterogeneous entities in Hainan's urban traffic, strengthening key correlations and weakening redundant correlations, focusing on the core correlation characteristics of Hainan's regional traffic. Spatiotemporal cross-fusion solves the problem of spatiotemporal feature fragmentation in the traditional dual-attention mechanism by using temporal features and spatial features as queries and keys for cross-retrieval, and achieves deep integration of temporal information and spatial correlation information.
[0109] The features output by the spatiotemporal-dual cross-attention mechanism are cross-fused with the hypergraph features optimized by dynamic hypergraph convolution (the core operator of hypergraph neural networks). Through feature concatenation and weighted summation, a comprehensive feature integrating temporal, spatial, dual, and higher-order relational information is generated. This provides more comprehensive feature support for decision-making inference in the hypergraph neural network output layer, adapting to the spatiotemporal characteristics of urban traffic in Hainan. The formulas for calculating the weights of temporal-aware attention and dual-aware attention, and for feature fusion, are as follows:
[0110] Time-aware attention weight calculation:
[0111]
[0112] In the formula, For the first Temporal attention weights for time-series perception (adapted to the temporal characteristics of traffic in Hainan). For the temporal attention query vector, This represents the timing length.
[0113] Temporal feature aggregation:
[0114]
[0115] In the formula, The aggregated temporal features retain the core information on the temporal changes of urban traffic in Hainan.
[0116] Duality-based attention weight calculation (used to capture the weights of relationships between heterogeneous traffic entities):
[0117]
[0118] In the formula, heterogeneous nodes Heterogeneous nodes with neighbors Duality attention weights heterogeneous nodes The set of neighboring nodes, This is a dual-relation attention weight matrix used to mine the correlation strength between heterogeneous entities in Hainan's urban transportation, highlighting regionally distinctive correlations. Neighboring heterogeneous nodes Hypergraph heterogeneous features optimized by dynamic hypergraph convolution; To connect heterogeneous nodes Heterogeneous nodes with neighbors The heterogeneous hyperedge correlation features corresponding to the hyperedge.
[0119] Dual relation feature aggregation:
[0120]
[0121] In the formula, The aggregated dual relationship features can highlight the important relationships between heterogeneous entities in Hainan's urban transportation system and weaken redundant relationship interference.
[0122] Spatiotemporal cross-fusion feature generation:
[0123]
[0124] In the formula, For the first The spatiotemporal cross-fusion characteristics of time, This is a spatiotemporal cross-weight matrix used to achieve deep cross-interaction between temporal features and duality features. Here are the weight matrix and bias terms for the fusion layer. This is the ReLU activation function.
[0125] Comprehensive Feature Fusion:
[0126] In the formula, For the first Time Node The comprehensive characteristics, For the first Hypergraph heterogeneous features optimized by time-varying dynamic hypergraph convolution. To fix the fusion weight coefficients, satisfy This is used to balance the proportion of spatiotemporal correlation information and higher-order hypergraph correlation information; Learnable weight matrix for feature interaction ( (where is the feature vector dimension), used to perform linear transformation on the element-wise interaction terms of spatiotemporal cross features and hypergraph features, enhancing the nonlinear correlation between features; It represents the Hadamardi (or Hadama) stack.
[0127] Step 5: Based on the comprehensive features, predict the risk of traffic accidents.
[0128] In this embodiment, for traffic accident risk prediction, based on the correlation obtained through reasoning, the probability of an accident occurring, the risk level, and the scope of impact are output; for traffic decision-making, combined with the congestion situation prediction results, the optimal traffic diversion plan, road segment control suggestions, and other decision information are output.
[0129] The formula for predicting the probability of traffic accident risk is defined as follows:
[0130]
[0131] In the formula, The probability of an accident occurring on the target road segment (range 0 to 1). To predict the weight matrix, To predict the bias term, The activation function maps the output to a probability interval. This formula, as the core prediction formula of the hypergraph neural network output layer, directly determines the accuracy of the prediction result.
[0132] Congestion prediction is optimized using a mean squared error loss function, the formula of which is:
[0133]
[0134] In the formula, To predict the loss due to congestion, where N is the sample size. These are congestion prediction values (such as traffic flow and speed deviation). The loss function, representing the true value of the congestion situation, is used for parameter optimization of the hypergraph neural network and, together with the accident prediction loss, constitutes the total model loss. A systematic evaluation of the hypergraph neural network's decision-making and prediction results is conducted, including error analysis and accuracy analysis, to determine the model's reliability. Based on the evaluation results, the model parameters are iteratively optimized to achieve a closed-loop iterative process for traffic risk prevention and control decisions.
[0135] It should be understood that although the steps in the flowchart above are shown sequentially as indicated by the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowchart above may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the sub-steps or stages of other steps.
[0136] Based on the same inventive concept, this application also provides a system for implementing the traffic accident risk prediction method described above. The solution provided by this system is similar to the solution described in the above method, and therefore will not be repeated here.
[0137] In one embodiment, a traffic accident risk prediction system is also provided, comprising:
[0138] The acquisition module is used to acquire multi-source heterogeneous traffic data and perform preprocessing.
[0139] The feature extraction module is used to obtain the features of heterogeneous entity nodes and the association features of heterogeneous hyperedges by using dual heterogeneous graph neural networks to perform dual feature encoding of heterogeneous entity nodes and associated hyperedges based on preprocessed multi-source heterogeneous traffic data.
[0140] An optimization module is constructed to build a temporal knowledge hypergraph based on heterogeneous entity node features and associated hyperedge features, and to optimize the node embedding in the temporal knowledge hypergraph based on dynamic hypergraph convolution to obtain heterogeneous features of the hypergraph.
[0141] The fusion module is used to take the heterogeneous features of the hypergraph optimized by dynamic hypergraph convolution as input, and adjust the feature weights from the temporal dimension and the heterogeneous entity dimension through the spatiotemporal duality cross attention mechanism to obtain spatiotemporal cross-fusion features; and cross-fuse the hypergraph heterogeneous features and the spatiotemporal cross-fusion features to obtain comprehensive features.
[0142] The prediction module is used to predict traffic accident risks based on the comprehensive features.
[0143] In the above embodiments, each module of a traffic accident risk prediction system can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the operations corresponding to each module.
[0144] In one embodiment, a computer device is also provided, comprising: a memory for storing a computer program; and a processor for executing the computer program to implement the steps as described in all the above method embodiments.
[0145] In one embodiment, a readable storage medium is also provided, on which a computer program is stored, which, when executed by a processor, implements the steps as described in all the above method embodiments.
[0146] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.
[0147] The embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on its differences from other embodiments. In particular, the system embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions in the method embodiments.
[0148] The above are merely preferred embodiments of the present application and are not intended to limit the embodiments of the present application. For those skilled in the art, the embodiments of the present application can have various modifications and variations. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the embodiments of the present application should be included within the protection scope of the embodiments of the present application.
Claims
1. A method for predicting traffic accident risks, characterized in that, Includes the following steps: Acquire multi-source heterogeneous traffic data and perform preprocessing; Based on the preprocessed multi-source heterogeneous traffic data, a dual heterogeneous graph neural network is used to perform dual feature encoding of heterogeneous entity nodes and associated hyperedges to obtain the features of heterogeneous entity nodes and the association features of heterogeneous hyperedges. A temporal knowledge hypergraph is constructed based on heterogeneous entity node features and associated hyperedge features, and the node embedding in the temporal knowledge hypergraph is optimized based on dynamic hypergraph convolution to obtain heterogeneous features of the hypergraph. Using the hypergraph heterogeneous features optimized by dynamic hypergraph convolution as input, the feature weights are adjusted from the temporal dimension and the heterogeneous entity dimension through the spatiotemporal duality cross-attention mechanism to obtain spatiotemporal cross-fusion features; the hypergraph heterogeneous features and the spatiotemporal cross-fusion features are cross-fused to obtain comprehensive features; Traffic accident risk prediction is based on the aforementioned comprehensive features.
2. The traffic accident risk prediction method according to claim 1, characterized in that, The preprocessing includes removing outliers, missing values, or duplicate values.
3. The traffic accident risk prediction method according to claim 1, characterized in that, A dual heterogeneous graph neural network is used to encode the features of heterogeneous entity nodes and their associated hyperedges, obtaining the features of heterogeneous entity nodes and the association features of heterogeneous hyperedges. The process includes the following steps: The formula for feature mapping of heterogeneous entity nodes is defined as follows: In the formula, heterogeneous nodes Features of heterogeneous entity nodes extracted by DHGNN heterogeneous nodes The corresponding original multi-source heterogeneous features, The feature mapping weight matrix for heterogeneous nodes. For the feature mapping bias term of heterogeneous nodes, It is a non-linear activation function; The formula for heterogeneous hyperedge correlation feature mapping is defined as follows: In the formula, heterogeneous hyperedge Heterogeneous hyperedge correlation features extracted by DHGNN heterogeneous hyperedge The corresponding heterogeneous association characteristics, The weight matrix for the eigenmap of heterogeneous hyperedges. This is the bias term for the heterogeneous hyperedge feature map.
4. The traffic accident risk prediction method according to claim 1, characterized in that, Constructing a temporal knowledge hypergraph based on heterogeneous entity node features and associated hyperedge features includes the following steps: The formula for feature mapping of heterogeneous nodes in a temporal knowledge hypergraph is defined as follows: In the formula, For the embedding feature vectors of heterogeneous nodes in the hypergraph, These are the features of the heterogeneous entity nodes corresponding to the heterogeneous nodes. The feature mapping weight matrix for heterogeneous nodes. For bias terms; The formula for the feature mapping of heterogeneous hyperedges in a temporal knowledge hypergraph is defined as follows: In the formula, For the embedding feature vector of the heterogeneous hyperedge, Let be the set of heterogeneous nodes connected by heterogeneous hyperedges. Let be the size of the heterogeneous node set. It is the weight matrix of the heterogeneous hyperedge eigenmap.
5. The traffic accident risk prediction method according to claim 1, characterized in that, Optimizing node embeddings in a temporal knowledge hypergraph based on dynamic hypergraph convolution to obtain heterogeneous features of the hypergraph includes the following steps: The formula for dynamic hypergraph convolution is defined as follows: In the formula, For the first The heterogeneous features of the hypergraph after dynamic hypergraph convolution optimization at each time step. For containing heterogeneous nodes The set of superedges The heterogeneous convolution weight matrix, This is the self-connection weight matrix for heterogeneous nodes. For the first Always Beyond the Edge heterogeneous nodes The association weight is updated using the following formula: 。 6. The traffic accident risk prediction method according to claim 1, characterized in that, Using the heterogeneous features of the hypergraph optimized by dynamic hypergraph convolution as input, the feature weights are adjusted from the temporal dimension and the heterogeneous entity dimension through a spatiotemporal duality cross-attention mechanism to obtain spatiotemporal cross-fusion features, including the following steps: The formula for calculating the temporal-aware attention weight in the spatiotemporal-dual cross-attention mechanism is as follows: In the formula, For the first Temporal attention weights at each moment This is the temporal attention query vector; The temporal features are calculated based on time-aware attention weights, using the following formula: In the formula, These are the aggregated temporal features; The formula for calculating the attention weights for duality perception is as follows: In the formula, heterogeneous nodes Heterogeneous nodes with neighbors Duality attention weights heterogeneous nodes The set of neighboring nodes, This is the attention weight matrix for dual relations; heterogeneous neighbor nodes Hypergraph heterogeneous features optimized by dynamic hypergraph convolution; To connect heterogeneous nodes Heterogeneous nodes with neighbors The heterogeneous hyperedge correlation features corresponding to the hyperedges; The duality-aware attention weights are used to calculate duality features, as shown in the following formula: In the formula, The dual relation features after aggregation; Based on temporal and duality features, spatiotemporal cross-fusion features are obtained, as shown in the following formula: In the formula, For the first The spatiotemporal cross-fusion characteristics of time, This is a spatiotemporal cross-weight matrix used to achieve deep cross-interaction between temporal features and duality features. The weight matrix and bias terms of the fusion layer; The heterogeneous features of the hypergraph and the spatiotemporal cross-fusion features are cross-fused to obtain a comprehensive feature, as shown in the following formula: In the formula, For the first Time Node The comprehensive characteristics, For the first Hypergraph heterogeneous features optimized by time-varying dynamic hypergraph convolution. To fix the fusion weight coefficients, satisfy ; Learnable weight matrix for feature interaction; It represents the Hadamardi (or Hadama) stack.
7. The traffic accident risk prediction method according to claim 1, characterized in that, Based on the aforementioned comprehensive features, the formula for predicting traffic accident risk is as follows: In the formula, This represents the probability of an accident occurring on the target road section. To predict the weight matrix, To predict the bias term, This is the activation function.
8. A traffic accident risk prediction system, characterized in that, include: The acquisition module is used to acquire multi-source heterogeneous traffic data and perform preprocessing. The feature extraction module is used to obtain the features of heterogeneous entity nodes and the association features of heterogeneous hyperedges by using dual heterogeneous graph neural networks to perform dual feature encoding of heterogeneous entity nodes and associated hyperedges based on preprocessed multi-source heterogeneous traffic data. An optimization module is constructed to build a temporal knowledge hypergraph based on heterogeneous entity node features and associated hyperedge features, and to optimize the node embedding in the temporal knowledge hypergraph based on dynamic hypergraph convolution to obtain heterogeneous features of the hypergraph. The fusion module is used to take the heterogeneous features of the hypergraph optimized by dynamic hypergraph convolution as input, and adjust the feature weights from the temporal dimension and the heterogeneous entity dimension through the spatiotemporal duality cross attention mechanism to obtain spatiotemporal cross-fusion features; and cross-fuse the hypergraph heterogeneous features and the spatiotemporal cross-fusion features to obtain comprehensive features. The prediction module is used to predict traffic accident risks based on the comprehensive features.
9. A computer device, characterized in that, Includes: memory, used to store computer programs; A processor for executing the computer program to implement the method as described in any one of claims 1 to 7.
10. A readable storage medium, characterized in that, The readable storage medium stores a computer program that, when executed by a processor, implements the method as described in any one of claims 1 to 7.