## 2 Materials and Methods
### Data Mining Techniques for PPRE Analysis  
In this section, we describe two data mining techniques used to elicit useful information for an in-depth understanding of potential pedestrian risky events: K-means clustering and decision tree methods. K-means clustering: Clustering techniques consist of unsupervised and semi-supervised learning methods and are mainly used to handle the associations of some characteristic features [28]. In this study, we considered each frame with its extracted features as a record, and used k-means clustering to classify them into categories which could indicate degrees of risk. The basic idea of k-means clustering is to classify the dataset \(D\) into \(K\) different clusters, with the classified clusters \(C_{i}\) consisting of the elements (records or frames) denoted as \(x\). The set of elements between classified clusters is disjointed, and the number of elements in each cluster \(C_{i}\) is denoted by \(n_{i}\). The k-means algorithm consists of two steps [29]. First, the initial centroids for each cluster are chosen randomly, then each point in the dataset is assigned to its nearest centroid by Euclidean distance [30]. After the first assignment, each cluster's centroid is recalculated for its assigned points. Then, we alternate between reassigning  
\begin{table}
\begin{tabular}{c c c c c c c c} \hline \hline
**Spot \#** & **Event \#** & **Frame \#** & **VV (km/h)** & **VA (km/h\({}^{2}\))** & **PV (km/h)** & **DVP (m)** & **DVC (m)** \\ \hline
1 & 1 & 1 & 19.3 & 5.0 & 3.2 & 12.1 & 8.3 \\
1 & 1 & 2 & 16.6 & \(-\)2.1 & 2.9 & \(-\)11.4 & 6.2 \\  & & & & & & & \\
1 & 529 & 8 & 32.1 & 8.4 & 4.1 & 8.0 & 0 \\
2 &  
points to the cluster of its closest centroid, and recalculating those centroids. This process continues until the clusters no longer differ between two consecutive iterations [31]. In order to evaluate the results of k-means clustering, we used the elbow method with the sum of squared errors (SSE). SSE is the sum of squared differences between each observation and mean of its group. It can be used as a measure of variation within a cluster, and the SSE is calculated as follows:  
\[SSE=\sum_{i=1}^{n}(x_{i}-\overline{x})^{2} \tag{5}\]  
where \(n\) is the number of observations \(x_{i}\), which is a value of the \(i\)-th observation, and \(\overline{x}\) is the mean of all the observations. We ran k-means clustering on the dataset for a certain range of values of \(K\), and calculate the SSE for each result. If the line chart of SSE plotted against \(K\) resembles an arm, then the \"elbow\" on the arm represents a point of diminishing returns when increasing K. Therefore, with the elbow method, we selected an optimal number of \(K\) clusters without overfitting our dataset. Then, we validated the accuracy of our clustering by using the decision tree method. Decision tree: Decision trees are widely used to model classification processes [32; 33]. It is one of many supervised learning algorithms, and can effectively divide a dataset into smaller subsets [34]. It takes a set of classified data as input, and arranges the outputs into a tree structure composed of nodes and branches. There are three types of nodes: (1) root node, (2) internal node, and (3) leaf node. Root nodes represent a choice that will result in the subdivision of all records into two or more mutually exclusive subsets. Internal nodes represent one of the possible choices available at that point in the tree structure. Lastly, the leaf node, located at the end of the tree structure, represents the final result of a series of decisions or events [35; 36]. Since a decision tree model forms a hierarchical structure, each path from the root node to leaf node via internal nodes represents a classification decision rule. These pathways can be also described as \"_if-then_\" rules [36].