Traffic accident prediction method based on space-time diagram convolutional neural network
By using the spatiotemporal graph convolutional neural network and STGEN model in traffic accident prediction, combined with the focus time self-attention mechanism and spatial feature transfer, the shortcomings of existing methods in spatiotemporal nonlinear feature processing and fine-grained spatial analysis are solved, and traffic accident prediction and risk identification are achieved with higher accuracy.
Patent Information
- Application Number
- CN202510054505.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-14
- Publication Date
- 2025-05-13
AI Technical Summary
The existing traffic accident prediction methods have limitations in dealing with spatiotemporal nonlinear features, especially the analysis on fine-grained spatial scales is insufficient, and the impact of road geometric features and road conditions on traffic accident risks cannot be fully considered.
The traffic accident prediction method based on the spatiotemporal graph convolution neural network is adopted, and the STGEN model of the focal time self-attention mechanism and the dual-stream network architecture of spatial feature transfer is introduced, and the time-weighted method is enhanced to enhance geospatial characteristics and accurately capture complex spatiotemporal dependencies.
It improves the accuracy of traffic accident prediction, identifies potential risk points and high-risk areas related to accidents, and provides more efficient intelligent traffic solutions.
Smart Images

Figure CN119990417A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of traffic accident prediction, and in particular to a traffic accident prediction method based on a spatiotemporal graph convolutional neural network. Background Art
[0002] Traffic accident prediction, as a key topic in the field of spatiotemporal prediction, aims to predict the probability of accidents by analyzing traffic data and provide a scientific basis for accident prevention.
[0003] Traditional traffic accident prediction methods mostly use classic machine learning models, such as decision trees (DT), Poisson regression, naive Bayes (NB), and cluster analysis. These methods have limitations in dealing with the spatiotemporal nonlinear characteristics of traffic accident prediction. With the rise of deep learning technology, researchers have begun to try to apply neural networks to traffic accident prediction. For example, long short-term memory networks (LSTM) and convolutional neural networks (CNN) have demonstrated superior modeling capabilities in the temporal and spatial dimensions, respectively. In addition, the spatiotemporal model combining LSTM and CNN further improves the prediction accuracy of traffic accidents.
[0004] In order to better solve the problem of spatiotemporal heterogeneity in traffic accident prediction, researchers have proposed innovative methods based on spatiotemporal graph neural networks (GNNs) and regional division. These methods effectively improve the prediction performance by capturing time series characteristics, spatial correlations, and dynamic change laws. However, current research is still insufficient in the analysis of fine-grained spatial scales, especially in terms of the impact of road geometric characteristics (such as turning radius, curvature) and road conditions on traffic accident risks. Therefore, in-depth research on traffic accident hotspots and influencing factors combined with geospatial information will not only help with early warning and intervention of accident risks, but also provide important references for road network design and traffic safety management. Summary of the invention
[0005] The technical problem to be solved by the present invention is to address the deficiencies of the above-mentioned prior art and provide a traffic accident prediction method based on a spatiotemporal graph convolutional neural network, establish a STGEN traffic accident prediction model that combines a focal time self-attention mechanism with a dual-stream network architecture of spatial feature transfer, and introduce a time weighting method to realize the identification and processing of the possibility of accidents in the time dimension, while enhancing the geographic spatial features in the spatial dimension to achieve accurate capture of complex spatiotemporal dependencies.
[0006] In order to solve the above technical problems, the technical solution adopted by the present invention is:
[0007] The present invention provides a traffic accident prediction method based on a spatiotemporal graph convolutional neural network, which specifically comprises the following steps:
[0008] Step 1: Obtain historical traffic data of the area to be predicted and pre-process the historical traffic data of the area to be predicted, establish a multi-point divergent road network map dataset of the area to be predicted, and divide the dataset into a training set, a validation set, and a test set according to the ratio;
[0009] Step 1.1, obtain historical traffic data of the area to be predicted, including road type, length, whether it is a one-way road, maximum speed limit, road direction information and road angle information, and accident location coordinates;
[0010] Step 1.2: Preprocess the historical traffic data of the prediction area, including parsing timestamps, handling missing values, and standardizing features;
[0011] Step 1.3, the road network of the area to be predicted is represented as a multi-point divergent road network graph G=VU, wherein V is a set of nodes, which is used to represent the endpoints of the roads in the area to be predicted, and U is a set of edges, which is used to represent the road set in the area to be predicted. Based on the coordinates of the accident site, the node v closest to the accident site in the road network in the area to be predicted is found, and it is used as the central node where the accident occurred. A multi-point divergent road network graph is generated along the road set U in the area to be predicted;
[0012] Step 1.4: Establish a multi-point divergent road network map dataset of the area to be predicted, and divide the dataset into a training set, a validation set, and a test set according to the proportion;
[0013] Step 2: extracting the geospatial data and road angle information of the area to be predicted from the multi-point divergent road network map using a multi-scale feature encoding method, encoding the multivariate road information of each central node in n time series {t, t+1, ..., t+n}, and generating a node matrix containing the multivariate features of all nodes; the geospatial data and road angle information of the area to be predicted include road type, road length, road restriction, road angle and direction information;
[0014] Based on OpenStreetMap (OSM), the geospatial data and road angle information contained in the multi-point divergent road network map are obtained; in order to use the central node to analyze the same road characteristics, the angle and direction information of the road are introduced, and all the divergent road networks in the predicted area are integrated into the encoder, and the multivariate road information of the central node in n time series {t, t+1, …, t+n} is encoded to form a node matrix containing the multivariate characteristics of all nodes;
[0015] Node matrix M∈R N×F is defined as:
[0016] M=Encode(F geo ,F angel, F time )
[0017] in, Represents the geographical information of the central node, including road type, road length and road restrictions, is the spatial information of the central node, including the road angle and direction, is the time information of the central node, including the specific timestamp, the time of the accident, the week, month, and season information. N×F is the node matrix set of all nodes in the area to be predicted, N is the number of nodes in the area to be predicted, F is a set containing node geographic information, spatial information and time information, Encode(·) is the encoding function that integrates geographic information, spatial information and time information;
[0018] Step 3, construct the STGEN traffic accident prediction model, and train the STGEN traffic accident prediction model using the node matrix containing the multivariate features of all nodes to obtain the trained STGEN traffic accident prediction model;
[0019] The STGEN traffic accident prediction model includes a feature extraction module and a GEN network. The feature extraction module extracts the spatial features, temporal features, and road similarity features of the roads around the central node. The GEN network adjusts the hyperparameter combination of the STGEN traffic accident prediction model through a grid search optimization algorithm.
[0020] Step 3.1: Based on the node matrix M, extract the road u around the central node v i The road features S generate the road u around the central node v i Spatial characteristics is the road u around the central node v i The spatial characteristics of is the dimension of spatial features; the road features S include road geometry information, topological relationships of road sections, road section length, road type and traffic sign information; the traffic sign information includes the maximum legal speed limit of the road, whether it is a bridge, and whether it is a one-way street;
[0021] Step 3.2: Based on the node matrix M, use the temporal self-attention mechanism to focus on the road u around the central node v. i Perform focus time feature extraction to generate a road u around the central node v i Time characteristics of historical traffic conditions X i χ,t is the road u around the central node v i The historical traffic conditions in the time series {t, t+1, …, t+n}, χ is the road u around the central node vi The average vehicle speed in each time period, is the dimension of the time feature, T is the length of the time feature;
[0022] Generate query, key and value vectors for each time step t in the time dimension according to the input node matrix, encode the time series data to capture the temporal change characteristics; calculate the homogeneity score in the heterogeneous time and space through the self-attention mechanism, and quantify the correlation and similarity between different time steps; perform weighted summation of the time vector according to the homogeneity score to obtain the weighted time feature vector; calculate the proportion of the number of traffic accidents occurring in time step t to the total number of traffic accidents occurring in one day through the weighted time feature vector i χ,t , get the time characteristics
[0023] Step 3.3: Based on the node matrix M, extract the road similarity feature X of the central node v similar ;
[0024] The node v where the accident occurred is the central node, and a road u around the central node v i For the edge, obtain geospatial data and road angle information, including the angle, direction, and curvature of the road, through (u i ,v) The angle information between them is used to infer the possibility of traffic accidents occurring at the same intersection in heterogeneous time and space;
[0025] The road u around the central node v i The angle is defined as the set Extract and aggregate roads u i The sharpest angle relative to the right-turn road and the left-turn road, and the road u i The angle between the road and its closest straight line is obtained by taking the central node v and the road u i Angle information As shown below:
[0026]
[0027] Among them, || means concatenation, and The road u i The sharpest angle relative to the right-turn road and the sharpest angle relative to the left-turn road, For road i The angle between it and the road that is closest to it in a straight line;
[0028] Set h v is the initial spatial feature of node v, and the angle information of the central node v is obtained
[0029]
[0030]
[0031] Among them, ReLU is a nonlinear activation function, MLP is a multi-layer perceptron, W is a weight coefficient, is the aggregation result of the angle information of the neighbor node set N(v) of the central node v, and the spatial feature h of the neighbor node v′ is v′ , edge features And angle information After combination, it passes through MLP and is summed up to obtain;
[0032] For the central node v and neighbor node v′, LAT v and LON v Represents the latitude and longitude of the central node v, using LAT v′ and LON v′ Represent the latitude and longitude of the neighbor node v′ respectively, and the direction of the edge (v, v′) is calculated as:
[0033] d vv′ =(LAT v -LAT v′ ,LON v -LON v′ )
[0034] Among them, LAT v and LON v Respectively represent the latitude and longitude of the central node v, LAT v′ and LON v′ Respectively represent the latitude and longitude of the neighbor node v′;
[0035] Use the same aggregation method as angle information to get the direction information of the center node v
[0036]
[0037] Among them, h v is the initial feature of the central node v, h v′ is the initial feature of the neighbor node v′, is the aggregate contribution of the neighbor set N(v) of the central node v to the directional information, e vv′ is the characteristic relationship between the edge (v, v′) between the central node v and the neighbor node v′, d vv′ is the direction between the central node v and the neighboring node v′;
[0038] The angle information around the central node v and the direction information of the central node are spliced to obtain the road feature matrix of the central node;
[0039] For the node where the accident is predicted to occur, the node v A The node v where the accident occurred B The cosine similarity of the road similarity matrix is used to obtain the similarity of the road characteristics where the traffic accident occurred, as shown in the following formula:
[0040]
[0041] Among them, S(A,B) is the node v where the accident is predicted to occur. A and the node v where the accident is known to have occurred B The road similarity matrix A and B are the road similarity matrices around node v. A and node v B The road feature matrix formed by all roads, A j is around node v A The road feature matrix of the connected j-th road, B k is around node v B The road feature matrix of the kth road, J is the road feature matrix around node v A The number of roads around node v B Number of roads;
[0042] The node v where the accident is predicted to occur A The road similarity information of all roads is aggregated to obtain the node v where the accident is predicted to occur A The road similarity feature X similar , as shown below:
[0043]
[0044] Among them, X similar is an upper triangular matrix with an empty diagonal, S(A,Q) is the node v where the node predicts the accident A and the node v where the accident is known to have occurred Q The road similarity matrix is , Q is the number of nodes where accidents occur;
[0045] Step 3.4: Extract the spatial features Time characteristics and road similarity feature X similar Input the GEN network for training, adjust the model's hyperparameter combination through the grid search optimization algorithm, and obtain the trained STGEN traffic accident prediction model;
[0046] By extracting spatial and temporal features and road similarity feature Xsimilar And the trainable weight W, estimates the probability of a traffic accident occurring at the central node v in the T+1 time period
[0047]
[0048] Among them, f(X i ,X similar ; W) is a prediction function whose goal is to estimate a certain road node v based on the input features i The probability of a traffic accident occurring in the T+1 period The weight W is trained by fitting the traffic accident events before T+1, and the model weight W is updated by minimizing the loss function, as shown in the following formula:
[0049]
[0050] Among them, ζ is the number of traffic accidents in the area to be predicted, y k is the true value of the traffic accident at the kth node, is the predicted value of the traffic accident at the kth node, λ is the L2 regularization parameter, ‖W‖ 2 is the L2 norm of weight W;
[0051] Step 4: Evaluate the STGEN traffic accident prediction model, further optimize the STGEN traffic accident prediction model through cross-validation method, and use the optimized STGEN traffic accident model to predict traffic accidents in the area to be predicted;
[0052] The K-fold cross-validation method is used to optimize the STGEN traffic accident prediction model. During the cross-validation process, the data set is divided into multiple training sets and validation sets according to different proportions. The STGEN traffic accident prediction model is trained and evaluated on different training sets and validation sets, thereby effectively reducing the deviation caused by data division; according to the verification results, if the model performs poorly on certain data sets, its parameters are adjusted and optimized to improve the stability and generalization ability of the model.
[0053] The beneficial effect of adopting the above technical scheme is that: the traffic accident prediction method based on the spatiotemporal graph convolutional neural network provided by the present invention integrates the advantages of spatiotemporal correlation and multi-point divergent road network to form an efficient and flexible intelligent transportation solution. The traffic accident prediction method based on the spatiotemporal graph convolutional neural network extracts and analyzes the spatial characteristics, focal time characteristics and multivariate road similarity characteristics of the location where the traffic accident is expected to occur within the prediction, and obtains the similarity of the road characteristics where the traffic accident occurred by calculating the cosine similarity of the road similarity matrix of the node where the accident has occurred and the node where the accident is predicted to occur, identifies potential risk points and high-risk areas related to the accident, and improves the prediction accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] Figure 1 This is a diagram of the architecture of the traffic accident prediction model based on the spatiotemporal graph convolutional neural network provided in this embodiment. DETAILED DESCRIPTION
[0055] The specific implementation of the present invention is further described in detail below in conjunction with the accompanying drawings and examples. The following examples are used to illustrate the present invention, but are not intended to limit the scope of the present invention.
[0056] In this embodiment, a traffic accident prediction based on spatiotemporal graph convolutional neural network is constructed to construct a STGEN traffic accident prediction model based on temporal self-attention and spatial feature transfer, such as Figure 1 As shown in the figure, the node closest to the accident is taken as the central node, and a multi-point divergent road network diagram is generated along the roads around the node; the time self-attention mechanism and "time entropy value" are introduced to give different weights to time slices, so that the model can better pay attention to changes in the time dimension; in the spatial part, the model uses the cosine similarity matrix to enable the STGEN traffic accident prediction model to learn the spatiotemporal characteristics of different geographical locations and predict the risk of traffic accidents in the next stage. The specific steps include:
[0057] Step 1: Obtain historical traffic data of the area to be predicted and pre-process the historical traffic data of the area to be predicted, establish a multi-point divergent road network map dataset of the area to be predicted, and divide the dataset into a training set, a validation set, and a test set according to the ratio;
[0058] Step 1.1, obtain historical traffic data of the area to be predicted, including road type, length, whether it is a one-way road, maximum speed limit, road direction information and road angle information, and accident location coordinates;
[0059] Step 1.2: Preprocess the historical traffic data of the prediction area, including parsing timestamps, handling missing values, and standardizing features;
[0060] Parsing timestamps is one of the key steps in preprocessing. By converting time data into a format suitable for analysis, subsequent feature engineering and model training are more effective. Processing missing values includes deleting or filling missing data to ensure data integrity and consistency. Standardizing features improves the efficiency and effectiveness of model training by scaling feature values to the same scale.
[0061] Step 1.3, the road network of the area to be predicted is represented as a multi-point divergent road network graph G=VU, wherein V is a set of nodes, which is used to represent the endpoints of the roads in the area to be predicted, and U is a set of edges, which is used to represent the road set in the area to be predicted. Based on the coordinates of the accident site, the node v closest to the accident site in the road network in the area to be predicted is found, and it is used as the central node where the accident occurred. A multi-point divergent road network graph is generated along the road set U in the area to be predicted;
[0062] Step 1.4: construct a multi-point divergent road network map dataset of the area to be predicted, and divide the dataset into a training set, a validation set, and a test set according to the proportion;
[0063] Step 2: extracting the geospatial data and road angle information of the area to be predicted from the multi-point divergent road network map using a multi-scale feature encoding method, encoding the multivariate road information of each central node in n time series {t, t+1, ..., t+n}, and generating a node matrix containing the multivariate features of all nodes; the geospatial data and road angle information of the area to be predicted include road type, road length, road restriction, road angle and direction information;
[0064] In a multi-point divergent road network, the central node is closely connected with the surrounding nodes and is usually responsible for coordinating and gathering information. In this embodiment, the central node is usually an intersection, the starting point or end point of a key road section, or an important location that affects the flow of the entire road network. During the temporal encoding process, the characteristics of the central node and its surrounding roads are analyzed, and this information is passed to the encoder for processing, which not only has a strong influence in the local space, but also can better understand and integrate multi-dimensional road information.
[0065] Based on OpenStreetMap (OSM), the geospatial data and road angle information contained in the multi-point divergent road network map are obtained; in order to use the central node to analyze the same road characteristics, the angle and direction information of the road are introduced, and all the divergent road networks in the predicted area are integrated into the encoder, and the multivariate road information of the central node in n time series {t, t+1, …, t+n} is encoded to form a node matrix containing the multivariate characteristics of all nodes;
[0066] Node matrix M∈R N×F is defined as:
[0067] M=Encode(F geo ,F angel, F time )
[0068] in, The geographical information of the central node, including road type, road length and road restrictions, is the spatial information of the central node, including the road angle and direction, is the time information of the central node, including the specific timestamp, the time of the accident, the week, month, and season information. N×F is the node matrix set of all nodes in the area to be predicted, N is the number of nodes in the area to be predicted, F is a set containing node geographic information, spatial information and time information, Encode(·) is the encoding function that integrates geographic information, spatial information and time information;
[0069] Step 3, construct the STGEN traffic accident prediction model, and train the STGEN traffic accident prediction model using the node matrix containing the multivariate features of all nodes to obtain the trained STGEN traffic accident prediction model;
[0070] The STGEN traffic accident prediction model includes a feature extraction module and a GEN network. The feature extraction module extracts the spatial features, temporal features, and road similarity features of the roads around the central node. The GEN network adjusts the hyperparameter combination of the STGEN traffic accident prediction model through a grid search optimization algorithm.
[0071] The goal of traffic accident prediction is to predict the accident risk of roads around the central node in the area in the next period based on the historical traffic records of the area to be predicted. The feature extraction module improves the performance of the STGEN model by generating new features or converting existing features. For example, generating new features such as hours, weeks, and holidays based on timestamps helps capture the time-varying patterns of traffic flow; time features help the STGEN traffic accident prediction model capture the laws and patterns of traffic accidents in the time dimension, improve the accuracy and timeliness of the prediction, and use time features to help the STGEN traffic accident prediction model understand the potential impact of time on traffic behavior patterns, and then optimize the prediction results. In this embodiment, the time features of the central nodes in the area to be predicted are extracted in units of hours; the road similarity features contain the spatial features of the central nodes, and by calculating the similarities between different roads or road sections, the STGEN traffic accident model understands the impact of different road conditions on the occurrence of accidents; in addition, feature selection and dimensionality reduction techniques can be used to reduce the data dimensions of historical traffic data in the area to be predicted, remove redundant information, and improve the training speed and prediction performance of the STGEN model; the GEN network is a general aggregation network for graph neural networks (GNNs), and a differentiable general aggregation function is proposed, which covers and exceeds the traditional Mean, Max and Sum aggregation functions through parameterization methods. The GEN network can dynamically learn aggregation strategies to adapt them to different task requirements, and effectively solve the problems of limited aggregation function selection and inconsistent performance, showing significant advantages in tasks such as node classification and link prediction.
[0072] Step 3.1: Based on the node matrix M, extract the road u around the central node v i The road features S generate the road u around the central node v i Spatial characteristics is the road u around the central node v i The spatial characteristics of is the dimension of spatial features; the road features S include road geometry information, topological relationships of road sections, road section length, road type and traffic sign information; the traffic sign information includes the maximum legal speed limit of the road, whether it is a bridge, and whether it is a one-way street;
[0073] Step 3.2: Based on the node matrix M, use the temporal self-attention mechanism to focus on the road u around the central node v. i Perform focus time feature extraction to generate a road u around the central node v i Time characteristics of historical traffic conditions X i χ,t is the road u around the central node v iThe historical traffic conditions in the time series {t, t+1, …, t+n}, χ is the road u around the central node v i The average vehicle speed in each time period, is the dimension of the time feature, T is the length of the time feature;
[0074] Generate query, key and value vectors for each time step t in the time dimension according to the input node matrix, encode the time series data to capture the temporal change characteristics; calculate the homogeneity score in the heterogeneous time and space through the self-attention mechanism, and quantify the correlation and similarity between different time steps; perform weighted summation of the time vector according to the homogeneity score to obtain the weighted time feature vector; calculate the proportion of the number of traffic accidents occurring in time step t to the total number of traffic accidents occurring in one day through the weighted time feature vector i χ,t , get the time characteristics
[0075] Step 3.3: Based on the node matrix M, extract the road similarity feature X of the central node v similar ;
[0076] Different road types may cause traffic accidents of different degrees. For example, the possibility of traffic accidents on high-traffic highways is much higher than on two-lane residential roads with less traffic. In addition, the turning radius angle direction is also one of the factors affecting traffic accidents. For example, the steeper the road curve, the higher the risk factor.
[0077] The node v where the accident occurred is the central node, and a road u around the central node v i For the edge, obtain geospatial data and road angle information, including the angle, direction, and curvature of the road, through (u i ,v) The angle information between them is used to infer the possibility of traffic accidents occurring at the same intersection in heterogeneous time and space;
[0078] The road u around the central node v i The angle is defined as the set Extract and aggregate roads u i The sharpest angle relative to the right-turn road and the left-turn road, and the road u i and the angle between it and the road closest to the straight line, and get the central node v road u i Angle information As shown below:
[0079]
[0080] Among them, || means concatenation, and The road u i The sharpest angle relative to the right-turn road and the sharpest angle relative to the left-turn road, For road i The angle between it and the road that is closest to it in a straight line;
[0081] Set h v is the initial spatial feature of node v, and the angle information of the central node v is obtained
[0082]
[0083] Among them, ReLU is a nonlinear activation function, MLP is a multi-layer perceptron, W is a weight coefficient, is the aggregation result of the angle information of the neighbor node set N(v) of the central node v, and the spatial feature h of the neighbor node v′ is v′ , edge features And angle information After combination, it passes through MLP and is summed up to obtain;
[0084] For the central node v and neighbor node v′, LAT v and LON v Represents the latitude and longitude of the central node v, using LAT v′ and LON v′ Represent the latitude and longitude of the neighbor node v′ respectively, and the direction of the edge (v, v′) is calculated as:
[0085] d vv′ =(LAT v -LAT v′ ,LON v -LON v′ )
[0086] Among them, LAT v and LON v Respectively represent the latitude and longitude of the central node v, LAT v′ and LON v′ Respectively represent the latitude and longitude of the neighbor node v′;
[0087] Use the same aggregation method as angle information to get the direction information of the center node v
[0088]
[0089] Among them, h v is the initial feature of the central node v, h v′ is the initial feature of the neighbor node v′, is the aggregate contribution of the neighbor set N(v) of the central node v to the directional information, e vv′ is the characteristic relationship between the edge (v, v′) between the central node v and the neighbor node v′, d vv′ is the direction between the central node v and the neighboring node v′;
[0090] The angle information around the central node v and the direction information of the central node are spliced to obtain the road feature matrix of the central node;
[0091] For the node where the accident is predicted to occur, the node v A The node v where the accident occurred B The cosine similarity of the road similarity matrix is used to obtain the similarity of the road characteristics where the traffic accident occurred, as shown in the following formula:
[0092]
[0093] Among them, S(A,B) is the node v where the accident is predicted to occur. A and the node v where the accident is known to have occurred B The road similarity matrix A and B are the road similarity matrices around node v. A and node v B The road feature matrix formed by all roads, A j is around node v A The road feature matrix of the connected j-th road, B k is around node v B The road feature matrix of the kth road, J is the road feature matrix around node v A The number of roads around node v B Number of roads;
[0094] The node v where the accident is predicted to occur A The road similarity information of all roads is aggregated to obtain the node v where the accident is predicted to occur A The road similarity feature X similar , as shown below:
[0095]
[0096] Among them, X similar is an upper triangular matrix with an empty diagonal, S(A,Q) is the node v where the node predicts the accident A and the node v where the accident is known to have occurred Q The road similarity matrix is , Q is the number of nodes where accidents occur;
[0097] In this way, more accurate predictions and analyses can be made to identify potential risk points and high-risk areas related to accidents. By comprehensively considering the geometric characteristics and spatiotemporal changes of roads, the model can provide more accurate risk assessment and decision support in complex traffic networks, thereby effectively improving the efficiency of traffic management and emergency response.
[0098] Step 3.4: Extract the spatial features Time characteristics and road similarity feature X similar Input the GEN network for training, adjust the model parameters through the grid search optimization algorithm, and obtain the trained STGEN traffic accident prediction model;
[0099] Selecting a suitable machine learning or deep learning model is one of the core steps in traffic flow prediction. Model selection depends on the data characteristics and the specific requirements of the prediction task. After the model is selected, the extracted features are input into the GEN network for training. The model parameters are adjusted through the optimization algorithm so that the model can accurately capture the patterns and regularities in the data.
[0100] By extracting spatial and temporal features and road similarity feature X similar And the trainable weight W, estimates the probability of a traffic accident occurring at the central node v in the T+1 time period
[0101]
[0102] Among them, f(X i ,X similar ; W) is a prediction function whose goal is to estimate a certain road node v based on the input features i The probability of a traffic accident occurring in the T+1 period The weight W is trained by fitting the traffic accident events before T+1, and the model weight W is updated by minimizing the loss function, as shown in the following formula:
[0103]
[0104] Among them, ζ is the number of traffic accidents in the area to be predicted, y k is the true value of the traffic accident at the kth node, is the predicted value of the traffic accident at the kth node, λ is the L2 regularization parameter, ‖W‖ 2 is the L2 norm of weight W;
[0105] Step 4: Evaluate the STGEN traffic accident prediction model, further optimize the STGEN traffic accident prediction model through cross-validation method, and use the optimized STGEN traffic accident model to predict traffic accidents in the area to be predicted;
[0106] The K-fold cross-validation method is used to optimize the STGEN traffic accident prediction model. During the cross-validation process, the data set is divided into multiple training sets and validation sets according to different proportions. The STGEN traffic accident prediction model is trained and evaluated on different training sets and validation sets, thereby effectively reducing the deviation caused by data division. According to the validation results, if the model performs poorly on certain data sets, its parameters are adjusted and optimized, such as adjusting the model's hyperparameters, adding regularization terms to reduce overfitting, or adjusting the distribution of the training set to improve the model's stability and generalization ability.
[0107] In this embodiment, the STGEN model is verified using a real data set TAP containing real traffic data from six cities, and compared with other 13 baseline models on the three evaluation indicators of F1 value, Accuracy, and AUC. The F1 values of the STGEN model and the other 13 baseline models are shown in Table 1. The STGEN traffic accident prediction model performs better than other baseline models on the real data sets of six cities. Compared with other models, the F1 value of STGEN has increased by 3.3% to 10.2%. The STGEN traffic accident prediction model only reaches an upper limit of 58.84% in prediction accuracy. This is because the data set is seriously unbalanced, resulting in the accuracy being affected by large categories of samples. Specifically, when a certain category occupies most of the data, the model tends to predict that category, thereby improving the accuracy. Therefore, the accuracy cannot fully reflect the actual prediction performance of the model.
[0108] Table 1 F1 value comparison experiment of STGEN model and other 13 baseline models
[0109]
[0110] Since the accuracy rate cannot fully reflect the actual prediction performance of the model, this embodiment uses the two indicators of Accuracy and AUC to measure the effectiveness of imbalanced classification. The comparison of the STGEN traffic accident prediction model with the other 13 baseline models in terms of Accuracy is shown in Table 2, and the comparison of the STGEN traffic accident prediction model with the other 13 baseline models in terms of AUC is shown in Table 3.
[0111] Table 2 Accuracy comparison experiment of STGEN model and other 13 baseline models
[0112]
[0113] As shown in Tables 2 and 3, the performance of the two classic time series-based prediction methods, XGBoost and MLP, is very poor. Since they cannot handle the nonlinear spatiotemporal characteristics of traffic accident data, their prediction performance is not as good as that of machine learning and deep learning models. The six classic GNN-based prediction methods, GCN, ChebNet, ARMANet, GraphSAGE, TAGCN, and GIN, do not support message passing with multi-dimensional edge features, nor can they handle graph-structured data well. Compared with the above methods, GAT, MPNN, CGC, GEN, Transformer, and STGEN have the ability to support message passing with multi-dimensional edge features to better handle graph-structured data, which helps the model obtain better results. Overall, the model using graph networks has good prediction performance, which verifies that modeling the spatial correlation between urban areas in the form of graph structures helps improve the performance of traffic accident prediction.
[0114] Table 3 AUC comparison of STGEN model and other 13 baseline models
[0115]
[0116] In the task of traffic accident prediction, deep learning models usually provide better prediction results than traditional prediction models. This is because deep learning models can automatically capture the nonlinear features in traffic accident data, while traditional methods require complex feature engineering or can only consider time dimension information. In particular, graph neural networks are able to simulate the spatial heterogeneity between different areas of a city. However, existing methods such as RiskOracle, GSNet, SNIPER, and TAP usually choose a fixed graph structure when designing graph network models, which cannot express the complex spatial correlation between different areas. Therefore, STGEN enhances the spatiotemporal correlation of traffic accident data in different areas of the city by utilizing the temporal attention mechanism and path similarity strategy. The experimental results on the dataset verify the effectiveness of this method.
[0117] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some or all of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope defined by the claims of the present invention.
Claims
1. A traffic accident prediction method based on spatiotemporal graph convolutional neural network, characterized by: The following steps are involved: Step 1: Obtain historical traffic data of the area to be predicted and pre-process the historical traffic data of the area to be predicted, establish a multi-point divergent road network map dataset of the area to be predicted, and divide the dataset into a training set, a validation set, and a test set according to the ratio; Step 2: extracting the geospatial data and road angle information of the area to be predicted from the multi-point divergent road network map using a multi-scale feature encoding method, encoding the multivariate road information of each central node in n time series {t, t+1, ..., t+n}, and generating a node matrix containing the multivariate features of all nodes; the geospatial data and road angle information of the area to be predicted include road type, road length, road restriction, road angle and direction information; Step 3, construct the STGEN traffic accident prediction model, and train the STGEN traffic accident prediction model using the node matrix containing the multivariate features of all nodes to obtain the trained STGEN traffic accident prediction model; Step 4: Evaluate the STGEN traffic accident prediction model, further optimize the STGEN traffic accident prediction model through cross-validation method, and use the optimized STGEN traffic accident model to predict traffic accidents in the area to be predicted.
2. The traffic accident prediction method based on spatiotemporal graph convolutional neural network according to claim 1 is characterized in that: The step 1 comprises: Step 1.1, obtain historical traffic data of the area to be predicted, including road type, length, whether it is a one-way road, maximum speed limit, road direction information and road angle information, and accident location coordinates; Step 1.2: Preprocess the historical traffic data of the prediction area, including parsing timestamps, handling missing values, and standardizing features; Step 1.3, the road network of the area to be predicted is represented as a multi-point divergent road network graph G=VU, wherein V is a set of nodes, which is used to represent the endpoints of the roads in the area to be predicted, and U is a set of edges, which is used to represent the road set in the area to be predicted. Based on the coordinates of the accident site, the node v closest to the accident site in the road network in the area to be predicted is found, and it is used as the central node where the accident occurred. A multi-point divergent road network graph is generated along the road set U in the area to be predicted; Step 1.4: Establish a multi-point divergent road network map dataset of the area to be predicted, and divide the dataset into a training set, a validation set, and a test set according to the proportion.
3. The traffic accident prediction method based on spatiotemporal graph convolutional neural network according to claim 2 is characterized in that: The specific method of step 2 is: Based on OpenStreetMap, the geospatial data and road angle information contained in the multi-point divergent road network map are obtained; in order to use the central node to analyze the same road characteristics, the angle and direction information of the road are introduced, and all the divergent road networks in the predicted area are integrated into the encoder, and the multivariate road information of the central node in n time series {t, t+1, …, t+n} is encoded to form a node matrix containing the multivariate characteristics of all nodes; Node matrix M∈R N×F is defined as: M=Encode(F geo ,F angel, F time ) in, Represents the geographical information of the central node, including road type, road length and road restrictions, is the spatial information of the central node, including the road angle and direction, is the time information of the central node, including the specific timestamp, the time of the accident, the week, month, and season information. N×F is the node matrix set of all nodes in the area to be predicted, N is the number of nodes in the area to be predicted, F is a set containing node geographic information, spatial information and time information, and Encode(·) is an encoding function that integrates geographic information, spatial information and time information.
4. The traffic accident prediction method based on spatiotemporal graph convolutional neural network according to claim 3 is characterized by: Step 3: The STGEN traffic accident prediction model includes a feature extraction module and a GEN network. The feature extraction module extracts the spatial features, temporal features, and road similarity features of the roads around the central node. The GEN network adjusts the hyperparameter combination of the STGEN traffic accident prediction model through a grid search optimization algorithm.
5. The traffic accident prediction method based on spatiotemporal graph convolutional neural network according to claim 4 is characterized in that: The step 3 comprises: Step 3.1: Based on the node matrix M, extract the road u around the central node v i The road features S generate the road u around the central node v i Spatial characteristics is the road u around the central node v i The spatial characteristics of is the dimension of spatial features; the road features S include road geometry information, topological relationships of road sections, road section length, road type and traffic sign information; the traffic sign information includes the maximum legal speed limit of the road, whether it is a bridge, and whether it is a one-way street; Step 3.2: Based on the node matrix M, use the temporal self-attention mechanism to focus on the road u around the central node v. i Perform focus time feature extraction to generate a road u around the central node v i Time characteristics of historical traffic conditions is the road u around the central node v i The historical traffic conditions in the time series {t, t+1, …, t+n}, χ is the road u around the central node v i The average vehicle speed in each time period, is the dimension of the time feature, T is the length of the time feature; Step 3.3: Based on the node matrix M, extract the road similarity feature X of the central node v similar ; Step 3.4: Extract the spatial features Time characteristics and road similarity feature X similar The GEN network is input for training, and the hyperparameter combination of the model is adjusted through the grid search optimization algorithm to obtain the trained STGEN traffic accident prediction model.
6. The traffic accident prediction method based on spatiotemporal graph convolutional neural network according to claim 5 is characterized in that: The specific method of step 3.2 is: Generate query, key and value vectors for each time step t in the time dimension according to the input node matrix, and encode the time series data to capture the temporal change characteristics; The self-attention mechanism is used to calculate the homogeneity score in heterogeneous time and space, and to quantify the correlation and similarity between different time steps. The time vector is weighted and summed according to the homogeneity score to obtain the weighted time feature vector. The weighted time feature vector is used to calculate the proportion of traffic accidents occurring in time step t to the total number of traffic accidents occurring in a day. Get time features 7. The traffic accident prediction method based on spatiotemporal graph convolutional neural network according to claim 6 is characterized in that: The specific method of step 3.3 is: The node v where the accident occurred is the central node, and a road u around the central node v i For the edge, obtain geospatial data and road angle information, including the angle, direction, and curvature of the road, through (u i ,v) to infer the possibility of traffic accidents occurring at the same intersection in heterogeneous time and space; The road u around the central node v i The angle is defined as the set Extract and aggregate roads u i The sharpest angle relative to the right-turn road and the left-turn road, and the road u i The angle between the road and its closest straight line is obtained by taking the central node v and the road u i Angle information As shown below: Among them, || means concatenation, and The road u i The sharpest angle relative to the right-turn road and the sharpest angle relative to the left-turn road, For road i The angle between it and the road that is closest to it in a straight line; Set h v is the initial spatial feature of node v, and the angle information of the central node v is obtained Among them, ReLU is a nonlinear activation function, MLP is a multi-layer perceptron, W is a weight coefficient, is the aggregation result of the angle information of the neighbor node set N(v) of the central node v, and the spatial feature h of the neighbor node v′ is v′ , edge features And angle information After combination, it passes through MLP and is summed up; For the central node v and neighbor node v′, LAT v and LON v Represents the latitude and longitude of the central node v, using LAT v′ and LON v′ Respectively represent the latitude and longitude of the neighbor node v′, and the direction of the edge (v, v′) is calculated as: d vv ,=(YEARS v -YEARS v′ ,LON v -LON v′ ) Among them, LAT v and LON v Respectively represent the latitude and longitude of the central node v, LAT v′ and LON v′ Respectively represent the latitude and longitude of the neighbor node v′; Use the same aggregation method as angle information to get the direction information of the center node v Among them, h v is the initial feature of the central node v, h v′ is the initial feature of the neighbor node v′, is the aggregate contribution of the neighbor set N(v) of the central node v to the directional information, e vv′ is the characteristic relationship between the edge (v, v′) between the central node v and the neighbor node v′, d vv′ is the direction between the central node v and the neighboring node v′; The angle information around the central node v and the direction information of the central node are spliced to obtain the road feature matrix of the central node; For the node where the accident is predicted to occur, the node v A The node v that has an accident with itself B The cosine similarity of the road similarity matrix is used to obtain the road similarity feature X of the road where the traffic accident occurred. similar , as shown below: Among them, S(A, B) is the node v where the accident is predicted to occur. A and the node v where the accident is known to have occurred B The road similarity matrix A and B are the road similarity matrices around node v. A and node v B The road feature matrix formed by all roads, A j is around node v A The road feature matrix of the connected j-th road, B k is around node v B The road feature matrix of the kth road, J is the road feature matrix around node v A The number of roads around node v B Number of roads; The node v where the accident is predicted to occur A The road similarity information of all roads is aggregated to obtain the node v where the accident is predicted to occur A The road similarity feature X similar , as shown below: Among them, X similar is an upper triangular matrix with an empty diagonal, S(A, Q) is the node v where the node predicts the accident A and the node v where the accident is known to have occurred Q The road similarity matrix is , and Q is the number of nodes where accidents occur.
8. The traffic accident prediction method based on spatiotemporal graph convolutional neural network according to claim 7 is characterized in that: The specific method of step 3.4 is: By extracting spatial and temporal features and road similarity feature X similar And the trainable weight W, estimates the probability of a traffic accident occurring at the central node v in the T+1 time period Among them, f(X i , X similar ; W) is a prediction function whose goal is to estimate a certain road node v based on the input features i The probability of a traffic accident occurring in the T+1 period The weight W is trained by fitting the traffic accident events before T+1, and the model weight W is updated by minimizing the loss function, as shown in the following formula: Among them, ζ is the number of traffic accidents in the area to be predicted, y k is the true value of the traffic accident at the kth node, is the predicted value of a traffic accident at the kth node, λ is the L2 regularization parameter, ||W|| 2 is the L2 norm of the weight W.
9. The traffic accident prediction method based on spatiotemporal graph convolutional neural network according to claim 8 is characterized in that: The specific method of step 4 is: The K-fold cross-validation method is used to optimize the STGEN traffic accident prediction model. During the cross-validation process, the data set is divided into multiple training sets and validation sets according to different proportions. The STGEN traffic accident prediction model is trained and evaluated on different training sets and validation sets, thereby effectively reducing the deviation caused by data division; according to the verification results, if the model performs poorly on certain data sets, its parameters are adjusted and optimized to improve the stability and generalization ability of the model.