Skip to content

This project implements Federated Learning (FL) models—both Horizontal and Vertical—for diabetes prediction while ensuring secure client-server communication using Solidity-based smart contracts

Notifications You must be signed in to change notification settings

elaaatif/Federated-Learning-with-Blockchain

Repository files navigation

Federated Learning for Diabetes Prediction with Solidity Smart Contracts

Overview

This project implements Federated Learning (FL) models—both Horizontal and Vertical—for diabetes prediction while ensuring secure client-server communication using Solidity-based smart contracts. It aims to preserve data privacy while enabling collaborative model training.

Table of Contents

Introduction

Traditional machine learning approaches require centralized data collection, posing security and compliance risks. Federated Learning (FL) addresses this by training models locally and only exchanging model updates. This project integrates Solidity smart contracts to enhance FL security.

Problem Statement

Medical data privacy is critical. This project focuses on federated learning for diabetes prediction using a dataset where data remains distributed among multiple institutions, ensuring compliance with regulations like GDPR and HIPAA.

Fundamentals

Federated Learning

  • Decentralized ML approach that enables collaborative training without sharing raw data.
  • Types of FL:
    • Horizontal Federated Learning (HFL): Clients have the same feature space but different data samples.
    • Vertical Federated Learning (VFL): Clients share common user samples but different feature spaces. image

Solidity

Solidity is used to implement smart contracts for securing FL communication. The contract records participant consent on the blockchain, ensuring trust and data integrity.

Dataset

  • Source: Diabetes Prediction in America dataset (Kaggle)
  • Features: Pregnancies, Glucose, Blood Pressure, BMI, Insulin, Age, etc.
  • Target Variable: Diabetes Diagnosis (1 = diabetic, 0 = non-diabetic)

Implementation

Local Model Testing

Implemented baseline classifiers:

  1. Random Forest Classifier
  2. Gradient Boosting Classifier
  3. Stacking Ensemble (Meta-Model)

Federated Learning Models

Implemented both Horizontal FL (HFL) and Vertical FL (VFL) using PyTorch.

  • HFL: Clients train models locally, updates are aggregated using Federated Averaging.
  • VFL: Clients contribute different features, with a central model aggregating partial outputs.

Smart Contract for Security

A Solidity smart contract (FLConsent.sol) ensures:

  • Immutable consent storage for FL participants.
  • Tamper-proof data integrity using Ethereum blockchain.
  • Secure authentication of participating clients.

Deployment & Execution

Steps:

  1. Compile and Deploy Solidity Contract
    • Use Remix IDE with Solidity v0.8.19.
    • Deploy on Ganache for local testing.
  2. Train Federated Learning Model
    • Split dataset for multiple clients.
    • Train models locally and aggregate weights.
  3. Integrate Smart Contract
    • Record client consent.
    • Securely authenticate FL participants. image image

Conclusion

This project successfully integrates Federated Learning and Blockchain to enable privacy-preserving AI in healthcare. Future work includes:

  • Enhancing security with cryptographic techniques (e.g., Secure Multi-Party Computation).
  • Extending the framework to other medical datasets.
  • Incorporating incentive mechanisms for participant engagement.

References

  1. Google Research - Federated Learning
  2. Flower AI - Vertical Federated Learning
  3. Solidity Documentation

About

This project implements Federated Learning (FL) models—both Horizontal and Vertical—for diabetes prediction while ensuring secure client-server communication using Solidity-based smart contracts

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published