Xtra-Computing / FedTree

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

How to train a random forests model? #52

Open hy101 opened 1 year ago

hy101 commented 1 year ago

Random forests model is mentioned in the FedTree draft paper, could you please add some example code for that

Ch33s3Burger commented 1 year ago

You have to set the "bagging" option to 1. It is not mentioned in the docs

QinbinLi commented 1 year ago

Hi @hy101 and @Ch33s3Burger ,

Currently random forest is implemented by merging all trees trained by different parties in the federated setting. There is no performance guarantee for the federated random forest. If setting bagging=1, FedTree takes the average of the output of each tree as the prediction value. More features (e.g., instance and feature bagging) and documentation will come in the future.

Ch33s3Burger commented 1 year ago

Those are the parameters i set to train a random forest model. Are those parameters correct to simulate the training of a federated forest model with the data?

clf = FLRegressor(n_trees=1, n_parties=NUM_CLIENTS, mode="horizontal",
                  max_depth=MAX_DEPTH, objective="reg:linear", bagging=1, n_parallel_trees=NUM_TREES)
clf.fit(x_train, y_train)
QinbinLi commented 1 year ago

Hi @Ch33s3Burger ,

No, your code will only train a single tree. FedTree does not support n_parallel_trees currently. I'll let you know when this parameter is enabled.