# Lightweight Anomaly Detection in Digit Recognition Using Federated Learning
## 7 Experimental Results and Analysis
### Federated Learning Scenario 2: IID--Partitioned Dataset
#### 7.5.2 Robustness to Anomalous Training Data  
To assess the robustness of the FL framework when exposed to anomalous training data, we conducted experiments where certain devices were trained entirely on corrupted versions of the dataset. Specifically, we focused on the _fog_ corruption type from MNIST-C as prior experiments showed it produces the highest anomaly rates due to its substantial visual deviation from MNIST digits and the AE's difficulty in accurate reconstruction. For this experiment, we again used Model 3 with the same architecture consisting of layers [196, 64, 196], with all the same training configuration parameters. In the following experiments, 1 to 5 out of 10 devices were trained on fog-corrupted digits, while the remaining devices used clean MNIST data. To monitor the behavior of the model, we focused on digit 9 as a representative case since it was consistently assigned to the corrupted training set in all configurations. The device configurations were as follows:  
* Configuration 1: devices 0-8 trained on clean MNIST; device 9 trained on fog. * Configuration 2: devices 0-7 on MNIST; devices 8-9 on fog. * Configuration 3: devices 0-6 on MNIST; devices 7-9 on fog. * Configuration 4: devices 0-5 on MNIST; devices 6-9 on fog. * Configuration 5: devices 0-4 on MNIST; devices 5-9 on fog. In each configuration, the local models underwent a round of training followed by federated aggregation. To better understand model behavior, we introduce an additional F1 score metric based on the fog dataset rather than EMNIST. This F1 score is designed to optimize false positives on MNIST and false negatives on fog. This allows us to evaluate how devices trained on fog datasets influence AD performance, considering both EMNIST and the fog variant. For simplicity, F1 scores based on EMNIST and fog are referred to as F1-EMNIST and F1-fog, respectively. Figure 8 shows six charts presenting F1-EMNIST and F1-fog scores for the mentioned configurations. The charts (a-e) illustrate F1 score trends as the number of devices trained on fog increases. These charts track performance on device 9, which is assigned to fog training in all configurations. For example, Figure 8 corresponds to Config. 1, (b) to Config. 2, and so forth. Figure 8,f both represent Config. 5 but differ in the digit used for training: (e) trains on digit 9 (fog corrupted), while (f) trains on digit 0 (clean MNIST), demonstrating how corrupted devices impact those trained on clean data. As expected, after each local training phase, models trained on fog begin to slowly lose their ability to recognize anomalies since fog images are treated as \"normal\" during training. However, after federated aggregation, the global model rapidly recovers its anomaly detection capability, illustrating the strength of collaborative learning. In subfigures (a-e), the F1-EMNIST score remains relatively stable, while F1-fog scores show greater variability. In Figure 8, the initial F1-fog score after the first training round (**Training 0**) is very low due to the fog training set, as expected. However, following federated aggregation, the global model improves substantially, rendering the impact of the fog-trained device negligible. Subsequent training rounds show a slight decline in F1-fog scores as the model attempts to better fit the fog data on the corrupted device,but aggregation consistently restores performance. This pattern indicates that a single corrupted device does not significantly degrade overall system performance. As the number of fog-trained devices increases, a stronger bias towards fog data emerges, noticeable starting with three fog devices. Larger fluctuations appear between local training and federated rounds since the model more easily adapts to the fog dataset. However, the aggregated models (**Federated _i_**) generally maintain good anomaly detection performance.