Online Traffic Accident Spatial-Temporal Post-Impact Prediction Model on Highways Based on Spiking Neural Networks

Traffic accident management as an approach to improve public security and reduce economic losses has received public attention for a long time, among which traffic accidents post-impact prediction (TAPIP) is one of the most important procedures. However, existing systems and methodologies for TAPIP are insufficient for addressing the problem. (e drawbacks include ignoring the recovery process after clearance and failing to make comprehensive prediction in both time and space domain. To this end, we build a 3-stage TAPIP model on highways, using the technology of spiking neural networks (SNNs) and convolutional neural networks (CNNs). By dividing the accident lifetime into two phases, i.e., clean-up phase and recovery phase, the model extracts characteristics in each phase and achieves prediction of spatial-temporal post-impact variables (e.g., clean-up time, recovery time, and accumulative queue length). (e framework takes advantage of SNNs to efficiently capture accident spatial-temporal features and CNNs to precisely represent the traffic environment. Integrated with an adaptation and updating mechanism, the whole system works autonomously in an online manner that continues to self-improve during usage. By testing with a new dataset CASTA pertaining to California statewide traffic accidents on highways collected in four years, we prove that the proposed model achieves higher prediction accuracy than other methods (e.g., KNN, shockwave theory, and ANNs).(is work is the introduction of SNNs in the traffic accident prediction domain and also a complete description of post-impact in the whole accident lifetime.


Introduction
People's living standards have increased all over the world, leading to an increase in the ownership of private vehicles [1]. While private vehicles have improved people's traveling experience, they have also contributed to several traffic problems, where traffic safety is one of the main concerns. According to statistical data released by World Health Organization in 2004, road traffic accidents are among the main causes of deaths and injuries all over the world, leading to 1.2 million deaths and 50 million injuries each year [2]. In 2019, the number of traffic accidents in China was 248,000, and the direct property loss was as high as 1.35 billion yuan (China Statistical Yearbook).
Besides the costs of fatalities and injuries, indirect effects brought by traffic accidents such as congestion and energy consumption also have tremendous impacts on socioeconomic development. Typically, accident congestion can spread rapidly and even cause a chain breakdown in the entire system, especially in closed roads like highways. In severe cases, the delays of clearance for an accident may increase the occurrence probability of a secondary accident [3]. In 1988, the total extra travel time and fuel consumption caused by traffic congestion, both regular and occasional, in 50 major cities in the United States was estimated at 35 billion U.S. dollars [4].
Traffic accident management (TAM) is of great importance to government and transportation agencies, which can not only improve public security but also reduce economic losses. ere are usually two main tasks in TAM: analysis and prediction. By analyzing the features of historical accident records, accident prediction can be realized to foresee the time and place of the accident in advance. Furthermore, traffic accidents post-impact prediction (TAPIP) is also an essential part in TAM but have not caught enough attention. When an accident occurs, if the spatial and temporal impact scope can be quickly determined, then the transportation agency can induce vehicles to avoid unnecessary congestion, and travelers can also plan their routes in advance. e lifetime of a traffic accident is usually divided into five phases, namely, detection, verification, response, clearance, and recovery [5]. Most TAPIP-related research studies till now concentrate only on the first four phases, which means the duration from accident occurrence to the reopening of all blocked traffic lanes. e existing research studies use traffic wave theory, regression model, and other methods to analyze the influence of various factors on accident indicators, but have not established a complete relationship between the influencing factors and the spatialtemporal impact of the accidents. Furthermore, the clearance is never the end of an accident, and the process that the traffic gradually recovers to normal conditions cannot be ignored. For the convenience of expression, this work proposes a two-phase accident lifetime. As shown in Figure 1, the four phases before clearance are grouped into clean-up phase, while the recovery phase remains unchanged. e reason for this division is that in the clean-up phase, at least one lane will be blocked, while after that, the whole lanes will be reopened.
As the third-generation neuron model, spiking neural networks (SNNs) [6] are closer to biological principle compared with other artificial neural networks (ANNs). Due to the advantage of being sensitive to spatial-temporal characteristics of information [7], SNNs already improve the traditional neural models on accuracy in many application areas. However, SNNs till now are rarely used in traffic domain and have even never been applied to accident prediction related research.
is study proposes a traffic accident spatial-temporal post-impact prediction model on highways, using the technology of SNNs and CNNs. In the 3-stage model, the duration of clean-up phase (clean-up time) is first estimated, and then, several post-impact variables such as recovery time and accumulative queue length are predicted. Additional online stage is used to make adaptation and update the model. In this regard, the main contributions of this work can be summarized as follows: (1) e development of a framework to predict postimpact in the complete accident lifetime, which contains the recovery process. e rest of this study is organized as follows. Section 2 describes literature review on SNNs and TAPIP. Section 3 defines the general framework of the 3-stage prediction model, including the specific input, output, and structure of SNNs and CNNs. e processing of the new dataset is introduced in Section 4, and Section 5 presents the experiment results. Finally, Section 6 provides concluding statements on our work.

Spiking Neural Networks in Traffic Domain.
With the rapid development of artificial intelligence and computer technology, deep learning has been widely applied in traffic domain, including traffic state prediction [8,9], traffic signal control [1,10], and driving model development [11]. e works mentioned above are all based on artificial neural networks (ANNs), where the neurons use differentiable, nonlinear activation functions. Although ANNs have achieved great performance in wide areas including classification, pattern recognition, and prediction, they are fundamentally different in structure, neural computations, and learning rule compared to the brain [7]. e way of information propagation between units is one of the most obvious differences. While ANNs rely on 32 bit or 64 bit continuous messages sent between units [12], the neurons in biological brain broadcast trains of action potentials, also known as spike trains to downstream neurons. As the thirdgeneration neuron model, spiking neural networks (SNNs) are close to biological principle by utilizing spikes. When dealing with complex or large datasets, while ANNs face the concern of huge computational consumption, SNNs achieve energy efficiency since output spike trains can be made sparse in time [13]. Besides that, SNNs improve the traditional neural models on accuracy due to the advantage of being sensitive to the spatial-temporal characteristics of information [7]. Although still in the early stages of development, SNNs have become the focus of many application areas and made progress in visual processing [12], speech recognition [14], and medical diagnosis [15].
However, SNNs till now are rarely used in traffic domain, despite their specialized capability in representing spatialtemporal data. Laña et al. [16] presents an approach for spatial-temporal road traffic forecasting that relies on the adoption of the NeuCube architecture based on SNNs. Taking advantages of the NeuCube platform, this work focuses on the spatially-aware traffic variable forecasts and on the exploration of the spatial-temporal relationships among different sensor locations within a traffic network. In another work of Laña et al. [17], an evolving spiking neural networks (eSNNs) based adaptive long-term traffic state estimation model is proposed. By using similarity-based clustering of daily traffic volume data and monitoring them in real time, the model encodes traffic data into spikes over the time domain effectively and achieves high accuracy in online prediction when new data samples arrive.

Post-Impact Prediction of Traffic Accident.
At present, the main research methods in predicting the impact of highway accidents are the traffic wave theory [18,19], vehicle arriving-departure model [20,21], regression model [22,23], decision tree model [5], and ANNs [23,24]. Yu et al. [18] analyzed the accumulation and dissipation process of the accident location on two-lane highway, using the shockwave theory as a foundation, and finally estimated the spatialtemporal impact of the accident. However, such methods based on theoretical analysis considered only limited influencing factors (flow and density of upstream) and only showed general laws that lead to poor applicability. Zhu et al. [23] established two kinds of forecasting models of spatialtemporal impact for traffic accidents based on nonlinear regression and BP neural networks, where the influence of factors were analyzed such as upstream flowrate, ratio of cargos, and accident handling time. e results showed that the BP neural network achieves higher accuracy. Lin and Li [24] embedded three machine learning algorithms in a hierarchical scheme to perform sequential prediction. e result outperformed others by achieving a MAPE range of 5.5-53.8%. However, it just considered the time duration of an accident rather than spatial impact. In contrast, Lee et al. [25] only focused on estimation of vehicle accident queue length using the ANN model with relatively abundant influencing factors. e methods above theoretically described and inferred the characteristics of incidental accidents and analyzed the influence of various factors on accident indicators. But they have not established a complete relationship model between the influencing factors and the spatial-temporal impact of the accidents. Furthermore, related works all used one model to output all prediction variables regardless of the characteristics in different phases of accidents. However, the five phases are closely related and can have great influence on each other. us, in order to fully capture the spatialtemporal features in the whole process, the prediction should be made separately according to the order of phase.
Since the prediction of accident impact highly relies on feature extraction of spatial and temporal data, SNNs are considered to be a more suitable method due to its characteristics compared with the models mentioned above. However, no such SNNs-related models have been proposed till now.

Methodology
is work proposes a spatial-temporal post-impact prediction model of traffic accidents. e 3-stage process is shown in Figures 2 and 3, where Figure 2 corresponds to the training process using historic accident records (training set) and Figure 3 corresponds to the predicting process using new accident records (test set). Stage 1 is the prediction of accident clean-up time; it uses clusters to define length hierarchy of clean-up time and then extract accident features to train the SNNs classifier. Stage 2 concerns with a prediction model of spatial-temporal impact based on CNNs and backpropagation neural networks (BPNNs), feeds with flow and speed data, and outputs the recovery time and accumulative queue length. When a new accident record comes to the model after being processed with the above two stages, another online updating stage will be promoted to correct error and revise model. e notations used frequently in the 3-stage model are given in Table 1.

Stage 1: Accident Clean-Up Time Prediction.
According to the two-phase accident lifetime defined in Section 1, phases are not completely independent and can influence each other. erefore, in order to figure out the spatial-temporal impact in the whole process, we need to predict the duration of clean-up phase first.
Mean-shift clustering is first performed on the clean-up time, which groups the clean-up time into several intervals. us, the accidents with similar cleaning difficulty are labeled as a cluster. Furthermore, the accident records with attributes and corresponding class labels are input to train an SNNs classifier. Whenever a new accident record comes in, the accident attributes are extracted and then classified using the trained classifier. e predicting clean-up time is represented by the centroid value of its corresponding cluster.

Clustering Using Mean-Shift.
According to the statistics in Section 4, the clean-up time of the accidents distributes unevenly throughout the interval. It exists the case where some of the interval lack records. us, to improve the prediction accuracy and remove exceptional, clustering the clean-up time into groups and using the centroid value to present the predicted value is better than a direct prediction model. e mean-shift algorithm [26] is chosen to cluster the clean-up time for two main reasons: it does not require a predefined number of clusters; and such density-based algorithms are less affected by the mean value compared with the K-means algorithm. e key operation of the algorithm is to calculate the drift vector of the centroid through the data density change in the region of data, so as to move the centroid in the next iteration until it reaches the maximum density. Algorithm 1 shows the procedure of clustering the traffic records according to the clean-up time. e bandwidth is set as 10.

Accident Characterization.
When a new accident record comes to the model, in order to predict the clean-up time, the cluster that the records belongs to needs to be figured out. us, a number of attributes that represent the characteristics of accidents are used to train a classifier, which outputs the corresponding cluster.
More detailed information of data processing can be found in Section 4.

Classification Using SNNs.
A classifier is trained to match the accident attributes to the cluster it belongs to. Due to the characteristics of being sensitive to the spatial-temporal features, SNNs are applied in building the classifier. It is the first time of applying SNNs in traffic accident prediction domain.
After being first proposed in 1997 by Maass [6], SNNs have attracted researchers to explore different research directions.
e main technique directions of SNNs can be concluded in four main categories: encoding and decoding of spiritual information, neuron models and network simulation strategy, similarity measurement of spiking sequence, and synaptic weight learning rules [32]. e classification problem in this work concerns with the supervised learning in SNNs, which refers to finding a suitable synaptic weight matrix for a series of given input spike trains and target spike trains, so that the output of the neurons is as close as the corresponding target spike trains, that is, the error evaluation function of the two reaches minimum [33].
(1) Leaky Integrate-and-Fire Neural Model. Neural computing relies on the construction of the spiking neuron model. In order to do numerical analysis, an efficient mathematical neural model should be built based on the geometry and electrical properties of neuron. Leaky Integrate-and-Fire neural (LIF) model [34], as the single compartment model with fixed threshold which has been widely used in neural computing, can directly describe the relationship between membrane potential V and input electric current I. When V is between the resting potential V rest and the threshold V thre , it is given by the following equation: where τ m is a time constant, and I is the sum of current released by presynaptic neurons. Once V crosses V thre from below, a spike is generated and V is reset to V rest . e LIF model, with the advantages of using simple structure to realize accurate simulation of SNNs by event-driven simulation strategy, is chosen as the basic neuron model in our work.
(1) Input (2) T c ≔ dataset of clean-up time over which the procedure is performed (3) Initialization (4) r ≔ the radius of a region (5) d ≔ the minimum distance between clusters (6) F(i, C j ) ≔ probability that point i belongs to Cluster C j (7) Repeat (8) Randomly select an unvisited point from the dataset as the starting centre point o c (9) Repeat (10) Find all the points that appear in the circle ⊙(o c , r) and group into cluster C o c (11) For

Journal of Advanced Transportation
(2) Gaussian Tuning Curve Coding. In the biological neural system, spikes are transmitted between neurons with different combinations. e corresponding rules and mechanisms of conversion between the stimulation signal and the spike trains are called neural coding [35]. When neuron feels external stimuli, encoding module encodes the stimulation signal to specific spike trains and responses; in turn, decoding module can estimate the stimulation signal from spike trains.
Researchers put forward various coding methods, which can be divided into two main categories: frequency-based coding [36] and time-based coding [37]. Evidence confirms that time-based coding is the more effective, since the time structure of the spike trains carries stimulus signals on a millisecond or even smaller scale, not just the average firing frequency [38]. With the introduction of more complex systems, single-neuron coding cannot effectively present the huge amount of information. Population coding [39] is thus proposed to solve complex information coding problem, where each neuron has a unique spike response distribution for a given stimulus, and the responses of the neuron population are combined to represent the overall information.
e population coding method used in this model is Gaussian tuning curve coding [40], as shown in Figure 4. A neuron covers a certain range of analog quantity in the form of Gaussian function, while the height of the corresponding Gaussian function to a certain value of the analog quantity determines the time for the neuron to emit spike. In this work, a population containing six neurons is used to encode the six accident attributes mentioned above. Figure 4 shows an example of how "block distance" of 0.18 miles is encoded into spike trains 0.79, 0.04, 0.52, 0.96, 1.00, 1.00 { }(ms).
(3) Multi-ReSuMe Training Algorithm. e supervised learning algorithm in SNNs can be divided into three categories based on the learning rules of synaptic weight: gradient-descent based method, synaptic plasticity-based method, and convolution-based method [41]. Gradientdescent based methods such as SpikeProp [40] learn from the error back propagation algorithm of traditional ANNs, where the state variables of the neuron model must have analytical expressions and lack biological realism. From a biological perspective, a training algorithm should update synaptic weights based on the temporal correlation of presynaptic and postsynaptic spikes, in keeping with the spike timing-dependent plasticity (STDP) theory [42]. In this work, a synaptic plasticity-based method called the multilayer remote supervised method (Multi-ReSuMe) [43] is used to train the classifier. Multi-ReSuMe extends the single-layer impulse neural network ReSuMe algorithm [41] to the multilayer network and overcomes some limitations as it can be applied to neurons firing multiple spikes, and it can in principle be applied to any linear neuron model. e main contribution of Multi-ReSuMe is the combination of the STDP and anti-STDP mechanism in one process, where synaptic weight update between hidden layer H and output layer O satisfies the following equation: For any excitatory synaptic connection from hidden neuron h to output neuron o, a synaptic strength w oh is potentiated whenever a target spike S d o (t) is observed and depressed whenever the trained neuron fires S a o (t). Here, s denotes a delay between the presynaptic and postsynaptic firing times, where h . e role of the noncorrelative factor a in equation (2) is to adjust the average strength of the synaptic inputs so as to impose on a neuron a desired level of activity. e kernels a pre and a post are STDP-related terms that define the shape of a learning window W(s) [44], where parameters A + , A − > 0 are the amplitudes and τ + , τ − > 0 are the time constants of the learning process. a pre (−s) gives the weight change if the presynaptic spike (the spike of the hidden neuron occurs) comes after the postsynaptic spike (the spike of the output and target neurons), while a post (s) gives the weight change if the presynaptic spike comes before the postsynaptic spike [43]. Similarly, synaptic weight update between input layer I and hidden layer H satisfies the following equation: As Figure 5 shows, the network has 36 input neurons corresponding to six accident attributes, and an output neuron representing the cluster that the input sample belongs to. e hidden layer contains 80 neurons which are fully connected with other layers. e output neuron's spike train contains a single spike, where the timing differs from each other, as given in Table 2. e process of building and training a Multi-ReSuMe-based classifier is given in Algorithm 2. e parameters are initialized as follows: A + � 1.2, A − � 0.5, τ + � τ − � 0.5, and a � 0.05 [45].

Stage 2: Accident Spatial-Temporal Post-Impact Prediction.
After the clean-up phase of an accident, the traffic flow will begin to recover from congestion to normal condition. Recovery phase is an important process which is often   neglected by the travelers and traffic management department, since people always regard clearance as the end of an accident, while the evacuation process afterwards plays a vital role in reasonable path planning. us, in this phase, several important values in the recovery phase will be predicted. First, the predicted clean-up time, matrixes of traffic volume, and speed at the occurrence of the accident are used to estimate the queue length at the end of the clean-up phase (or the beginning of recovery phase). A CNNs-based predictor is used in order to better capture the spatial features of the congested road. Second, the analysis of the recovery phase is based on a backpropagation neural networks (BPNNs), where the estimated queue length together with the historical average traffic condition are used as input. e final output of this stage can include full-recovery time, halfrecovery time, maximum accumulative queue length, and average accumulative queue length. Whenever a new accident record comes in, stage 2 will start when it receives the output clean-up time of stage 1.

Queue Length Estimation at the End of Clean-Up Phase
Using CNNs. During the clean-up phase, one or several lanes of the highway will be affected which leads to the reduction of capacity. According to the specific number of block lanes and block distance, there will be varying degrees of vehicle accumulation. If the block area is relatively small or the traffic volume is low, the traffic flow itself will absorb disturbance and cause little congestion. However, if high traffic volume meets the large block area, the accumulated queue will be very long, and it will be necessary for the travelers to change the travel plan.
Convolutional neural network (CNN) is a class of deep, feed-forward artificial neural network, which has been successfully employed to analyze visual imagery. Since the variables that influence the queue length in our model include traffic flow, speed, and the geometry of the block area, they can all be better presented by pictures. us, CNNs are the best choice since they behave well in extracting spatial features from images so as to fully understand the spatial characteristics around the block area. A CNN consists of an input and an output layer, multiple convolutional layers, and optional hidden layers such as pooling layers, fully connected layers, and normalization layers. Figure 6 shows the demonstration of how these layers can be combined to build a CNN according to the requirement [1]. Convolutional layers apply a convolution operation to the input and pass the result to the next layer, so as to achieve feature extraction [46].
(1) Traffic Environment Preprocessing. e definitions and representations of the traffic environment are very important, as the accuracy of prediction is dependent on the effectiveness of the information received about the environment. To take advantage of the CNNs, the environment is processed as three pictures in the model: a picture of geometry showing the block area, a picture of the vehicle speed, and a picture of the traffic flow. A representation of this process is shown in Figure 7, where an accident blocks two lanes with 0.23 miles on a four-lane highway. Noticing that the red arrow shows the location of sensors (spread unevenly), and the grey dotted lines in Figure 7(a) represents how the picture is divided into grids that is long in 0.1 miles and wide in lane width. Figure 7(b) shows the trafficability of each grid, where the block area is set to 0, and other normal area is set to 1. e corresponding average flow (vehicles/hour) and average speeds (miles/ hour) are shown in Figures 7(c) and 7(d). e data in each grid are always accessed from the nearest sensor and later normalized. e total length is set as 5 miles, which means 4 × 50 grids. ese settings ensure that the environment is accurately and sufficiently represented and also not too complex for the CNNs to understand. a 2 , a 3 , a 4 , a 5 , a 6 , c) (4) e target ≔ the minimum value of network error to reach when learning is considered converged (5) W ≔ synaptic weight between all neurons (6) M ≔ maximum number of iterations (7) Initialization (8) W← Initial synaptic weight with random value θ ∼ U(0.2, 0.8) 1 , a 2 , a 3 , a 4 , a 5 , a 6 , c) to a series of spike trains Set membrane potential of all neurons to the resting potential (set to 0) (13) Pass input spike trains to the network and find actual output spike S a o (14) Calculate network error Compute weight modifications ΔW for all layers according to equation (2) and equation (4)   Journal of Advanced Transportation

Prediction of Spatial-Temporal Impact in Recovery
Phase Using BPNNs. At the beginning of the recovery phase, the block area will be removed and the traffic will gradually return to normal condition. us, the environment in this phase can be described as a simple congestion propagation model in the straight closed road. Shock wave theory [47], proposed in 1955, regards traffic flow as a continuous fluid with a linear flow-density relationship and has been applied widely in the congestion propagation analysis. However, it only concerns constant flow and density and neglects stochastic effects.
is work fully considers the uneven distribution of traffic in the upstream and downstream and uses a BPNNs-based predictor to capture the nonlinear relationship between model input and output that estimate spatial-temporal impact variables such as full-recovery time, half-recovery time, maximum accumulative queue length, and average accumulative queue length. Similar to Section 3.2.1, we also train three BPNNs models corresponding to 4-lane case, 5-lane case, and 6-lane case. Each BPNN receives inputs including the speed and flow of each lane at the beginning of recovery phase together with the predicted queue length, and after processing through a hidden layer, it outputs a number representing the spatial-temporal impact variable. Note that a separate BPNN is trained for each variable. It is worth mentioning that in the predicting process shown in Figure 3, the instant traffic data are represented by the historical average value to improve accuracy. For example, if the predicted recovery phase of an accident starts at 2021/6/20, 8 : 00 (Sunday), the speed and flow data will be accessed through calculating the average value at the four most recent "Sunday 8:00." . Figure 9 shows the structure of the 4-lane BPNN model, which has 17 input neurons and 9 hidden neurons. e 5-lane model has 21 input neurons and 11 hidden neurons, while the 6-lane model has 25 and 13. Learning rate is set as 0.005, and the training ends when mean square error reaches 0.001. e process of acquiring actual recovery time and accumulative queue length is detailed in Section 4.

Stage 3: Online Updating.
After stage 1 and stage 2, the whole lifetime of an accident has already been predicted. It is expected that most accidents will be classified accurately, and the predicted spatial-temporal variables will match the actual one within a fault tolerance. However, some of the predictions can have long time span using the information at  Journal of Advanced Transportation the first beginning. Long-term prediction has always been a difficulty and errors must exist. e most influencing part would be the clustering and classification accuracy, since the error will continue to propagate and cause more serious errors in the following stages. at is the reason for proposing stage 3: detecting the error during the development of the accident and making timely adaptation and revision. Furthermore, the revised values can also help to modify and update the models in stage 1, namely, mean-shift-based clustering and SNNs-based classification.

Error Detection and
Adaptation. e first step in the online updating stage is to detect if the predicted clean-up time is excessively deviating from the true value. As Figure 10 shows, the detection process is carried out every 5 minutes starting from the occurrence of an accident. e cause of errors can be divided into two situations: (i) T clA > T clP : the accident has not been totally cleaned in the predicted clean-up time; then, the stage 2 is repeated every 5 minutes until the accident is cleaned. (ii) T clA < T clP : the accident is cleaned earlier than predicted; then, the current time is set as the actual clean-up time and is used to repredict in stage 2.
is process makes up for the shortcomings of long-term prediction and helps the model to predict more accurately.

Clustering and Classification
Updating. Another benefit of online stage is the modification of the clustering and prediction model when new knowledge is found along with the incoming accidents. As Figure 11 shows, the process starts with finding the actual closest cluster C A for T clA . en, it can be divided into the following two situations:  (ii) C A ≠ C P : the accident is not classified into the proper cluster and the error is caused by the misclassification of the SNNs classifier. en, another classification updating is needed where the accident attributes and its actual cluster C A is added to the SNNs training set and later used to retrain the SNNs model.
is process helps to describe accidents that are not available in the training dataset and further improve the overall accuracy of the model.

Dataset
is section describes the process of constructing a California statewide spatial-temporal traffic accident dataset (CASTA), using two datasets named US accident [48] and California Department of Transportation (Caltrans) Performance Measurement System (PeMS) [49].
US accident is a countrywide traffic accident dataset, which covers 49 states of the United States. e data are continuously being collected from February 2016, containing about 3.5 million accident records currently.
PeMS provides access to real-time and historical performance data in many useful formats and presentation styles, including a consolidated database of traffic data collected by Caltrans placed on state highways throughout California, as well as other Caltrans and partner agency datasets.
To figure out the spatial-temporal impact of each accident, we use the process shown in Figure 12 to match and  Table 3. For better representing the spatial characteristics of accidents, the statistical distribution of clean-up time (sum of detection, verification, response, and clearance time) of the selected records is shown in Figure 13, from 16 min to 8 h 40 min. It can be figured out that the clean-up time is not distributed evenly in the range, where more than 96% of the records fall in (25,120], and (25,30] is the interval with the highest amount. However, the records with clean-up time less than 25 min or higher than 240 min are not representative and not enough to train the model. us, we only include 11940 pieces of records with clean-up time fallen in (25,240] minutes in the experiment.

Data Integration.
e data integration process is about matching the traffic flow and speed data with traffic accident records. First, we extract the latitude and longitude coordinates and time of each accident record, denoted as 〈lat, lng, t〉. Second, we find the nearest sensor to that coordination in PeMS and extract the flow and speed data after t e . ird, concatenate the PeMS and US accident to form the new raw dataset. Note that disabled detectors have already been filtered out.

Data Extraction.
By comparing with the upstream flow/ speed after t e , figure out the accident full-recovery time T frA , half-recovery time T hrA , maximum accumulative queue length L maxA , and average accumulative queue length L aveA according to Algorithm 3. e final dataset CASTA consists of 20 attributes that fall in 6 main types as given in Table 4.

Experiments and Results
Methods proposed in Section 3 have been tested with the CASTA dataset, and the results are discussed in this section. Among the 11940 pieces of records, 9940 of them are randomly chosen as the training set, while the rest 2000 are used as the test set. Since no similar previous work that predicts the whole accident process has been proposed yet, the comparison is carried out in each stage, respectively. First, the outcomes of the first two stages without the online adaptation are presented. Second, the online stage is added to test how the outcomes have been improved. Experiments have been implemented on the server with four CPU (Intel Xeon (R) CPU E5-2650 v2 @ 2.60 GHz), 32 GB RAM.

Clean-Up Time Analysis.
e efficiency of the initial clean-up time prediction is essential to the following stages, since the error will be further propagated and lead to larger mistakes. According to the cluster results, the clean-up time has been divided into 13 groups, where group 13 is a noise cluster. Table 5 presents the interval of each group and its corresponding centroid value.
When comparing the performance of classifiers, the classification accuracy which means the proportion that predicted class is equal to the real class is usually calculated. However, in this case, since the specific value of clean-up time is more important than the class, the classification accuracy is replaced by the MAPE and RMSE in the following equations, respectively, by comparing the predicted clean-up time T clP and actual clean-up time T clA .
In order to verify the suitability of our proposed model (mean-shift clustering and SNNs classifier), several methods have been selected as comparison benchmarks: nonlinear regression [50], KNN [51], ANNs, and mean-shift clustering and ANNs classifier. Noticing that the first three benchmarks directly build the relationship between accident attributes and clean-up time without the clustering process, while the fourth replaces the SNNs classifier by ANNs. e experiment results are given in Table 6. Our proposed method outperforms all other benchmarks in accuracy and   I-5  I-805  I-8  I-15  I-405  I-605  I-10  I-880  I-80  I-280  I-680  Total  San Diego  694  484  391  258  0  0  0  0  0  0  0  1827  Orange  523  0  0  0  410  25  0  0  0  0  0  958  Riverside  0  0  0  284  0  0 T c ≔ sum of detection, verification, response, and clearance time of traffic accident e (8) Initialization (9) F dissipate ←false means if the traffic flow is in dissipating process (10) v threshold ←10mile/h means the vehicle is low-speed driving or waiting (11) For t i in T do (12) For s j in S do (13) If v s j ,t i > v threshold (14) en If L maxA < distance(s e , s j ) (15) en update L maxA � distance(s e , s j ) If distance(s e , s j ) < L maxA /2 (19) en T hrA � t i − t e (20) End if (21) End if (22) Update L aveA ←((j − 1) * L aveA + distance(s e , s j ))/j (23) Break (24) End for (25) If j � 1 and F dissipate � true (26) en update T total � t i − t e (27) Break (28) End for (29) T frA � T total − T c (30) Output (31) T frA ≔ full-recovery time of traffic accident e (32) T hrA ≔ half-recovery time of traffic accident e (33) L maxA ≔ maximum accumulative queue length (34) L aveA ≔ average accumulative queue length ALGORITHM 3: Data extraction from dataset. training time. Mean-shift clustering and ANNs classifier ranks first in the comparing methods, but still needs more running time and higher MAPE and RMSE. e other three benchmarks achieves unsatisfied prediction accuracy due to the lacks of combination of clustering and classification. e results prove that clustering the records into classes and using the centroid value to present the predicted value is better than direct prediction model when the data are dispersive distributed, as well as the suitability of applying SNNs in capturing spatial and temporal features. For better analysis of the model performance, the accuracy in each interval is calculated, respectively, as given in Table 7. It can be figured out that MAPE and RMSE are relatively low in intervals with abundant records, e.g., [25,30) and [40,50). In contrast, the prediction difficulty of intervals that clustered as noise (e.g., [120, 240)) is relatively high and the accuracy is not satisfied due to insufficient training. Fortunately, the probability of such severe accidents is low enough and will not cause frequent impact on traffic. Furthermore, with the increase of historic accident data, those outliers can be removed from the noise cluster and the accuracy can be further improved.

Clean-Up Phase Queue Length Analysis.
In this section, the performance of CNNs based queue length prediction is analyzed, using the output of the previous stage. Comparison benchmarks include the shockwave theory [18], nonlinear regression, and ANNs. Shockwave theory assumes that the traffic flow and speed is constant at the accident site and upstream. It takes traffic flow as a continuous fluid with a flow (q)-density (k) relationship and uses equation (7) to calculate the shockwave when the state of a traffic stream changes from (q i , k i ) to (q j , k j ) [18]. e length of block area is neglected in the shockwave theory.
Due to inability of capturing picture input, other two benchmarks set up relationships between constant flow, speed, block length, and queue length.
In Table 8 e proposed CNNs based model still outperforms other benchmarks in MAPE and RMSE in all three cases. Shockwave theory is unable to make efficient prediction due to unrealistic assumption, while nonlinear regression and ANNs make similar performance but are still not satisfied due to constant traffic information. Considered together with the distribution of queue length shown in Figure 14, the 4-lane model and 5-lane model have simple environment that leads to high prediction accuracy. With the increase of lanes, the traffic itself can absorb the disturbance better; thus, the accumulated queue length becomes shorter. at explains the high MAPE but low RMSE in 6-lane case.
e MAPE of 6-lane cases grouped according to the length of the queue is also calculated and shown in Figure 15. It can be concluded that the MAPE of queue length in [0.4, 2.2) miles is below 20%, while the model performs relatively poor when the queue length is below 2 miles and above 2.2 miles. e cause of error in low queue length is the quality of the PeMS dataset, where the distance between sensors is not small enough to give accurate queue length. For example, if the actual queue length of an accident is 0.06 miles while the distance between the closet sensors is 0.1 miles, then the queue length will be regarded as 0. at kind of errors will greatly affect the model performance, especially in low queue length cases. Meanwhile, when the accumulative queue length is greater than 2.2 miles, the model needs larger input to capture the environment, and thus, 5-mile is not enough to make accurate prediction. ough the proposed model has already achieved better performance than other methods, the accuracy would still improve if trained by a more complete dataset. e merging  process of US accident and PeMS can expand the error in some situation. For example, the coordination bias errors in US accident will result in an offset when matching the closet sensor in PeMS.

Recovery Phase Spatial-Temporal Impact Analysis.
In the last stage of the offline prediction, the model will give out the final predicted spatial-temporal impact during the recovery process. Comparison benchmarks include shockwave theory, nonlinear regression, and BPNNs (base). e proposed model will use the output data of the CNNs model in the previous stage, while shockwave theory and nonlinear regression will still be based on the result using the same method, which means the performance analysis already includes the error of previous stages.
Comparing to our proposed model that uses historical average flow/speed as input, the BPNN (base) only uses the value at the beginning of the recovery phase. According to the results given in Table 9, the error of the shockwave theory and nonlinear regression continues to expand. e MAPE of maximum accumulative queue length even reaches 40.47%, which losses its reference value. e BPNN (base) stably ranks the second under all assessment criteria, just behind our proposed method. Due to the comprehensive representation of traffic environment and the use of historical average value, the proposed model achieves satisfying performance, where the MAPE of four impact variables are all below 20%. Although there is no existing work considering the whole accident process that can be used as comparing benchmark, the above separate comparison in each offline stage still illustrates the effectiveness of our proposed method. e offline part can be regarded as the combination of three different models developed for the characteristics in each stage, and the advantages are further expanded after the combination.

Online Prediction Analysis.
Although the accuracy of offline prediction is already much higher than other comparing benchmarks, it is still not satisfying enough for providing precise information and guidance for governments and travelers. Especially for accidents with long time span, as shown in Figure 16, the error can be as large as 40%.      To compensate for the difficulty in long-term prediction, the online prediction phase is carried out and analyzed to see how much improvement it can bring. Taking the 6-lane cases as examples, 10 accidents in each clean-up time interval given in Table 10 are chosen as the test set (60 accidents in total) in this stage. According to statistical results given in Table 10, the actual clean-up time of 29 accidents is larger than the predicted ones, while 28 is smaller, and the rest 3 are equal. Apply error detection and adaptation mechanism to these test cases, and an averaged result per interval is given in Table 11. Reduction of MAPE is visible from any interval and impact variable when the final adaptation is done.
To further find out how the improvement is made in each test case, the detailed MAPE difference in full-recovery time of 60 cases is shown in Figure 17, where values above 0 represent cases with less error, while negative values represent cases with more error. It can be concluded that most of the cases except for one accident (in red) experienced lower MAPE, and the differences range from −0.28% to 32.98%. Along with the increase of accident clean-up time, the improvement becomes more evident. at is reasonable since cases with longer clean-up time always experience more times of adaptation.
In Figure 18, 6 accidents are randomly picked to show how MAPE of full-recovery time changes along with the increase in adaptation times, where the adaptation interval is 5 minutes. e overall trend for all cases is gradually decreasing, where the least of them has experienced one adaptation, while the most has experienced 8 times of  adaptation. Even after a few times of adaptation, the model can achieve a much better accuracy, which conveys the effectiveness of this mechanism.
In the second step of online stage, the clustering and prediction model will be modified and updated to improve the future prediction. To reduce workload, this process should be carried out until a batch of data has been gathered. Due to the dataset size limit, there is no enough cases to support to show the obvious change in model parameters and improvements after retraining. us, the result analysis of this step is not represented in this work, but can be supplemented when applied to more datasets in the future.
All of the results and discussion above point to the same conclusion: the introduction of online stage can greatly improve the model performance.

Conclusions
Traffic accidents post-impact prediction (TAPIP) plays an important role in traffic management. In this study, a 3-stage TAPIP model on highway is proposed and tested by the dataset CASTA. Using the advantages of SNNs, the model builds a comprehensive relationship between the spatialtemporal features of accidents and clean-up time. e   combination of clustering and classification improves the prediction accuracy. Due to the capability of CNNs to fully capture the spatial characteristics of traffic environment and the use of historical average data, the model achieves effective prediction of post-impact variables (e.g., fully-recovery time, half-recovery time, maximum accumulative queue length, and average accumulative queue length). A new dataset CASTA that describes California statewide spatial-temporal traffic accidents is constructed and used to test the model. Experiment results prove that our model performs better in accuracy and running time than several existing benchmarks, including nonlinear regression and KNN. e introduction of online adaptation and updating the mechanism further expands the advantages of the model. is work implements a framework that describes the whole process of a traffic accident and captures the spatialtemporal characteristics in each phase. When applied in real world, whenever an accident takes place, the whole process can be predicted immediately. It proves the reliability and efficiency in applying SNNs in traffic domain, especially in accident prediction research. With regards to future work, we acknowledge that this work is not perfect and that there are still many aspects that can be improved upon. First, the dataset with more detailed accident information and higher quality traffic data can be used to improve the model performance. Second, accidents with clean-up time longer than 240 or shorter than 25 minutes can be further added into the model when enough records have been gathered.
ird, clustering and classification updating in online stage needs further experimental demonstration. Last, the model can be extended to city roads rather than limited to highways.

Data Availability
All data and program files included in this study are available from the corresponding author upon request.

Conflicts of Interest
e authors declare that there are no conflicts of interest.