FedPACPersonalization<T>

Models & Types · AiDotNet.FederatedLearning.Personalization

Implements FedPAC (Personalization via Aggregation and Calibration) with prototype alignment.

Inheritance: FederatedLearningComponentBase<T> → FedPACPersonalization<T>

For Beginners

FedPAC personalizes in two steps. First, it calibrates the aggregation itself — instead of averaging all clients equally, each client aggregates only from “similar” clients (measured by prototype similarity). Second, it aligns class prototypes (average feature vectors per class) across clients so that the shared feature space has consistent semantics. This is especially effective when clients have different class distributions (label skew).

How It Works

Algorithm:

Reference: FedPAC: Personalization via Aggregation and Calibration (2024).

Constructors

Constructor Summary
FedPACPersonalization(double similarityThreshold, double calibrationWeight) Creates a new FedPAC personalization strategy.

Properties

Property Summary
double CalibrationWeight { get; } Gets the calibration loss weight.
double SimilarityThreshold { get; } Gets the similarity threshold for client inclusion.

Methods

Method Summary
Dictionary<int, T[]> ComputeClassPrototypes(T[][] features, int[] labels) Computes class prototypes from a client’s local data: p_c = mean(features where label = c).
Dictionary<int, T[]> ComputeGlobalPrototypes(Dictionary<int, Dictionary<int, T[]>> clientPrototypes, Dictionary<int, Dictionary<int, int>> clientSampleCounts) Computes global prototypes by averaging client prototypes per class (weighted by sample count).
Dictionary<int, double> ComputePersonalizedWeights(int targetClientId) Computes personalized aggregation weights based on prototype similarity.
double ComputeCalibrationLoss(Dictionary<int, T[]> localPrototypes, Dictionary<int, T[]> globalPrototypes) Computes the calibration loss that aligns local features to global prototypes.
void RegisterPrototypes(int clientId, Dictionary<int, T[]> prototypes) Registers class prototypes for a client.