Provably fair particle swarm optimization for federated learning coalition selection
Project description
FairSwarm
Provably fair particle swarm optimization for federated learning coalition selection
Overview
FairSwarm is a novel particle swarm optimization algorithm designed for fair client selection in federated learning. It provides provable guarantees on both convergence and demographic fairness.
Key Innovation
FairSwarm introduces a fairness-aware velocity update that steers optimization toward demographically balanced coalitions:
v = ω·v + c₁·r₁·(pBest - x) + c₂·r₂·(gBest - x) + c₃·∇_fair
^^^^^^^^
Novel fairness gradient
Theoretical Guarantees
| Theorem | Guarantee |
|---|---|
| Theorem 1 | Convergence to stationary point with probability 1 |
| Theorem 2 | ε-fairness: DemDiv(S*) ≤ ε with high probability |
| Theorem 3 | (1-1/e-η) approximation for submodular objectives |
| Theorem 4 | Privacy-fairness tradeoff lower bound |
Data Access and Compliance
This library contains no patient data. Examples and tests use only
synthetic data generated by create_synthetic_clients().
Experiments on restricted clinical datasets (MIMIC-III, eICU-CRD) require that you independently obtain credentialed access:
- Complete CITI "Data or Specimens Only Research" training.
- Sign the PhysioNet Data Use Agreement at https://physionet.org/about/database/.
- Download MIMIC-III / eICU under your own credentials.
- Place derived cohort files outside the repository tree, or in a
path covered by
.gitignore(data/processed/,data/raw/). - Set the
MIMIC_DATA_PATH(orEICU_DATA_PATH) environment variable to point the experiment scripts at your local data.
Do NOT commit, redistribute, or share patient-level data in any form. You are solely responsible for compliance with the PhysioNet DUA, HIPAA, and your institution's IRB requirements.
The full threat model — what the server sees, what is out of scope (malicious servers, sybil clients, model inversion, side-channel attacks), and how the package's privacy claims align with HIPAA Safe Harbor / GDPR / PhysioNet DUA / All of Us terms — is in THREAT_MODEL.md.
Installation
pip install fairswarm
For development:
pip install fairswarm[dev]
Quick Start
from fairswarm import FairSwarm, FairSwarmConfig, Client
from fairswarm.demographics import DemographicDistribution, CensusTarget
import numpy as np
# Create clients (hospitals) with demographic information
clients = [
Client(
id=f"hospital_{i}",
demographics=np.random.dirichlet([2, 2, 2, 2]),
dataset_size=1000 + i * 100,
)
for i in range(20)
]
# Configure the optimizer
config = FairSwarmConfig(
swarm_size=30,
max_iterations=100,
coalition_size=10,
fairness_weight=0.3, # λ in fitness function
seed=42,
)
# Create target demographics (e.g., US Census 2020)
target = DemographicDistribution.from_dict({
"white": 0.576,
"black": 0.124,
"hispanic": 0.187,
"asian": 0.061,
"other": 0.052,
})
# Run optimization
optimizer = FairSwarm(
clients=clients,
coalition_size=10,
target_demographics=target,
config=config,
)
# Use built-in demographic fitness (or supply your own callable)
from fairswarm.fitness import DemographicFitness
fitness_fn = DemographicFitness(target=target)
result = optimizer.optimize(fitness_fn)
# Check results
print(f"Selected coalition: {result.coalition}")
print(f"Fitness: {result.fitness:.4f}")
print(f"ε-fair: {result.is_epsilon_fair(0.05)}")
Documentation
Full API documentation is available in the source code docstrings. For the formal algorithm specification, theoretical proofs, and experimental methodology, please refer to:
T. Norwood, D. Das, P. Chatterjee, E. Bentley, and U. Ghosh, "FairSwarm: Trustworthy Coalition Selection for Fair and Secure Federated Intelligence," IEEE Trans. Consum. Electron., 2026. note : Submitted
Citation
If you use this library or its results, please cite the article (preferred — the one that carries the formal theorems) and, if relevant, the specific software release.
@article{norwood2026fairswarm,
title = {FairSwarm: Trustworthy Coalition Selection for Fair
and Secure Federated Intelligence},
author = {Norwood, Tenicka and Das, D. and Chatterjee, P. and
Bentley, E. and Ghosh, U.},
journal = {IEEE Transactions on Consumer Electronics},
year = {2026},
note = {Submitted}
}
CITATION.cff backs GitHub's "Cite this repository" button and points
at the same record.
License
This project is licensed under the PolyForm Noncommercial License 1.0.0. You are free to use, modify, and distribute it for any noncommercial purpose, including academic research, education, and personal projects.
Commercial licensing is available. For commercial use inquiries, please contact Tenicka Norwood.
See LICENSE for full terms.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fairswarm-0.5.0.tar.gz.
File metadata
- Download URL: fairswarm-0.5.0.tar.gz
- Upload date:
- Size: 240.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a5f45a1783099647fc67b1ff649e5474e15d0aef40107b6315b0bba89898728f
|
|
| MD5 |
8f4a4d7e2eacfb5806ff15a508bf4401
|
|
| BLAKE2b-256 |
a6bdbeb4516021d69904cff88204902d192595587feeb8b8548d34e954a40ed0
|
File details
Details for the file fairswarm-0.5.0-py3-none-any.whl.
File metadata
- Download URL: fairswarm-0.5.0-py3-none-any.whl
- Upload date:
- Size: 166.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2c491170b0e801448bff8eef609723880da96ffe87f5938bccf27e09634e6c89
|
|
| MD5 |
3426d7d39a3c576e091276a3f9183687
|
|
| BLAKE2b-256 |
70eec8834ac5ff94ceb7ab059a532cd9c0fe95391eeaf0b61010632b2b323620
|