# Federated Learning: A Comparative Study of Defenses Against Poisoning Attacks
## 5 Defense Methods
### KPCA + K-Means  
Kernel Principal Component Analysis (KPCA) is a robust extension of PCA, which is widely used in machine learning and statistics [7]. Similar to PCA, KPCA excels in reducing the dimensionality of high-dimensional data, with the goal of retaining important information while minimizing loss. What sets KPCA apart is its ability to handle non-linear relationships within the data by using a kernel function. This enhanced capability makes KPCA particularly effective at capturing complex patterns that may be missed by linear methods.  
The key improvement of KPCA over PCA is its ability to reduce the dimension of data nonlinearly, as demonstrated in Figure 2[6,7,16]. The linear green lines (on the right side) represent the linear reduction of data, where only a straight line is traced. In contrast, the curved green lines (on the left side) demonstrate the non-linear reduction achieved by KPCA, allowing for a more flexible representation of the underlying data. This figure emphasizes KPCA's capability to capture intricate patterns and relationships that may be overlooked by traditional linear methods like PCA.  
The algorithm for the federated learning system using KPCA + K-means as the aggregation model works as follows (Algorithm 2):  
```
Input: numberOfAgents, T (number of iterations) Output: globalWeights // Step 1: Initialization and Configuration  Initialize agents with indices [1, 2,..., numberOfAgents]  Initialize globalWeights  Set t = 0 // Step 2: Main Training Loop whilet < Tdo // Step 2: Calculate probabilities for agent selection  probabilities = CalculateSelectionProbabilities(agents) // Step 2: Start parallel training and wait for completion  selectedAgents = SelectAgents(probabilities)  updates = ParallelTraining(selectedAgents) // Step 2: Data Collection and Preprocessing  updateMatrix = CollectUpdates(updates) // Step 2: Kernel Transformation with KPCA  kernelTransformedData = KPCA\({}_{\_}\)Transform(updateMatrix) // Step 2: Kernel-Based Cluster Analysis using K-Means  clusters = KMeansClustering(kernelTransformedData) // Step 2: Cluster Selection and Weighted Aggregation  selectedClusters = IdentifyDistinctiveClusters(clusters)  aggregatedKernelUpdates = WeightedAggregate(selectedClusters, clusterSizes) // Step 2: Inverse Kernel Transformation  globalUpdate = KPCA\({}_{\_}\)InverseTransform(aggregatedKernelUpdates) // Step 3: Evaluation and Updating  globalWeights = UpdateGlobalWeights(globalWeights, globalUpdate)  EvaluateModel(globalWeights)
```  
**Algorithm 2**Identifying malicious model updates using KPCA + K-means  
Figure 2: Demonstration of the benefit of non-linear dimensional reduction.  
```
Input: numberOfAgents, T (number of iterations) Output: globalWeights // Step 1: Initialization and Configuration  Initialize agents with indices [1, 2,..., numberOfAgents]  Initialize globalWeights  Set t = 0 // Step 2: Main Training Loop whilet < T do // Step 2: Calculate probabilities for agent selection probabilities = CalculateSelectionProbabilities(agents) // Step 2b: Start parallel training and wait for completion  selectedAgents = SelectAgents(probabilities)  updates = ParallelTraining(selectedAgents) // Step 2c: Calculate Offsets  for each agent in selectedAgents do  offset[agent] = CalculateOffset(agent.update, referenceUpdate) end for // Step 2d: Similarity Measurement for each agent in selectedAgents do  similarityScore[agent] = MeasureSimilarity(offset[agent], referenceUpdate) endfor // Step 2e: Weighted Aggregation  globalUpdate = 0  totalWeight = 0 for each agent in selectedAgents do if similarityScore[agent] is High then  weight = AssignHigherWeight(similarityScore[agent])  globalUpdate = weight * agent.update  totalWeight += weight  endif  globalUpdate = globalUpdate/totalWeight // Step 3: Evaluation and Updating  globalWeights = UpdateGlobalWeights(globalWeights, globalUpdate)  EvaluateModel(globalWeights)
```  
**Algorithm 2**_Cont._