# A Density-Based Random Forest for Imbalanced Data Classification
## 3 Methods
### DBRF Algorithm
For the metal glass dataset, GM decreased as \(\eta\) increased, whereas F1 and _Accuracy_ increased. The main reason for the growth of F1 is that as the number of majority classes increased, the model's prediction accuracy gradually increased for the majority class and gradually decreased for the minority class samples. The increase in the majority class compensated for the decreases in the minority class, resulting in an increase in F1 with increasing \(\eta\). For the Haberman's survival dataset, both GM and F1 decreased with increasing \(\eta\), and _accuracy_ increased with increasing \(\eta\). The experimental results were consistent with our expectations. For the vehicle evaluation dataset, _accuracy_, F1, and GM first decreased and then gradually stabilized as \(\eta\) increased. This shows that \(\eta\) for the vehicle evaluation dataset could only be adjusted to one. When \(\eta\geqslant 2\), the density domain contained all the majority samples. Therefore, there was a sharp drop when \(\eta=1\) and \(\eta=2\). \begin{table}
\begin{tabular}{c c c c} \hline \hline  & & \multicolumn{2}{c}{**Predict**} \\ \cline{3-4}  & & **Minority Class** & **Majority Class** \\ \hline \multirow{2}{*}{Actual} & Minority class & TP & FN \\ \cline{2-4}  & Majority class & FP & TN \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Confusion matrix. Figure 4: Data visual distribution for synthetic dataset paw50 with different \(\eta\). Here, (**a**) is the original dataset; the red point is the minority class, and the blue point is the majority class. In (**b**–**f**), the red and gray points are the minority class samples in the entire dataset, whereas the green and blue points are the majority class samples in the entire dataset. The red points show the boundary domain. The gray points show the minority class with a clear decision boundary. The green points show the majority class selected by the \(DBRF\) algorithm. The green, red, and gray points form the density domain. Figure 5: Three real-world datasets on (**a**) the metal glass, (**b**) [PERSON]’s survival, and (**c**) vehicle evaluation with different \(\eta\). The horizontal axis is the \(\eta\), and the vertical axis shows the F1, GM, and _accuracy_. Figure 6 presents the results obtained on the metal glass, vehicle evaluation, and [PERSON]'s survival datasets with different values of \(p\). It can be observed that the overall accuracy decreased as \(p\) increased in Figure 6. Although the recall of the minority class increased with increasing \(p\), the majority class was also miscategorized. Through F1 and GM, the results showed that after \(p=0.5\), the performance of the model began to decline, mainly because the prediction accuracy of the majority class began to decline. Therefore, for the metal glass dataset, \(p\) was set at 0.4. In Figure 6, for the vehicle evaluation dataset, it can be observed that DBRF outperformed the base model RF for F1 and GM. The reason that DBRF was higher in F1, GM, and _accuracy_ than those of RF was mainly that the \(TP\) of the other two models was very low, while \(DBRF\) compensated for the drop in \(FP\) due to the increase in \(TP\). Therefore, the F1 and GM of DBRF were higher than those of RF. Therefore, the best \(p\) value for the vehicle evaluation dataset was 0.5. In Figure 6, for the [PERSON]'s survival dataset, it can be seen that the F1 and GM of \(DBRF\) were higher than those of RF. To avoid losing too much overall accuracy, we set \(p=0.6\). When \(p=0.6\), the F1 and GM of the DBRF were improved, and the overall accuracy loss was less. Figure 7 shows a box plot of the 10-fold cross-validation on the three datasets with the best \(p\) and \(\eta\). Figure 7 indicates that the maximum value of DBRF was larger than that of the base algorithm RF, and the minimum value was larger than that of RF. In addition, the distribution of the 10 experimental results revealed that DBRF was relatively stable.