FATE入门案例——纵向 SecureBoost 模型

FATE入门案例——纵向 SecureBoost 模型

0,demo说明

使用的hetero_secureboost案例,角色及数据:(1) guest: breast_hetero_guest.csv (2) host: breast_hetero_host.csv。

参考来源:https://github.com/FederatedAI/FATE/tree/master/examples/dsl/v2/hetero_secureboost

1,模型训练

1,使用如下命令提交了job进行模型训练:

flow job submit -c ${runtime_config} -d ${dsl}

#配置文件为:
Binary-Class:
example-data: (1) guest: breast_hetero_guest.csv (2) host: breast_hetero_host.csv
dsl: test_secureboost_train_dsl.json
runtime_config: test_secureboost_train_binary_conf.json

2,训练细节分析:

参考来源:https://github.com/FederatedAI/FATE/blob/master/examples/experiment_template/user_usage/pipeline_predict_tutorial.md

https://github.com/FederatedAI/FATE/blob/master/python/fate_client/flow_client/README_zh.rst

训练包括以下几个阶段,分别由相应组件执行:

  1. reader:读取原始数据;
  2. dateio:将数据转换为实例样本;
  3. Intersection:求host和guest方的交集;
  4. HeteroSecureBoost:树模型;
  5. evaluation:评估指标。

你可以从http://hostip:8080/fateboard面板查看到建模信息:

image-20210328195207508

这里的_0_1指的是训练和验证的数据集,只是example中的例子该部分都是同样的数据,所以他们会有相同的dataouput.

其实第一棵树的训练都是要使用各自的标签。(待验证)

image-20210328192710335

模型输出

image-20210328192919093

数据输出:

image-20210328193025876

模型各种指标:

image-20210328193811542

host方的模型输出:

image-20210328193445268

host的标签在guest处都是匿名处理了的。

image-20210328193523205

host方无data output。

host方无模型指标。

2,模型预测

那么如何用我们已经训练好的模型进行预测呢?

参考:https://github.com/FederatedAI/FATE/blob/master/examples/experiment_template/user_usage/dsl_v2_predict_tutorial.md

1,通过我们刚刚提交的jobid,找到对应的model_id和model_version:

flow job config -j 202103270933192332863 -r guest -p 9999 -o ./

image-20210328210923197

2,部署模型

flow model deploy --model-id guest-9999#host-9998#model --model-version 202103270933192332863

image-20210328210948645

3,修改test_predict_conf.json配置文件的model_id和model_id,包括part_id和role。

4,使用修改好的配置文件提交任务进行预测:

image-20210328211014338

可以看到模型预测的DAG似乎有些不同:

image-20210328195124362

由前所述,这里的read和dataio几乎是一样的,当然这也包括intersection。

guest方的module output也同上。

这里的预测结果几乎和上面看到的是一样的,还是因为example的案例中都使用了同样的样本。

image-20210328194639357

不失一般性,我们看下模型输出的第2棵树:

image-20210328200132958

可以知道,guest方和host方的树模型都有对方的特征(实际上这两棵树本身就应该是这样,并且他们也是互补的)。因此,在模型使用时,需要同时用到这两棵树。

  • 8
    点赞
  • 37
    收藏
    觉得还不错? 一键收藏
  • 8
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值