# Federated Learning for Cybersecurity: A Privacy-Preserving Approach
## 4 Experimental Setup and Evaluation
### Evaluation Metrics  
The evaluation of the proposed privacy-preserving FL framework was performed using a set of standard cybersecurity and machine learning metrics. These metrics were selected to comprehensively assess model performance, communication efficiency, and privacy preservation across distributed nodes in a simulated IoT environment. These metrics were chosen not only for their prevalence in intrusion detection tasks, but also for their ability to reflect trade-offs in federated settings, where privacy constraints, data heterogeneity, and communication costs directly affect model performance. Metrics such as privacy loss and communication overhead reduction are particularly relevant in FL architectures, where optimization of local training and secure aggregation must not compromise detection quality. To ensure a rigorous evaluation of the proposed FL framework, we adopted a stratified five-fold cross-validation scheme for each dataset, thereby maintaining consistency in the distribution of classes across the splits. The dataset was randomly shuffled and partitioned into five equally sized subsets. During each iteration, four folds were used for training and one for testing. This approach reduces variance and provides a more reliable estimate of model generalization, particularly for imbalanced intrusion detection datasets [1]. Additionally, for specific experimental scenarios, such as ablation studies and adversarial robustness evaluation, we implemented an 80/20 training/testing split using fixed random seeds to ensure reproducibility. All preprocessing steps (e.g., feature scaling, encoding and label remapping) were performed solely on the training data and were then applied to the test set to prevent information leakage. This procedure aligns with the best practices for validating machine learning models for cybersecurity applications [2]. The following metrics were utilized:  
* Accuracy (ACC): This metric measures the overall correctness of the model by calculating the proportion of correctly predicted instances (both benign and malicious) out of the total number of samples. It is defined as \[Accuracy=\frac{TP+TN}{TP+TN+FP+FN}\] (1) This standard metric is widely used to evaluate FL-based intrusion detection systems because it reflects the model's overall reliability across benign and malicious classifications. In federated environments, where data heterogeneity and imbalance are common, accuracy is an essential initial indicator of general model performance across distributed nodes [1,13]. * Precision (PRE): Precision refers to the proportion of correctly predicted positive instances out of all instances predicted as positive. It indicates how many of the alerts generated by the system are actually true threats: \[Precision=\frac{TP}{TP+FP}\] (2)Precision is particularly relevant in intrusion detection scenarios where the cost of false alarms (FP) is high, such as alert fatigue or unnecessary blocking of benign traffic. In federated models where client-specific data biases may occur, high precision ensures that identified threats are indeed valid, thus optimizing response actions and reducing noise in decentralized alert systems [2; 39]. * Recall (REC): This represents the proportion of actual positives that were correctly identified. \[Recall=\frac{TP}{TP+FN}\] (3)  
Recall directly impacts the model's ability to detect real threats, especially critical in high-risk infrastructures such as healthcare or industrial IoT. In these domains, missing a true intrusion (FN) could lead to data breaches or service disruption. Therefore, recall remains a core metric in evaluating FL-based IDS models under adversarial conditions [1; 40]. * F1 score: This is the harmonic mean of precision and recall, balancing both metrics. \[F1-Score=2\ \times\ \frac{Precision\ \times\ Recall}{Precision+Recall}\] (4)  
The F1 score combines the strengths of both precision and recall, offering a more balanced evaluation in cases of uneven class distributions.