# Lightweight Anomaly Detection in Digit Recognition Using Federated Learning
## 7 Experimental Results and Analysis
### Evaluating the Dual-Phase Early Stopping Mechanism  
To validate the advantages of the proposed dual-phase early stopping strategy, we conducted an additional experiment on PC that compared our strategy with the standard early stopping method using fixed patience values. This supplementary analysis demonstrates how the dual-phase approach effectively balances training efficiency and model performance.  
For this analysis, we selected Model 4 with a batch size of 50 as a representative example. The standard early stopping was implemented using TensorFlow's callback, with a consistent _min delta_ of 0.0005 and varying patience values (3, 10, 15, and 20). In contrast, our dual-phase strategy combines two patience levels: 3 for the initial phase and 20 once an acceptable loss threshold is reached. Figure 5 illustrates the training loss curves for both standard early stopping and the proposed dual-phase approach.  
Figure 4: Sorted anomaly detection rate for each letter in EMNIST dataset for autoencoder Model 1 [196, 16, 196].  
Figure 5a-d illustrate the training loss behavior using the standard strategy with increasing patience. As expected, higher patience values (e.g., 15 and 20) allow longer training and convergence, resulting in a stable loss plateau. Lower patience values (3 and 10) often terminate training prematurely, before the model escapes a local minimum, resulting in suboptimal final loss values.  
While higher patience enables better convergence, it also prolongs training with diminishing returns in terms of loss improvement. On the other hand, smaller patience values reduce training time but risk early stopping before meaningful convergence. The dual-phase approach offers a compromise between these extremes. As shown in Figure 5e, it allows sufficient exploration early in training, followed by faster termination once the model reaches an acceptable performance threshold.  
Table 4 summarizes the number of epochs and corresponding F1 scores across all the settings. The results indicate that extended training does not significantly improve F1 score and may even slightly degrade performance. In edge scenarios with limited power and time, the dual-phase strategy provides an efficient and effective trade-off between training cost and model quality.  
\begin{table}
\begin{tabular}{c c c c c} \hline \hline \multirow{2}{*}{**Strategy**} & \multirow{2}{*}{**Epochs**} & \multicolumn{2}{c}{**Anomaly Detection Rate (\%)**} & \multirow{2}{*}{**F1 Score**} \\ \cline{3-3} \cline{5-5}  & & **MNIST** & & **EMNIST** \\ \hline Standard (patience = 3) & 6 & 6.25 & 47.00 & 0.6134 \\ Standard (patience = 10) & 19 & 6.45 & 48.05 & 0.6220 \\ Standard (patience = 15) & 221 & 19.25 & 91.30 & 0.8673 \\ Standard (patience = 20) & 263 & 21.45 & 91.75 & 0.8607 \\ Dual-phase (3/20) & 124 & 12.55 & 86.80 & 0.8708 \\ \hline \hline \end{tabular}
\end{table}
Table 4: Comparison of early stopping strategies on anomaly detection performance.  
Figure 5: Training loss curves for Model 4 using different early stopping strategies: (**a**) standard early stopping with patience 3, (**b**) patience 10, (**c**) patience 15, (**d**) patience 20, and (**e**) proposed dual-phase early stopping with patience 3 for first phase and 20 for second phase.