FedCast: Federated Learning for Time Series Forecasting

FedCast Logo

FedCast is a comprehensive Python framework designed for time series forecasting using federated learning. It leverages the powerful Flower (flwr) framework to enable privacy-preserving, decentralized model training on distributed time series data.

Project Overview

The core goal of FedCast is to provide a modular, extensible, and easy-to-use platform for researchers and practitioners to develop and evaluate personalized federated learning strategies for time series analysis. The framework addresses the unique challenges of time series forecasting in federated settings, where data privacy, communication efficiency, and model personalization are critical concerns.

Problem Statement

Traditional centralized approaches to time series forecasting require all data to be collected at a central location, which poses significant challenges:

FedCast addresses these challenges through federated learning, enabling collaborative model training while keeping data distributed and private.

Key Features

Quick Start

Installation

pip install fedcast

Note: FedCast is currently in Beta (v0.1.1b1). While the core functionality is stable, some features may still be under development.

Basic Usage

from fedcast.datasets import SinusDataset
from fedcast.cast_models import MLP
from fedcast.federated_learning_strategies import FedTrend

# Load time series data
dataset = SinusDataset(num_clients=10, sequence_length=100)

# Define model architecture
model = MLP(input_size=100, hidden_size=64, output_size=1)

# Choose federated learning strategy
strategy = FedTrend()

# Run federated learning experiment
results = run_federated_experiment(
    dataset=dataset,
    model=model,
    strategy=strategy,
    num_rounds=50
)

Architecture

FedCast is built on a modular architecture that seamlessly integrates with the Flower framework:

Core Components

  1. Flower Integration Layer: Direct integration with Flower’s core functionality
  2. Data Management: Time series data loading, preprocessing, and validation
  3. Model Management: Model registry, version control, and personalization
  4. Federated Learning Strategies: Communication-efficient algorithms like FedLAMA and FedNova
  5. Evaluation & Experimentation: Time series metrics and MLflow integration
  6. Telemetry & Monitoring: Comprehensive experiment tracking

Technical Stack

Getting Started

Quick Start with Tutorials

New to FedCast? Start with our comprehensive tutorial series:

Development Setup

  1. Clone the repository:
    git clone https://github.com/NKDataConv/FedCast.git
    cd FedCast
    
  2. Install dependencies:
    poetry install
    
  3. Run tests:
    poetry run pytest
    

Running Experiments

# Basic experiments
poetry run python fedcast/experiments/basic_fedavg.py
poetry run python fedcast/experiments/basic_fedtrend.py

# Grid search experiments
poetry run python fedcast/experiments/grid_all.py

Monitoring Results

View experiment results with MLflow:

mlflow ui --host 127.0.0.1 --port 5000

Documentation

Supporters

This project is supported by the Bundesministerium für Forschung, Technologie und Raumfahrt (BMFTR).

BMFTR Logo

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.