## 3 Framework Design and Deployment
### Proposed Framework
#### 3.4.3 Federated Averaging with XAI Integration  
The aggregation equation simplifies the federated averaging process for clarity, but it does not merely involve a raw summation of model parameters. Instead, it incorporates weighting factors based on hyperparameters such as the number of data samples on each participating device. Specifically, the weights assigned to each local model \(M_{i+1}^{k}\) are proportional to the size of the local dataset, ensuring that devices contributing more significant data influence the global model proportionally. The adopted aggregation equation can be expressed as:  
\[M_{i+1}=\sum_{k=1}^{N}\frac{n_{k}}{n}M_{i+1}^{k}, \tag{1}\]  
where \(n_{k}\) is the number of data samples on device \(k\), and \(n=\sum_{k=1}^{N}n_{k}\) represents the total number of samples across all devices. This weighted approach prevents devices with smaller datasets from disproportionately impacting the global model and enhances the robustness and generalizability of the aggregated model. The implementation also considers potential adjustments to the hyperparameters, such as learning rates or local training epochs, to fine-tune the contributions of each device further. A discussion of these nuances highlights the thoughtfulness of the aggregation strategy and addresses the concern raised about oversimplification. The weights \(\frac{n_{k}}{n}\) in Equation (1) are determined based on the number of data samples \(n_{k}\) on each device, where \(n=\sum_{k=1}^{N}n_{k}\). This ensures that devices with larger datasets have a proportionally greater influence on the global model, reflecting their statistical significance. Additional factors can influence the weights, such as data quality (e.g., reliability and completeness), model convergence (e.g., lower loss or higher accuracy), and device reliability (e.g., historical consistency). A generalized weighting function \(w_{k}\) can be formulated as:  
\[w_{k}=\alpha\cdot\frac{n_{k}}{n}+\beta\cdot q_{k}+\gamma\cdot r_{k}, \tag{2}\]  
where \(q_{k}\) represents data quality, \(r_{k}\) reflects reliability, and \(\alpha\), \(\beta\), \(\gamma\) are hyperparameters. This flexible approach allows the aggregation process to incorporate both the quantity and quality of contributions, ensuring fairness and robustness in the FL framework. To enhance this aggregation, the framework integrates XAI techniques post-aggregation, generating explanations (e.g., attention maps and gradients) to identify critical features and assess the importance of various data inputs. This insight-driven approach allows the system to refine model aggregation further and prioritize high-impact data as follows:  
* By incorporating XAI, the framework adjusts the FL process to optimize the impact of significant features. XAI methods identify feature importance and assist in prioritizing adjustments, particularly for sensor inputs prone to errors. This adjustment mechanism aims to ensure that the model performs robustly across a variety of operational conditions, increasing interpretability and reliability. * To reinforce the XAI-driven insights, each local model's contribution is weighted according to its identified importance. Let \(W_{i+1}^{k}\) represent the weight assigned to the model update from device \(k\) after update cycle \(i+1\). The revised aggregation process is represented as: \[M_{i+1}=\frac{\sum_{k=1}^{N}W_{i+1}^{k}M_{i+1}^{k}}{\sum_{k=1}^{N}W_{i+1}^{k}}\] (3) This approach improves the global model by emphasizing data sources that contribute to more accurate and resilient predictions, guided by XAI insights. * During local training on each edge device, XAI further customizes the training process by prioritizing data points associated with historical model errors.