Xtra-Computing / FedTree

A tree-based federated learning system (MLSys 2023)
https://fedtree.readthedocs.io/en/latest/index.html
Apache License 2.0
141 stars 40 forks source link

Python Vertical FL example #42

Closed Martinn1996 closed 1 year ago

Martinn1996 commented 2 years ago

Hi, can you provide an example using the Python wrapper for Vertical FL? Currently the examples all make use of Horizontal FL.

QinbinLi commented 2 years ago

Hi @Martinn1996 ,

I have added an example here. You can set ''mode'' to ''vertical'' and ''partition_mode'' to "vertical" to simulate the vertical FL.

Martinn1996 commented 2 years ago

Thank you! I think there is an error then in the documentation, since it says that the possible value for partition_mode are iid or noniid

I was also wondering how I can make the partition myself? As in, can I decide which features belongs to which party, thanks in advance.

QinbinLi commented 2 years ago

Hi @Martinn1996 ,

Thanks for the information! I have corrected the document. For the partition, you can manually partition the dataset into multiple subsets and use the CLI interface to conduct training by specifying them as data. For example, the configuration file example.conf is

data=./dataset/credit/credit_vertical_p0_withlabel.csv,./dataset/credit/credit_vertical_p1.csv
test_data=./dataset/credit/credit_vertical_p0_withlabel.csv,./dataset/credit/credit_vertical_p1.csv
model_path=fedtree.model
n_class=2
data_format=csv
n_parties=2
objective=binary:logistic
mode=vertical
privacy_tech=none
n_trees=10
depth=6
max_num_bin=16
learning_rate=0.1

Then run ./build/bin/FedTree-train example.conf.

We'll integrate this feature into Python interface. Thanks!