# FedDB: A Federated Learning Approach Using DBSCAN for DDoS Attack Detection
## 4 Results
### Personalized Federated Learning Results  
The performance evaluation of the proposed method is based on four commonly used indicators, including accuracy, recall, precision and F1 measure. Accuracy--It reflects the percentage of correct predictions among all samples. It can be expressed by Equation (2). \[\text{Accuracy (acc)}=\frac{\text{Accurately classified records}}{\text{Total Samples}}\times 100 \tag{2}\]  
Recall--It defines the proportion of correctly predicted positive samples within the original positive data; it is described by Equation (3). \[\text{Recall}=\frac{\text{True Positive}}{\text{True Positive}+\text{False Negative}}\times 100 \tag{3}\] \begin{table}
\begin{tabular}{c c c c} \hline \hline
**Worker** & **FedAvg \(\alpha\) = 0.2** & **FedMe \(\alpha\) = 0.2** & **FedDB \(\alpha\) = 0.2** \\ \hline Worker1 & 0.76 & 0.89 & 0.91 \\ Worker2 & 0.7 & 0.6 & 0.96 \\ Worker3 & 0.94 & 0.97 & 0.97 \\ Worker4 & 0.73 & 0.96 & 0.96 \\ Worker5 & 0.95 & 0.98 & 0.99 \\ Worker6 & 0.87 & 0.92 & 0.95 \\ Worker7 & 0.95 & 0.99 & 0.99 \\ Worker8 & 0.85 & 0.99 & 0.99 \\ Worker9 & 0.75 & 0.97 & 0.96 \\ Worker10 & 0.98 & 0.98 & 0.95 \\ Avg & 0.85 & 0.92 & 0.97 \\ \hline \hline \end{tabular}
\end{table} 
Table 4: Each worker represents the accuracy rates achieved under various FL architectural configurations when alpha is set to 0.2. \begin{table}
\begin{tabular}{c c c c} \hline \hline
**Worker** & **FedAvg \(\alpha\) = 0.9** & **FedMe \(\alpha\) = 0.9** & **FedDB \(\alpha\) = 0.9** \\ \hline Worker1 & 0.93 & 0.88 & 0.95 \\ Worker2 & 0.7 & 0.71 & 0.88 \\ Worker3 & 0.95 & 0.95 & 0.97 \\ Worker4 & 0.98 & 0.99 & 0.99 \\ Worker5 & 0.87 & 0.92 & 0.93 \\ Worker6 & 0.98 & 0.98 & 0.98 \\ Worker7 & 0.92 & 0.96 & 0.97 \\ Worker8 & 0.91 & 0.97 & 0.97 \\ Worker9 & 0.88 & 0.92 & 0.92 \\ Worker10 & 0.98 & 0.98 & 0.98 \\ Avg & 0.91 & 0.93 & 0.95 \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Each worker represents the accuracy rates achieved under various FL architectural configurations when alpha is set to 0.9. Precision--It defines, among all the samples predicted as positive, the proportion that are actually positive. It is represented by Equation (4):  
\[\text{Precision}=\frac{\text{True Positive}}{\text{True Positive}+\text{ False Positive}}\times 100 \tag{4}\]  
F1 Score--It is defined as the harmonic mean of precision and recall. It is represented by Equation (5). \[\text{FI Score}=\frac{2\cdot\text{Precision}\cdot\text{Recall}}{\text{ Precision}+\text{Recall}}\times 100 \tag{5}\]  
To test the adaptability of our classification model under different data distribution scenarios, we designed a series of experiments. We used CrossEntropyLoss as the loss function and SGD as the optimizer, setting the initial learning rate to \(\eta=0.01\). We trained three models with 70 epochs and compared their performance under \(\alpha=0.2\) and \(\alpha=0.9\) conditions. Under the \(\alpha=0.9\) condition, the classification accuracy and loss rate of each model over the training epochs are shown in Figures 5 and 6. Our method (FedDB) outperforms FedAvg and FedMe in terms of accuracy and also demonstrates better performance in terms of loss. Under the \(\alpha=0.2\) condition, the results are shown in Figures 7 and 8. From the trend curves in Figures 5 and 7, it can be seen that all models have reached a stable convergence state. Our method continues to outperform the other two in accuracy and has a lower loss rate. When the data distribution is particularly uneven, the advantages of DBSCAN become more evident. In contrast, the traditional K-means method, which fixes the number of clusters at the start, tends to include outliers in clusters. This limitation is especially pronounced when handling unevenly distributed data, such as outliers, non-spherical data, and the challenge of selecting the optimal number of clusters [27]. As shown in Tables 5 and 6 our method outperforms FedMe in terms of accuracy under these conditions, effectively addressing the limitations of K-means.