## 4 Proposed Framework
### EdgeGuard Framework
#### 4.1.5 Adaptive Aggregation and Global Model Update  
Another innovation is the adaptive aggregation function that weighs contributions from each edge device within the function of data quality and reliability of devices. Such a feature is extremely critical for ensuring that the federated learning process remains robust and effective in the eventuality of a possible problem that results from data quality and security threats. Let \(\{w_{1},w_{2},\ldots,w_{N}\}\) represent the gradient updates acquired from the blockchain layer. Finally, the central server takes the adaptive aggregation function \(f\) to obtain the new global gradient at the time step \(t+1\). Mathematically, we have the following:  
\[w_{t+1}=f(\{w_{i}^{t+1}\}_{i\in\mathcal{E}_{t}},\{q_{i}^{t}\}_{i\in\mathcal{E }_{t}},\{r_{i}^{t}\}_{i\in\mathcal{E}_{t}}) \tag{34}\]  
where \(\mathcal{E}_{t}\) is the set of participating devices in round \(t\), \(q_{i}^{t}\) is the quality score of device \(i\)'s data, and \(r_{i}^{t}\) is the reliability score of device \(i\). The adaptive aggregation function \(f\) is defined as follows:  
\[f(\{w_{i}\},\{q_{i}\},\{r_{i}\})=\frac{\sum_{i\in\mathcal{E}_{t}}\alpha_{i}w_{ i}}{\sum_{i\in\mathcal{E}_{t}}\alpha_{i}} \tag{35}\]  
where \(\alpha_{i}\) is the weight assigned to device \(i\)'s update and is calculated as follows:  
\[\alpha_{i}=q_{i}\cdot r_{i}\cdot\exp(-\beta\|w_{i}-\bar{w}\|^{2}) \tag{36}\]  
Here, \(\bar{w}\) is the average of all updates, and \(\beta\) is a hyperparameter controlling the influence of update similarity. This formulation ensures the following:  
1. Higher quality data (higher \(q_{i}\)) have more influence on the global model.
2. More reliable devices (higher \(r_{i}\)) contribute more significantly.
3. Updates that are closer to the average (potentially more trustworthy) are given higher weight.  
The quality score \(q_{i}\) is determined by the quality assessment module (QAM):  
\[q_{i}=Q(D_{i})=\frac{1}{1+\exp(-(\gamma_{1}C_{i}+\gamma_{2}V_{i}-\gamma_{3}O_{ i}))} \tag{37}\]  
where \(C_{i}\) denotes the completeness of the data, \(V_{i}\) denotes the validity, \(O_{i}\) denotes the outlier ratio, and \(\gamma_{1}\), \(\gamma_{2}\), \(\gamma_{3}\) denote learnable parameters. The reliability score \(r_{i}\) is calculated by the reliability evaluation function (REF), as follows:  
\[r_{i}=R(e_{i},t)=\delta r_{i,t-1}+(1-\delta)(\frac{1}{1+\exp(-(\lambda_{1}U_{i }+\lambda_{2}A_{i}-\lambda_{3}E_{i}))}) \tag{38}\]  
where \(r_{i,t-1}\) is the previous reliability score, \(U_{i}\) is the uptime ratio, \(A_{i}\) is the contribution accuracy, \(E_{i}\) is the error rate, \(\delta\) is a smoothing factor, and \(\lambda_{1}\), \(\lambda_{2}\), \(\lambda_{3}\) are learnable parameters. This adaptive aggregation mechanism allows EdgeGuard to conduct the following:  
1. Mitigate the impact of low-quality or malicious updates.
2. Adapt to changing device behaviors and data characteristics.
3. Improve the overall robustness and accuracy of the global model.
4. Provide an implicit defense against various attacks, including data poisoning and free-riding.  
The aggregated gradient \(w_{t+1}\) is then used to update the global model \(GM\). The \(GM\) has the same architecture as the local models. The update process is expressed in Equation (39):  
\[GM_{(t+1)}=GM_{(t)}+w_{t+1} \tag{39}\]