Skip to content

xuefeng-xu/fedps

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FedPS: Federated data Preprocessing via aggregated Statistics

The workflow consists of five steps: ① Compute local statistics; ② Share and aggregate statistics; ③ Derive preprocessing parameters; ④ Broadcast parameters to clients; ⑤ Apply preprocessing locally.

Overview

Installation

Dependencies

  • Python (>= 3.10)
  • Scikit-learn (~= 1.7)
  • NumPy (>= 1.20)
  • DataSketches (<= 4.1.0)
  • PyZMQ

Building from source

  1. Create a Python env
conda create --name fedps python=3.10
conda activate fedps
  1. Clone this project
git clone https://github.com/xuefeng-xu/fedps.git && cd fedps
  1. Build the project
pip install -e .

Usage

  1. Set up communication channels
# Client1 channel
from fedps.channel import ClientChannel

channel = ClientChannel(
    local_ip="127.0.0.1", local_port=5556,
    remote_ip="127.0.0.1", remote_port=5555,
)
# Client2 channel
from fedps.channel import ClientChannel

channel = ClientChannel(
    local_ip="127.0.0.1", local_port=5557,
    remote_ip="127.0.0.1", remote_port=5555,
)
# Server channel
from fedps.channel import ServerChannel

channel = ServerChannel(
    local_ip="127.0.0.1", local_port=5555,
    remote_ip=["127.0.0.1", "127.0.0.1"],
    remote_port=[5556, 5557],
)
  1. Specify FL_type and role in the preprocessor
  • FL_type: "H" (Horizontal) or "V" (Vertical)

  • role: "client" or "server"

# Client1 code example
from fedps.preprocessing import MinMaxScaler

X = [[-1, 2], [-0.5, 6]]
est = MinMaxScaler(FL_type="H", role="client", channel=channel)
Xt = est.fit_transform(X)
print(Xt)
# Client2 code example
from fedps.preprocessing import MinMaxScaler

X = [[0, 10], [1, 18]]
est = MinMaxScaler(FL_type="H", role="client", channel=channel)
Xt = est.fit_transform(X)
print(Xt)
# Server code example
from fedps.preprocessing import MinMaxScaler

est = MinMaxScaler(FL_type="H", role="server", channel=channel)
est.fit()
  1. Run the script
# Run in three terminals
python client1.py
python client2.py
python server.py

PS: See more cases in the example folder.

Available preprocessing modules

Differences from Scikit-learn

Acknowledgement

This project is build on Scikit-learn.

About

A unified framework for tabular data preprocessing in federated learning.

Topics

Resources

Stars

Watchers

Forks

Contributors

Languages