metadata
title: Federated Credit Scoring
emoji: π
colorFrom: red
colorTo: red
sdk: streamlit
app_port: 8501
tags:
- streamlit
- federated-learning
- machine-learning
- privacy
pinned: false
short_description: Federated Learning Credit Scoring Demo
license: mit
Federated Learning for Privacy-Preserving Financial Data Generation with RAG Integration
This project implements a complete federated learning framework with a Retrieval-Augmented Generation (RAG) system for privacy-preserving synthetic financial data generation. The system includes a working server, multiple clients, and an interactive web application.
Live Demo
Try it now: Hugging Face Spaces
Features
- Complete Federated Learning System: Working server, clients, and web interface
- Real-time Predictions: Get credit score predictions from the federated model
- Interactive Web App: Beautiful Streamlit interface with demo and real modes
- Client Simulator: Built-in client simulator for testing
- Privacy-Preserving: No raw data sharing between participants
- Educational: Learn about federated learning concepts
- Production Ready: Docker and Kubernetes deployment support
Quick Start
Option 1: Try the Demo
- Visit the Live Demo
- Enter customer features and get predictions
- Learn about federated learning
Option 2: Run Locally (Complete System)
- Install Dependencies
# Create virtual environment
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements-full.txt
- Start the Federated Server
python -m src.main --mode server --config config/server_config.yaml
- Start Multiple Clients (in separate terminals)
python -m src.main --mode client --config config/client_config.yaml
- Run the Web Application
streamlit run webapp/streamlit_app.py
- Test the Complete System
python test_complete_system.py
How to Use
Web Application Features:
- Demo Mode: Works without server (perfect for HF Spaces)
- Real Mode: Connects to federated server for live predictions
- Client Simulator: Start/stop client participation
- Training Progress: Real-time monitoring of federated rounds
- Server Health: Check server status and metrics
- Educational Content: Learn about federated learning
Federated Learning Process:
- Server Initialization: Global model is created
- Client Registration: Banks register with the server
- Local Training: Each client trains on their local data
- Model Updates: Clients send model updates (not data) to server
- Aggregation: Server aggregates updates using FedAvg
- Global Model: Updated model is distributed to all clients
- Prediction: Users can get predictions from the global model
System Architecture
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Web App β β Federated β β Client 1 β
β (Streamlit) βββββΊβ Server βββββΊβ (Bank A) β
β β β (Coordinator) β β β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β
βΌ
βββββββββββββββββββ
β Client 2 β
β (Bank B) β
βββββββββββββββββββ
Project Structure
FinFedRAG-Financial-Federated-RAG/
βββ src/
β βββ api/ # REST API for server and client communication
β βββ client/ # Federated learning client implementation
β βββ server/ # Federated learning server and coordinator
β βββ rag/ # Retrieval-Augmented Generation components
β βββ models/ # VAE/GAN models for data generation
β βββ utils/ # Privacy, metrics, and utility functions
βββ webapp/ # Streamlit web application
βββ config/ # Configuration files
βββ tests/ # Unit and integration tests
βββ docker/ # Docker configurations
βββ kubernetes/ # Kubernetes deployment files
βββ app.py # Root app.py for Hugging Face Spaces deployment
βββ requirements.txt # Minimal dependencies for HF Spaces
βββ requirements-full.txt # Complete dependencies for local development
βββ test_complete_system.py # End-to-end system test
Configuration
Server Configuration (config/server_config.yaml
)
# API server configuration
api:
host: "0.0.0.0"
port: 8080
# Federated learning configuration
federated:
min_clients: 2
rounds: 10
# Model configuration
model:
input_dim: 32
hidden_layers: [128, 64]
Client Configuration (config/client_config.yaml
)
client:
id: "client_1"
server_url: "http://localhost:8080"
data:
batch_size: 32
input_dim: 32
Testing
Run the complete system test:
python test_complete_system.py
This will test:
- Server health
- Client registration
- Training status
- Prediction functionality
Deployment
Hugging Face Spaces (Recommended)
- Fork this repository
- Create a new Space on HF
- Connect your repository
- Deploy automatically
Local Development
# Install full dependencies
pip install -r requirements-full.txt
# Run complete system
python -m src.main --mode server --config config/server_config.yaml &
python -m src.main --mode client --config config/client_config.yaml &
streamlit run webapp/streamlit_app.py
Docker Deployment
docker-compose up
Performance
- Model Accuracy: 85%+ across federated rounds
- Response Time: <1 second for predictions
- Scalability: Supports 10+ concurrent clients
- Privacy: Zero raw data sharing
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
License
MIT License - see LICENSE file for details.
Acknowledgments
- TensorFlow for the ML framework
- Streamlit for the web interface
- Hugging Face for hosting the demo
Live Demo: https://huggingface.co/spaces/ArchCoder/federated-credit-scoring