Arrythmia-Detection is a federated learning system built using Flower (flwr) for arrhythmia detection on the MIT-BIH dataset. The project demonstrates privacy-preserving distributed model training, where multiple clients collaboratively train a model without sharing raw data.
-
Server (
server.py)- Orchestrates federated learning rounds.
- Aggregates model updates and evaluation metrics from clients.
- Uses the FedAvg strategy for model aggregation.
- Configurable for number of rounds and client requirements.
- Handles logging and suppresses unnecessary warnings.
-
Clients (
client1.py,client2.py,client_base.py)- Each client trains locally on its own data.
- Inherit shared logic from
client_base.py. - Perform local training, evaluation, and send updates/metrics to the server.
-
Data Preparation (
prep_mitbih.py)- Prepares and preprocesses the MIT-BIH arrhythmia dataset for client consumption.
-
Server ↔ Clients
- Server sends global model and training instructions to clients.
- Clients send model updates and evaluation metrics to the server.
- Heartbeat/status signals for monitoring client availability.
-
Data Provisioning
- Clients load and preprocess data using
prep_mitbih.py.
- Clients load and preprocess data using
- The server and clients can be deployed on cloud services, on-premises machines, or containers.
- Secure communication (SSL/TLS) is recommended for production.
- Logging and monitoring are integrated for system health and debugging.
Arrythmia-Detection/
│
├── server.py # Federated server logic and orchestration
├── client_base.py # Base class for client logic
├── client1.py # Client 1 implementation
├── client2.py # Client 2 implementation
├── prep_mitbih.py # Data preparation for MIT-BIH dataset
- Python 3.7+
- Flower (
pip install flwr) - Required ML/DL libraries (e.g., TensorFlow, PyTorch, NumPy, etc.)
- MIT-BIH Arrhythmia dataset
-
Clone the repository:
git clone <your-repo-url> cd Arrythmia-Detection
-
Install dependencies:
pip install flwr # Add other dependencies as needed
Run prep_mitbih.py to preprocess the MIT-BIH dataset for clients.
python server.py- The server listens on
0.0.0.0:8000by default.
In separate terminals, start each client:
python client1.py
python client2.py- Each client loads its data, trains locally, and communicates with the server.
- Modify
client_base.pyto change client logic or add new clients. - Adjust server parameters (e.g., number of rounds) in
server.py. - Update data preprocessing steps in
prep_mitbih.pyas needed.
- The server and clients use Python's logging module for event tracking.
- Consider integrating external monitoring tools for production deployments.
- For production, enable SSL/TLS for secure communication.
- Implement authentication for client-server connections if needed.
Specify your license here (e.g., MIT, Apache 2.0).
