## 3 Methodology
### The ReMAHA Algorithm
#### 3.2.4 ReMAHA
The \(F_{\beta}\) score is used to provide a weighted harmonic mean of precision and recall [41]. Its calculation is as follows:

\[F_{\beta}=\frac{1}{C}\frac{C}{i=1}\frac{(1+\beta^{2})\times Precision_{i}\times Recall _{i}}{\beta^{2}\times Precision_{i}+Recall_{i}} \tag{15}\]

The F1-Score is the most commonly used \(F_{\beta}\) score, where \(\beta\) is equal to 1. It balances precision and recall equally. ### The Impact of Clustering on Generated Data

Considering that at the algorithm level, the proposed model in this paper involves the selection of the number of clusters. To demonstrate the effectiveness of clustering in traffic accident prediction, we conducted experiments to investigate the impact of varying cluster numbers on the results. Given that oversampling algorithms primarily affect the minority class in imbalanced datasets, this experiment particularly focused on observing the effect of cluster numbers on labels 1 and 4 in the dataset. Clustering is one of the key steps of the model proposed in this paper, and Figure 4 depicts the relationship between the number of clusters and the F1-Score. In this experiment, experiments were conducted from the number of clusters being 1 to 9. Considering the problem of the relatively large amount of data, we choose mini batch K-means as the clustering method. In Figure 4, the relationship between the number of clusters and the F1-Score variation is illustrated. When the number of clusters is set to 1 (i.e., the entire category forms a single cluster without clustering), the performance is relatively poor compared to cases where clustering is applied. Within a smaller range, the F1-Score improves as the number of clusters increases. However, when the number of clusters becomes excessive, it may lead to highly consistent features within clusters, potentially resulting in unstable quality in the generated data. \begin{table}
\begin{tabular}{c c c} \hline \hline  & **Predicate Positive** & **Predicate Negative** \\ \hline True Positive & TP & FN \\ True Negative & FP & TN \\ \hline \hline \end{tabular}
\end{table} 
Table 8: Confusion matrix. ### Quality Comparison of Data Generated by Sampling Algorithms

In the previous section, we assessed the impact of internal parameters on model performance. In this section, we compare ReMAHA with different sampling algorithms. At the data level, we compared three oversampling algorithms, namely, SMOTE [19], ADASYN [42], and random oversampling, with the proposed ReMAHA. The parameters used in the sampling models during the experiments are as follows (Table 9):

We used three oversampling algorithms, SMOTE, ADASYN, and random oversampler, and compared them with the proposed ReMAHA method. The predictive models in all cases were CatBoost. The experimental results are shown in Table 10.

Figure 5 shows that the addition of oversampling improves the predictive performance, with a significant increase in the number of predictions for minority class samples. \begin{table}
\begin{tabular}{c c c c c c} \hline \hline
**Class** & **Metric** & **SMOTE** & **ADASYN** & **ROS** & **ReMAHA** \\ \hline \multirow{3}{*}{Severity 1} & Precision & 52.91 & 43.05 & 29.21 & 71.41 \\  & Recall & 85.12 & 81.96 & 97.46 & 75.60 \\  & F1–Score & 65.26 & 56.45 & 44.95 & 73.44 \\ \hline \multirow{3}{*}{Severity 2} & Precision & 93.26 & 91.65 & 90.81 & 91.51 \\  & Recall & 93.82 & 91.34 & 93.54 & 94.57 \\  & F1–Score & 93.54 & 91.49 & 92.15 & 93.02 \\ \hline \multirow{3}{*}{Severity 3} & Precision & 78.01 & 69.02 & 73.93 & 73.43 \\  & Recall & 69.96 & 61.52 & 57.90 & 64.63 \\ \cline{1-1}  & F1–Score & 73.76 & 65.06 & 64.94 & 68.75 \\ \hline \multirow{3}{*}{Severity 4} & Precision & 40.28 & 33.47 & 73.05 & 76.31 \\ \cline{1-1}  & Recall & 53.90 & 53.46 & 33.56 & 53.23 \\ \cline{1-1}  & F1–Score & 46.11 & 41.17 & 45.99 & 62.71 \\ \hline \hline \end{tabular}
\end{table} 
Table 10: Performance of each sampling model (%). Figure 4: The impact of cluster variations on F1–Score graph.