We provide a scikit-learn wrapper interface. Before you use the Python interface, you must install FedTree first. Then, you can run the following command to install the Python package from source.
python setup.py installWe provide two classes, FLClassifier and FLRegressor, where the first is for classification task and the second is for regression task.
Please refer to here for the list of parameters.
fit(X, y):
Fit the FedTree model according to the given training data.
predict(X):
Perform prediction on samples in X.
save_model(model_path):
Save the FedTree model to model_path.
load_model(model_path):
Load the FedTree model from model_path.
Users can simply input parameters to these classes, call fit() and predict functions like models in scikit-learn.
from fedtree import FLRegressor
from sklearn.metrics import mean_squared_error
from sklearn.datasets import load_svmlight_file
x, y = load_svmlight_file("../dataset/test_dataset.txt")
clf = FLRegressor(n_trees=10, n_parties=2, mode="horizontal", learning_rate=0.2, max_depth=4, objective="reg:linear")
clf.fit(x, y)
y_pred = clf.predict(x)
rmse = mean_squared_error(y, y_pred, squared=False)
print("rmse:", rmse)Under examples directory, you can find three examples on how to use FedTree with Python.