## 3 Dataset Generation
### Accident Labeling Dataset  
An accident labeling dataset containing data selected using a proposed filter was established on the basis of the basic traffic dataset. The following factors were considered during the development of the filter.  
Vehicles typically travel at high speeds on highways. Changes in traffic density can considerably reduce vehicle speed, potentially resulting in traffic accidents. Therefore, data analysis must be performed to determine the association between changes in vehicle speed and the occurrence of traffic accidents [24]. In this study, a basic traffic dataset was used to calculate the mean vehicle speed difference in each 5 min period between every two neighboring gantries to determine whether a drastic speed change occurred. This speed difference was then used as the first criterion for the filter to select useful data.
2. In low-density traffic, vehicles travel at high speeds, allowing them to catch up with vehicles in high-density downstream traffic. The interaction of these two flows creates a discontinuous traffic wave, also known as a shock wave, which travels back upstream at a negative propagation velocity. In this study, ETC and VD data were used to obtain the traffic flow volume \(q\) and mean traffic speed \(v\). The relational equation \(q=k\times\
u\) was used to derive the traffic density \(k\). Subsequently, data conversion was performed to derive the velocity of the shock wave propagating toward the upstream traffic, \(v_{sw}\). This propagation velocity was used as the second criterion for data filtration. The following equation was used: \[v_{sw}=\frac{q_{b}-q_{a}}{o_{b}-o_{a}}\] (1) \(v_{sw}\) represents the propagation velocity of the shock wave (km/hour), and \(q_{a}\) and \(q_{b}\) respectively represent the vehicle flow before and after the condition changes (vehicles/hour). \(o_{a}\) and \(o_{b}\) respectively represent lane occupancy before and after the condition changes (vehicles/length).
3. As indicated by [PERSON] and [PERSON] [25], the relationship between space headway \(s\) and time headway \(h\) (Figure 1) can be used in combination with vehicle density \(k\) data to determine the mean headway. Figure 1 shows the space-time diagram of the relationship between space headway s and time headway h. The horizontal axis represents time \(t\) and the vertical axis represents space \(x\). \(s_{i}\) represents the space headway of the \(i\)th car and the \(i\)+1 th car. \(h_{i}\) represents the time headway of the \(i\)th car and the \(i\)+1 th car. \(v_{i}\) and \(v_{i-1}\) respectively represent the change in speed between car \(i\) and car \(i\)+1. According to the vehicle characteristics and relevant regulations in Taiwan, when the mean traffic speed is 60 km/h, the maximum speed limit is 110 km/hr, the headway threshold should be 50-100 m/veh. Therefore, in this study, a mean headway of \(<\)50 m/veh was used as the third criterion for data filtration.
4. In summary, three filtration criteria, namely drastic decreases in mean traffic speed, shock wave propagation velocity, and mean headway of \(<\)50 m/veh, were used in this study to identify and label traffic accidents.  
Figure 1: Relationship between headway and time.