Skip to main content

MEDfl: A Collaborative Framework for Federated Learning in Medicine

Python Versions License: GPL v3 Build Status Contributors PyPI version Downloads


📚 Table of Contents

  1. Introduction
  2. Key Features
  3. Installation
  4. Modes of Operation
  5. Quick Start
  6. Documentation
  7. Contributing
  8. Acknowledgment
  9. Authors

1. Introduction

MEDfl is an open-source Federated Learning (FL) framework designed for both simulation and real-world distributed trainingin the medical and healthcare domains. It integrates Differential Privacy (DP), Transfer Learning (TL), and secure communication to enable privacy-preserving model training across multiple institutions—particularly suited for medical and clinical data.


2. Key Features

  • 🧩 Two Operation Modes

    • Simulation Mode: Run FL experiments locally for testing and benchmarking.
    • Real-World Mode: Connect remote clients for production-grade FL.
  • 🔒 Differential Privacy (Opacus Integration)
    Ensures client updates are mathematically protected against data leakage.

  • 🧠 Transfer Learning Integration
    Improve convergence and accuracy in small or heterogeneous datasets.

  • ⚙️ Modular Design
    Plug-and-play components for models, optimizers, datasets, and aggregation strategies.


3. Installation

pip install medfl

✅ Requires Python 3.9+.

If you prefer the development version:

git clone https://github.com/MEDomics-UdeS/MEDfl.git
cd MEDfl
pip install -e .

4. Modes of Operation

Mode Description Typical Use Case
Simulation FL Runs all clients locally in a controlled environment. Benchmarking, debugging, or prototyping.
Real-World FL Connects distributed client machines. Multi-institution collaboration, production deployments.

5. Quick Start

🌍 Real-World Federated Learning Example

Server Setup

from MEDfl.rw.server import FederatedServer, Strategy

custom_strategy = Strategy(
    name="FedAvg",
    fraction_fit=1,
    min_fit_clients=1,
    min_evaluate_clients=1,
    min_available_clients=1,
    local_epochs=1,
    threshold=0.5,
    learning_rate=0.01,
    optimizer_name="SGD",
    saveOnRounds=3,
    savingPath="./",
    total_rounds=10,
    datasetConfig={"isGlobal": True, "globalConfig": {"target": "label", "testFrac": 0.2}},
)

server = FederatedServer(
    host="0.0.0.0",
    port=8080,
    num_rounds=10,
    strategy=custom_strategy,
)
server.start()

Client Setup

from MEDfl.rw.client import FlowerClient, DPConfig

# Example: XGBoost client
xgb_params = {
    "objective": "binary:logistic",
    "eval_metric": "logloss",
    "eta": 0.1,
    "max_depth": 6,
    "subsample": 0.8,
    "colsample_bytree": 0.8,
    "tree_method": "hist",  # GPU: "gpu_hist"
}

client = FlowerClient(
    server_address="100.65.215.27:8080",
    data_path="../data/client1.csv",
    dp_config=None,            # DP only applies to neural networks
    model_type="xgb",
    xgb_params=xgb_params,
    xgb_rounds=10,
)
client.start()

💡 Tip:
Use Tailscale to connect clients and server under the same secure VPN for real-world deployments.


6. Documentation

You can generate and host the documentation locally with Sphinx:

cd docs
make clean && make html
cd _build/html
python -m http.server

7. Contributing

We welcome contributions of all kinds — from bug fixes to new modules.

  1. Fork the repo and create a feature branch.
  2. Run tests and format your code with black and flake8.
  3. Submit a Pull Request with clear details on your changes.

8. Acknowledgment

MEDfl is part of the MEDomicsLab initiative at the Université de Sherbrooke.
It was developed to enable secure, privacy-preserving, and reproducible machine learning across distributed medical datasets.


9. Authors


⭐ If you find this project useful, please consider starring it on GitHub to support continued development.

Metadata

Release files for medfl 2.0.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for medfl 2.0.10
File Size Uploaded Provenance
medfl-2.0.10.tar.gz 76.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for medfl 2.0.10
File Interpreter ABI Platform
medfl-2.0.10-py3-none-any.whl Python 3 none any Details

Total release size: 162.0 kB

Release files / medfl-2.0.10.tar.gz

Download URL medfl-2.0.10.tar.gz
Size 76.5 kB
Tags Source
SHA-256 checksum
How to use checksums
dccba2a3f1a88a12e5e4dd95269b570c4f38418ec1752ccfb245f3805aa9a694
BLAKE2b-256 checksum
How to use checksums
3ae1bdf45d263175870d0d6b53ec7b4eae1d4ab28f4265023c9e191268e4293b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.2

Release files / medfl-2.0.10-py3-none-any.whl

Download URL medfl-2.0.10-py3-none-any.whl
Size 85.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fa75997127e7f2e0176affded7a4beb609d35259235f8c466022b664fc860f25
BLAKE2b-256 checksum
How to use checksums
6ccbc507145ebb7a723e31af946e1289dcdafb575ddbebe0b91e09d58e55207f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.2

Security for medfl 2.0.10

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

2.0.10 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page