back to projects

fed-rf-mk

Machine LearningPythonPySyftFederated LearningXGBoostPrivacy MLExplainabilitycompleted2025

fed-rf-mk is a privacy-preserving federated learning framework for tree-based models, enabling organizations such as hospitals and clinical research groups to collaboratively train Random Forest and XGBoost classifiers without ever centralizing raw data. Each participant keeps its data locally; only trained model artifacts, metrics, and aggregated statistics leave the silo. The framework is built on PySyft, which provides the secure code dispatch and execution governance layer between an orchestrator and each data silo.

The architecture separates orchestrator logic from silo logic. The FLClient orchestrator manages connections to each participating DataSite, dispatches training and evaluation code as PySyft code requests governed by an explicit input policy, collects results in parallel, and aggregates them into a federated global model. On the silo side, FLServer stands up a local PySyft Datasite that can auto-approve or manually review incoming code requests before executing them against its private dataset, returning only derived artifacts such as model weights, metrics, and explainability summaries.

Aggregation is model-aware. For Random Forest, each silo contributes a number of its decision trees proportional to its weight, sampled and pooled into a merged forest that remains fully compatible with scikit-learn's prediction API. For XGBoost, whose sequential boosting rounds cannot be naively merged, the framework instead maintains an ensemble of per-silo boosters and computes a weighted average of margin probabilities at evaluation time, with optional Platt or temperature-scaling calibration. A weight normalization layer handles equal-weighting, partial-weighting, and over-specified-weight scenarios, always renormalizing strictly to sum to 1.0.

The framework includes a two-method explainability pipeline combining SHAP and permutation feature importance, producing federated global feature-importance rankings through weighted averaging across silos. Both methods are gated by a dual-consent policy: the orchestrator must request the computation, and each silo independently retains veto power via a local analysis policy, ensuring no sensitive feature data leaves a silo without explicit local consent. Adaptive weighting supports non-IID (heterogeneous) data distributions across silos, with the framework evaluated on three real-world healthcare datasets: AIDS Clinical Trials, Diabetic Retinopathy, and BRFSS Heart Disease Indicators, showing federation consistently improves over single-site baselines under data scarcity and heterogeneity, with federated accuracy within 9% of centralized methods.

The framework is published as an installable Python package under the IEETA organization (University of Aveiro), with CI/CD via GitHub Actions, unit tests covering core aggregation and weight normalization logic, and pre-commit hooks. It underlies two research papers: "A Federated Random Forest Solution for Secure Distributed Machine Learning" (IEEE CBMS 2025) and "Privacy-aware Federated Tree Models for Secure and Interpretable Machine Learning" (under review).

  • ·Designed a client-server architecture (FLClient orchestrator + DataSite servers) with weighted tree-sampling aggregation for Random Forest and margin-space ensemble aggregation for XGBoost
  • ·Built privacy-aware federated explainability tooling using distributed SHAP and permutation feature importance with cross-silo weighted averaging and dual-consent privacy gating
  • ·Evaluated on three real-world healthcare datasets, achieving federated accuracy within 9% of centralized methods with consistent gains under data scarcity and heterogeneity
  • ·Published as a pip-installable package with CI/CD, unit tests, and pre-commit hooks, underlying two research papers (IEEE CBMS 2025, under review)

Core

PythonPySyft

ML

Random ForestXGBoostFederated LearningSHAP

Tooling

GitHub Actionspytestpre-commit