## 4 Proposed Methods
### Heuristic 2: F1 Score  
The second and third heuristics utilize the models' performances to promote communication between clients with better-performing or dissimilar models. After each round, clients calculate their models' per-class f1-scores on a test set and share them with the network. Clients then select neighbors to communicate with based on the dissimilarity or similarity scores computed using these f1-scores. \[\text{neighbor dissimilarity score}=ndc=\sum_{\text{class i}}\left|F_{k}^{i}-F_{ c}^{i}\right| \tag{2}\]  
1. FedAVG (Algorithm 7)
```
1:forround \(\gets 1,2,3,\ldots\)do
2:for\(client\gets 1,2,3,\ldots\)do
3:\(w_{client}=\text{fit}(w_{client},data_{client},\text{epochs = $\$local\_epoch})\)
4:endfor
5:for\(client\gets 1,2,3,\ldots\) in parallel do
6: neighbors = GetNeighbors(\(c\), without = client.last, metric = ndc)
7:\(w_{client}+=Mean(neighbors.weight)\)
8:endfor
9:endfor
```
**Algorithm 7** FedAVG Heuristic 2: F1 score
```
1:forround \(\gets 1,2,3,\ldots\)do
2:for\(local\_epoch\gets 1,2,3,\ldots\)do
3:for\(step\gets 1,2,3,\ldots\)do
4:for\(client\gets 1,2,3,\ldots\) in parallel do
5:\(grad_{client}=Gradient(w_{client},data_{client})\)
6: neighbors = GetNeighbors(\(c\), without = client.last, metric = ndc)
7:\(w_{client}+=Mean(neighbors.grad)\)
8:endfor
9:endfor
10:endfor
11:endfor
```
**Algorithm 8** FedSGD Heuristic 2: F1 score. \(c\) is the fraction of clients that perform a computation on each round  
### Heuristic 2: F1 Score  
The second and third heuristics utilize the models' performances to promote communication between clients with better-performing or dissimilar models. After each round, clients calculate their models' per-class f1-scores on a test set and share them with the network. Clients then select neighbors to communicate with based on the dissimilarity or similarity scores computed using these f1-scores. \[\text{neighbor dissimilarity score}=ndc=\sum_{\text{class i}}\left|F_{k}^{i}-F_{ c}^{i}\right| \tag{3}\]  
1. FedAVG (Algorithm 7)
```
1:forround \(\gets 1,2,3,\ldots\)do
2:for\(client\gets 1,2,3,\ldots\)do
3:\(w_{client}=\text{fit}(w_{client},data_{client},\text{epochs = $\$local\_epoch})\)
4:endfor
5:for\(client\gets 1,2,3,\ldots\) in parallel do
6: neighbors = GetNeighbors(\(c\), without = client.last, metric = ndc)
7:\(w_{client}\leftarrow\text{Mean(neighbors.weight)}\)
8:endfor
9:endfor
```
**Algorithm 9** FedSGD Heuristic 2: F1 score. \(c\) is the fraction of clients that perform a computation on each round
```
1:forround \(\gets 1,2,3,\ldots\)do
2:for\(local\_epoch\gets 1,2,3,\ldots\)do
3:for\(step\gets 1,2,3,\ldots\) in parallel do
4:for\(client\gets 1,2,3,\ldots\) in parallel do
5:\(grad_{client}=Gradient(w_{client},data_{client})\)
6: neighbors = GetNeighbors(\(c\), without = client.last, metric = ndc)
7:\(w_{client}+=Mean(neighbors.grad)\)
8:endfor
9:endfor
10:endfor
11:endfor
```
**Algorithm 10** FedSGD Heuristic 2: F1 score. \(c\) is the fraction of clients that perform a computation on each round
```
1:forround \(\gets 1,2,3,\ldots\)do
2:for\(local\_epoch\gets 1,2,3,\ldots\)do
3:for\(step\gets 1,2,3,\ldots\) in parallel do
5:\(grad_{client}=Gradient(w_{client},data_{client})\)
6: neighbors = GetNeighbors(\(c\), without = client.last, metric = ndc)
7:\(w_{client}+=Mean(neighbors.grad)\)
8:endfor
9:endfor
10:endfor
11:endfor
```
**Algorithm 11** FedSGD Heuristic 2: F1 score. \(c\) is the fraction of clients that perform a computation on each round
```
1:for\(local\_epoch\gets 1,2,3,\ldots\)do
2:for\(local\_epoch\gets 1,2,3,\ldots\)do
3:for\(step\gets 1,2,3,\ldots\) in parallel do
4:\(grad_{client}=Gradient(w_{client},data_{client})\)
5: neighbors = GetNeighbors(\(c\), without = client.last, metric = ndc)
7:\(w_{client}+=Mean(neighbors.grad)\)
8:endfor
9:endfor
10:endfor
11:endfor
```
**Algorithm 12** FedSGD Heuristic 2: F1 score.