# Federated Learning for Clients' Data Privacy Assurance in Food Service Industry
## 5 Results and Discussion  
### Federated Learning Classification Model Performance  
Performance testing of classification between the clean and contamination frames using FL was carried out on data from ten clients (facilities), including 44,185 _clean_ frames and 46,882 _contamination_ frames. The dataset description is shown in Table 1. As can be seen in Table 1, the establishments range from small restaurants to institutional kitchens. They also vary in the types of surfaces to be scanned and the relative cleanliness, as well as measurement issues discussed above. That is why the number of frames selected for model development varies between clients. We used data from eight initial clients (35,858 _clean_ frames and 36,523 _contamination_ frames) for training and validation of the model and data from two new clients (8327 _clean_ frames and 10,359 _contamination_ frames) for final testing. Data from the eight clients were randomly assigned to training (70%) and validation (30%) sets. The FedAvg algorithm requires that in each round, a subset of clients be selected for training the model and then evaluated on all clients before starting the next round. In this study, for each round of communication, four out of eight clients were randomly chosen for the training subset for each of the 150 rounds. We then validated the updated model on the validation data sets of eight clients. For each client, the training data and validation data were separate, so we could see how well the new model was generalized. In each round, clients download the global model and train it on their local dataset over 100 epochs, with a local batch size of 32, using binary cross-entropy as the model loss function. We used [PERSON] as the model optimizer with a learning rate of \(1\times 10^{-5}\) and weight decay of \(1\times 10^{-6}\). Each client then returns the locally trained model to the server and the local models are aggregated using the FedAvg algorithm, and an updated global model is sent back to all clients. The updated global model is validated using each client's validation dataset before starting the next training round. The FL classification model was evaluated using the six metrics of accuracy, precision, recall, specificity, F-score, and area under the curve (AUC). The first five metrics are defined as follows:  
\[\text{Accuracy}=\frac{\text{(TP+TN)}}{\text{(TP+TN+FP+FN)}},\text{Precision}= \frac{\text{TP}}{\text{TP+FP}}, \tag{11}\]  
\[\text{Specificity}=\frac{\text{TN}}{\text{TN}+\text{FP}},\text{ }\text{F}_{\text{score}}=2\times\frac{\text{Precision}\times\text{ Recall}}{\text{Precision}+\text{Recall}} \tag{12}\]  
where TP, TN, FP, and FN show true positive, true negative, false positive, and false negative, respectively. In our case, TP shows correctly identified _contamination_ frames, and TN shows _clean_ frames. FP denotes the _clean_ frame wrongly classified as _contamination_, and FN shows the _contamination_ frame misclassified as _clean_. \begin{table}
\begin{tabular}{c c c c c} \hline \hline  & **No. of** & **No. of** & **No. of** & **Total No. ** \\  & **Clients** & **“Clean” Frames** & **“Clean” Frames** & **“Clean” Frames** & **“Clean” Frames** \\ \hline  & 1 & 708 & 3242 & 3950 \\  & 2 & 1585 & 7207 & 8792 \\  & 3 & 2740 & 1815 & 4555 \\ Training/ & 4 & 3893 & 2574 & 6467 \\ Validation & 5 & 2679 & 2320 & 4999 \\  & 6 & 11,897 & 8629 & 20,526 \\  & 7 & 11 We trained and validated the FL classification model over 150 rounds, and the updated global model was validated using the clients' validation dataset. Figure 4 shows the model accuracy and loss for each round of communication. The accuracy and loss of each round are the average accuracies and average losses of all eight clients. After the model was trained and validated over 150 rounds, we tested it on two new clients.