# Fed-Hetero: A Self-Evaluating Federated Learning Framework for Data Heterogeneity
## 5 Experiment Setup
### Data heterogeneity Estimation
#### 5.4.1 Estimate Quantity Skew  
After a specified number of rounds \"nt\" based on the weight divergence factor, the server accepts the additional parameters such as \(P_{D_{m}}\), \(P_{D_{ml}}\) where l = 0, 1, \(\text{Dpm}^{(Sub)}\) along with the \(W_{(t+1)}^{m}\) where m= client 1 to client 4. The class distributions of client 1 to client 4 are given below:  
\[P_{D_{1}} =[p_{1}(0),p_{1}(1),\ldots,p_{1}(K-1)] \tag{11}\] \[P_{D_{2}} =[p_{2}(0),p_{2}(1),\ldots,p_{2}(K-1)]\] (12) \[P_{D_{3}} =[p_{3}(0),p_{3}(1),\ldots,p_{3}(K-1)]\] (13) \[P_{D_{4}} =[p_{4}(0),p_{4}(1),\ldots,p_{4}(K-1)] \tag{14}\]  
Here, \(p_{1}(c)\), \(p_{2}(c)\), \(p_{3}(c)\), \(p_{4}(c)\) is the probability of class \(c\) in dataset \(D_{1}\), \(D_{2}\), \(D_{3}\), \(D_{4}\). All clients calculate the probability distributions of the data they possess. Each client has an \(P_{D_{m}}\), which is then sent to the server. The server computes the \(JSD_{d}\) for the datasets from client 1 to client 4.  
The Jensen-Shannon Divergence (JSD) between the four class distributions \(P_{D_{1}}\), \(P_{D_{2}}\), \(P_{D_{3}}\)and \(P_{D_{4}}\) is defined as follows:  
\[M=\frac{1}{2}\Big{(}P_{D_{i}}+P_{D_{j}}\Big{)} \tag{15}\]  
where \(i\) and \(j\) can be any of the dataset pairs from \(D_{1}\), \(D_{2}\), \(D_{3}\), \(D_{4}\).  
\(JSD\) between each client pairs is calculated as shown in Equations (16)-(21).  
\[JSD(P_{D_{1}}\parallel P_{D_{2}}) =\frac{1}{2}\big{(}KL_{\text{D}}(P_{D_{1}}\parallel M)+KL_{\text {D}}(P_{D_{2}}\parallel M)\big{)} \tag{16}\] \[JSD(P_{D_{1}}\parallel P_{D_{3}}) =\frac{1}{2}\big{(}KL_{\text{D}}(P_{D_{1}}\parallel M)+KL_{\text {D}}(P_{D_{3}}\parallel M)\big{)}\] (17) \[JSD(P_{D_{1}}\parallel P_{D_{4}}) =\frac{1}{2}\big{(}KL_{\text{D}}(P_{D_{1}}\parallel M)+KL_{\text {D}}(P_{D_{4}}\parallel M)\big{)}\] (18) \[JSD(P_{D_{2}}\parallel P_{D_{3}}) =\frac{1}{2}\big{(}KL_{\text{D}}(P_{D_{2}}\parallel M)+KL_{\text {D}}(P_{D_{3}}\parallel M)\big{)}\] (19) \[JSD(P_{D_{2}}\parallel P_{D_{4}}) =\frac{1}{2}\big{(}KL_{\text{D}}(P_{D_{2}}\parallel M)+KL_{\text {D}}(P_{D_{4}}\parallel M)\big{)}\] (20) \[JSD(P_{D_{3}}\parallel P_{D_{4}}) =\frac{1}{2}\big{(}KL_{\text{D}}(P_{D_{3}}\parallel M)+KL_{\text {D}}(P_{D_{4}}\parallel M)\big{)} \tag{21}\]  
where \(KL_{\text{D}}\) is the Kullback-Leibler Divergence [38] as shown in Equations (22)-(25).  
\[KL_{\text{D}}(P_{D_{1}}\parallel M) =\sum_{i}P_{D_{1}}(i)\log\frac{P_{1}(i)}{M(i)}\] (22) \[KL_{\text{D}}(P_{D_{2}}\parallel M) =\sum_{i}P_{D_{2}}(i)\log\frac{P_{2}(i)}{M(i)}\] (23) \[KL_{\text{D}}(P_{D_{3}}\parallel M) =\sum_{i}P_{D_{3}}(i)\log\frac{P_{3}(i)}{M(i)}\] (24) \[KL_{\text{D}}(P_{D_{4}}\parallel M) =\sum_{i}P_{D_{4}}(i)\JSD is used to evaluate the differences in data distributions across multiple clients. A smaller \(JSD_{d}\) value indicates that the clients have similar distributions and larger value indicates greater dissimilarity. The reported upper-limit thresholds are specific to the dataset used in the study to identify clients with close similarity, with 0.4 determined as the upper limit for JSD and the lower limit 0. Based on the \(JSD_{d}\) value as shown in Equation (26), the server can notify the clients using \(R_{Q}\) about the type of heterogeneity associated in their data, prompting them to explore methods such as data augmentation [28] for improving the accuracy of their individual models.