# Fed-Hetero: A Self-Evaluating Federated Learning Framework for Data Heterogeneity
## 4 System Architecture
### Fed-Hetero Algorithm  
This section presents a comprehensive overview of the modules in Fed-Hetero. The process begins with Algorithm 2, which serves as the foundational step for the self evaluating framework. Algorithm 2 is composed of several sub-modules designed to handle specific tasks. The sub-modules functionalities are specified in Algorithms 3-6. Algorithm 3 identifies the weight divergence between the clients, followed by Algorithm 4 for estimat  
Figure 1: System architecture for Fed-Hetero recommendation system for clients. ing quantity skew, Algorithm 5 for computing label distribution skew, and Algorithm 6 for identifying image skew. These algorithms estimate the type of heterogeneity associated with data in the clients and recommend strategies to mitigate it. ```
1:Input:
2:Number of clients \(m\), number of global rounds \(t\), local epochs \(E\), learning rate \(\eta\), initial global model \(\mathbf{w}_{0}\), predefined number of rounds \(nt\)
3:Output:
4:Recommended strategies for: quantity skew \(R_{Q}\), label skew \(R_{l}\) and image skew \(R_{i}\)
5:Initialize: Set global model \(\mathbf{w}=\mathbf{w}_{0}\)
6:for each round \(t1=1\) to \(t\)do
7: Server sends global model \(\mathbf{w}\) to all clients
8:for each client \(k\in\{1,\ldots,m\}\)in paralleldo
9: Initialize local model \(\mathbf{w}_{k}=\mathbf{w}\)
10: Train \(\mathbf{w}_{k}\) on client \(k\)'s local data for \(E\) epochs using learning rate \(\eta\)
11: Client sends updated model \(\mathbf{w}_{k}\) to server
12:endfor
13: Server aggregates client models to update global model: \[\mathbf{w}\leftarrow\frac{1}{K}\sum_{k=1}^{K}\mathbf{w}_{k}\]
14:if\(t1==nt\)then
15: Server invokes the function Weight_Divergence(\(W_{\texttt{clients}}\))
16:if\(weight\_divergence\_found==TRUE\)then
17: Server requests PDm, PDm0, PDm1 from all the clients. 18: Server invokes JSD_Data(PDm) to compute the JSD between clients. 19: Receive the variables for data distributions and store it in \(JSD_{d}\) list. 20:endif
21:for each \(L\) in \(JSD_{d}\)do
22:if\(L>\) Threshold then
23: Send \(R_{Q}\) to the corresponding clients and recommend data augmentation [28]. 24:endif
25:endfor
26: Server invokes JSD_10(PDm0, PDm1) to compute the JSD between classes in clients. 27: Receive the dictionary CJSD and iterate the dictionary to check if it exceeds the threshold value. 28:for (key, \(D_{l}S,x\)) IN in the CJSD do
29:if\(D_{l}S,x>\) Threshold then
30: Send \(R_{l_{l}}\) or \(R_{l_{1}}\) to the corresponding clients and recommend data augmentation [28]. 31:endif
32:endfor
33: Server requests for \(\text{Dpm}^{(Sub)}\) from Clients
34: Server invokes SSIM(\(\text{Dpm}^{(Sub)}\)) to compute SSIM between subset of samples in the clients. 35: Receive the SSIM values store it in \(SSIM_{l}\)_images_
36:for (key, SSIM) IN in the \(SSIM_{l}\)_images_ do
37:if\(SSIM<\) Threshold then
38: Send \(R_{i}\) to the corresponding clients and recommend clustering for the clients with similar distributions [29]. 39:endif
40:endfor
41:endif
42:endfor
```
1:Initialize an empty list divergences
2:Initialize a boolean flag weight_divergence_found \(\leftarrow\) false
3:for each client \(i\) in \(W_{\text{clients}}\)do
4:\(W_{i}(t+1)\gets W_{\text{clients}}[i](t+1)\)
5: Compute \(WD_{i}=\left\lVert W_{i}(t+1)-W_{\text{global}}(t+1)\right\rVert_{2}\)
6: Append the computed divergence \(WD_{i}\) to divergences
7:endfor
8: Set a threshold value \(\theta\) (a predefined constant or dynamic threshold)
9: Initialize an empty list clients_above_threshold
10:for each divergence \(D_{i}\) in divergences do
11:if\(D_{i}>\theta\)then
12: Set weight_divergence_found \(\leftarrow\) true
13: Append \(D_{i}\) to clients_above_threshold
14:endif
15:endfor
16: Return weight_divergence_found which indicates if any divergence exceeded the threshold. ```
**Algorithm 3**Weight_Divergence(\(W_{\text{clients}}\))
```
1:Input: Distributions \(D_{1},D_{2},\ldots,D_{m}\) indicates datasets associated with the clients.