forked from FederatedAI/FATE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_hetero_sbt_regression.py
48 lines (40 loc) · 1.76 KB
/
test_hetero_sbt_regression.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import argparse
from fate_client.pipeline.components.fate import HeteroSecureBoost, PSI, Evaluation, Reader
from fate_client.pipeline import FateFlowPipeline
from fate_client.pipeline.utils import test_utils
def main(config="../config.yaml", namespace=""):
if isinstance(config, str):
config = test_utils.load_job_config(config)
parties = config.parties
guest = parties.guest[0]
host = parties.host[0]
pipeline = FateFlowPipeline().set_parties(guest=guest, host=host)
reader_0 = Reader("reader_0")
reader_0.guest.task_parameters(
namespace=f"experiment{namespace}",
name="breast_hetero_guest"
)
reader_0.hosts[0].task_parameters(
namespace=f"experiment{namespace}",
name="breast_hetero_host"
)
psi_0 = PSI("psi_0", input_data=reader_0.outputs["output_data"])
hetero_sbt_0 = HeteroSecureBoost('sbt_0', num_trees=3, max_bin=32, max_depth=3, objective='regression:l2',
he_param={'kind': 'paillier', 'key_length': 1024}, train_data=psi_0.outputs['output_data'],)
evaluation_0 = Evaluation(
'eval_0',
runtime_parties=dict(guest=guest),
metrics=['rmse'],
input_datas=[hetero_sbt_0.outputs['train_output_data']]
)
pipeline.add_tasks([reader_0, psi_0, hetero_sbt_0, evaluation_0])
pipeline.compile()
pipeline.fit()
if __name__ == "__main__":
parser = argparse.ArgumentParser("PIPELINE DEMO")
parser.add_argument("--config", type=str, default="../config.yaml",
help="config file")
parser.add_argument("--namespace", type=str, default="",
help="namespace for data stored in FATE")
args = parser.parse_args()
main(config=args.config, namespace=args.namespace)