*3.2. Learning Process*

The purpose of this study is to prevent AVs-related accidents in advance by learning from the accident analysis of HVs. The dependent variables adopted for offender and victim identically consist of 5 different degrees of injuries such as death, serious injury, injury, minor injury, and no injury. Traffic accidents do not always consist of two parties, the offender and the victim. Sometimes there exists only one party case. For instance, when only vehicle damage is occurred with no human casualties (only one party), there exist only offenders. These cases also are incorporated into the learning process. The independent variables accounting for the seriousness of the injuries consist of road conditions, weather, road shape, number of lanes, and link speed (See Table 3). The learning was implemented by adding new factors such as time (T), day of the week (D), vehicle type of offender & victim (C), and violation of the law (L) in a step-by-step manner.


**Table 3.** Basic Data Variable Setting for Learning.

### **4. Design of Optimal Deep Neural Networks (DNNs)**

This chapter proposes an optimal DNNs for more accurate traffic accident prediction. The process of optimizing the model consists of three steps: setting up the data range—epoch—and hidden layers.

### *4.1. Environment on Building Algorithm*

This study intends to produce an optimal model of accident prediction based on the backpropagation algorithm [51] and SGD (Stochastic Gradient Descent) optimizer of the Tensorflow and Keras libraries [52,53]. The ratio of training and testing data was set at 8:2. It used the dropout of randomly skipping a certain amount between nodes in weight update for minimizing an overfitting. We experimentally confirmed that the highest prediction was achieved where the dropout value was set at 0.2. Also, we used ReLU (Rectified Linear Unit) function [54] to prevent gradient vanishing when using the Sigmoid function [55]. The batch size was set to 64 for stable learning.

### *4.2. Learning Data Range for Building optimal DNNs*

First, we performed DNNs using 2017, 2018, and 2017–2018 integrated data. For extracting optimal data range suited to the model, we set up the default model (RC, W, S, L, Sp; -1 set, which are only external factors) and simulated the degree of injury to the offender and victim as output. The prediction results show that the predicted accuracy of the degree of injury to the offender is over 80%. Also, it appeared that the 2018 data's prediction accuracy was higher by about 0.1–2.0% than the 2017 data, and the 2017–2018 integrated data was more accurate by about 0.5–1.5% than the 2018 data. The degree of injury to the victim showed about 60–65% accuracy, and prediction based on the integrated data was found more accurate by 0.5–2.5% than 2017, 2018 data. Therefore, we decide to implement the simulation by using the 2017–2018 integrated data set (See Table 4 & Figure 1).


**Table 4.** Offender/Victim Injuries Accuracy by datasets.

(**a**) Offender injuries accuracy

(**b**) Victim injuries accuracy 

**Figure 1.** (**a**) Offender Injuries Accuracy by dataset; and (**b**) Victim Injuries Accuracy by dataset: The red dash line rectangular stands for the highest accuracy at that factors in 2017–2018

### *4.3. Learning Data Epoch for Building Optimal DNNs*

Second, we performed DNNs by varying epoch, a state where one learning is completed for the entire data set within the network. When the epoch is set up on a large scale, training can cause overfitting, resulting in less accuracy in testing, verification, and application of new data. So, the step equally simulated one step (data range) process for extracting optimal data epoch. We set up epoch in five divisions of 100 units and simulated the degree of injury to the offender and victim as output. It is confirmed that the highest accuracy was achieved in both offender and victim at 100 epochs. The result suggests that the higher epoch was set up, the lower accuracy was shown due to overfitting. Therefore, we will simulate the study by setting 2017–2018 integrated data and 100 epochs (See Table 5).


**Table 5.** Offender/Victim Injuries Accuracy by Epoch.

### *4.4. Setting the Hidden Layers Building Optimal DNNs*

Third, we performed DNNs by setting the hidden layers and the number of nodes. The complexity of neural networks is determined by these two settings. It is important to set up the optimal node and hidden layers suitable to the model because model overfitting might occur and lead to poor learning. So, this means that the hidden layers and the number of nodes should be set up to suit this model.

For obtaining the optimal level of hidden layers and nodes, we tried to learn based on -1 Set. However, the results showed that the learning was not done properly due to a shortage in the number of features in -1 Set. Thus, we extracted a hidden layer based on "all data" which contained a default feature and new factors (Time, Day, Car of offender & victim, violation of Law).

Consequently, the prediction accuracy of injury to the offender was observed to be mostly higher than 84%, and the highest accuracy was 84.15% with (256,128,64,64) nodes in the hidden layers. The prediction accuracy of injury to the victim reached mostly higher than 64%, and the highest accuracy was 65.93% with (256,128,64,64) nodes in hidden layers as well. It suggests that the optimal hidden layers about traffic accident prediction is (256,128,64,64), which deduced output value to the converging process. Therefore, we will simulate the study by setting 2017–2018 integrated data, 100 epochs, and (256,128,64,64) hidden layers(See Figure 2 & Table 6).

> **Table 6.** Offender/Victim Injuries Accuracy by Hidden Layers.


(**a**) Offender injuries accuracy

(**b**) Victim injuries accuracy

**Figure 2.** (**a**) Offender Injuries Accuracy by Hidden Layers; and (**b**) Victim Injuries Accuracy by Hidden Layers: Different colored bars stand for the highest accuracy is derived from the hidden layers.
