当前位置:网站首页>隱私計算FATE-離線預測
隱私計算FATE-離線預測
2022-06-27 13:58:00 【qq_43479892】
優質資源分享
| 學習路線指引(點擊解鎖) | 知識定比特 | 人群定比特 |
|---|---|---|
| 🧡 Python實戰微信訂餐小程序 🧡 | 進階級 | 本課程是python flask+微信小程序的完美結合,從項目搭建到騰訊雲部署上線,打造一個全棧訂餐系統。 |
| Python量化交易實戰 | 入門級 | 手把手帶你打造一個易擴展、更安全、效率更高的量化交易系統 |

一、說明
Fate 的模型預測有 離線預測 和 在線預測 兩種方式,兩者的效果是一樣的,主要是使用方式、適用場景、高可用、性能等方面有很大差別;本文分享使用 Fate 基於 縱向邏輯回歸 算法訓練出來的模型進行離線預測實踐。
- 基於上文 《隱私計算FATE-模型訓練》 中訓練出來的模型進行預測任務
- 關於 Fate 的基礎概覽和安裝部署可參考文章 《隱私計算FATE-關鍵概念與單機部署指南》
二、查詢模型信息
執行以下命令,進入 Fate 的容器中:
docker exec -it $(docker ps -aqf "name=standalone\_fate") bash
首先我們需要獲取模型對應的 model_id 和 model_version 信息,可以通過 job_id 執行以下命令獲取:
flow job config -j 202205070226373055640 -r guest -p 9999 --output-path /data/projects/fate/examples/my_test/
job_id 可以在 FATE Board 中查看。
執行成功後會返回對應的模型信息,以及在指定目錄下生成一個文件夾 job_202205070226373055640_config
{
"data": {
"job\_id": "202205070226373055640",
"model\_info": {
"model\_id": "arbiter-10000#guest-9999#host-10000#model",
"model\_version": "202205070226373055640"
},
"train\_runtime\_conf": {}
},
"retcode": 0,
"retmsg": "download successfully, please check /data/projects/fate/examples/my\_test/job\_202205070226373055640\_config directory",
"directory": "/data/projects/fate/examples/my\_test/job\_202205070226373055640\_config"
}
job_202205070226373055640_config 裏面包含4個文件:
- dsl.json:任務的 dsl 配置。
- model_info.json:模型信息。
- runtime_conf.json:任務的運行配置。
- train_runtime_conf.json:空。
三、模型部署
執行以下命令:
flow model deploy --model-id arbiter-10000#guest-9999#host-10000#model --model-version 202205070226373055640
分別通過 --model-id 與 --model-version 指定上面步驟查詢到的 model_id 和 model_version
部署成功後返回:
{
"data": {
"arbiter": {
"10000": 0
},
"detail": {
"arbiter": {
"10000": {
"retcode": 0,
"retmsg": "deploy model of role arbiter 10000 success"
}
},
"guest": {
"9999": {
"retcode": 0,
"retmsg": "deploy model of role guest 9999 success"
}
},
"host": {
"10000": {
"retcode": 0,
"retmsg": "deploy model of role host 10000 success"
}
}
},
"guest": {
"9999": 0
},
"host": {
"10000": 0
},
"model\_id": "arbiter-10000#guest-9999#host-10000#model",
"model\_version": "202205070730131040240"
},
"retcode": 0,
"retmsg": "success"
}
部署成功後返回一個新的 model_version
四、准備預測配置
執行以下命令:
cp /data/projects/fate/examples/dsl/v2/hetero_logistic_regression/hetero_lr_normal_predict_conf.json /data/projects/fate/examples/my_test/
直接把 Fate 自帶的縱向邏輯回歸算法預測配置樣例,複制到我們的
my_test目錄下。

預測的配置文件主要配置三部分:
- 上面部分為配置發起者以及參與方角色
- 中間部分需要填入正確的 模型信息
- 下面的則為預測使用的數據錶
唯一需要修改的就是中間的 模型信息 部分;需要注意的是這裏輸入的版本號是 模型部署 後返回的版本號,並且需要增加 job_type 為 predict 指定任務類型為預測任務。
五、執行預測任務
執行以下命令:
flow job submit -c hetero_lr_normal_predict_conf.json
與模型訓練一樣也是使用 submit 命令,通過 -c 指定配置文件。
執行成功後返回:
{
"data": {
"board\_url": "http://127.0.0.1:8080/index.html#/dashboard?job\_id=202205070731385067720&role=guest&party\_id=9999",
"code": 0,
"dsl\_path": "/data/projects/fate/fateflow/jobs/202205070731385067720/job\_dsl.json",
"job\_id": "202205070731385067720",
"logs\_directory": "/data/projects/fate/fateflow/logs/202205070731385067720",
"message": "success",
"model\_info": {
"model\_id": "arbiter-10000#guest-9999#host-10000#model",
"model\_version": "202205070730131040240"
},
"pipeline\_dsl\_path": "/data/projects/fate/fateflow/jobs/202205070731385067720/pipeline\_dsl.json",
"runtime\_conf\_on\_party\_path": "/data/projects/fate/fateflow/jobs/202205070731385067720/guest/9999/job\_runtime\_on\_party\_conf.json",
"runtime\_conf\_path": "/data/projects/fate/fateflow/jobs/202205070731385067720/job\_runtime\_conf.json",
"train\_runtime\_conf\_path": "/data/projects/fate/fateflow/jobs/202205070731385067720/train\_runtime\_conf.json"
},
"jobId": "202205070731385067720",
"retcode": 0,
"retmsg": "success"
}
六、查看預測結果
可以通過返回的 board_url 或者 job_id 去 FATE Board 裏查看結果,但是圖形化界面裏最多只能查看 100 條記錄;
我們可以通過 output-data 命令,導出指定組件的所有數據輸出:
flow tracking output-data -j 202205070731385067720 -r guest -p 9999 -cpn hetero_lr_0 -o /data/projects/fate/examples/my_test/predict
- -j:指定預測任務的 job_id
- -cpn:指定組件名。
- -o:指定輸出的目錄。
執行成功後返回:
{
"retcode": 0,
"directory": "/data/projects/fate/examples/my\_test/predict/job\_202205070731385067720\_hetero\_lr\_0\_guest\_9999\_output\_data",
"retmsg": "Download successfully, please check /data/projects/fate/examples/my\_test/predict/job\_202205070731385067720\_hetero\_lr\_0\_guest\_9999\_output\_data directory"
}
在目錄 /data/projects/fate/examples/my_test/predict/job_202205070731385067720_hetero_lr_0_guest_9999_output_data 中可以看到兩個文件:
- data.csv:為輸出的所有數據。
- data.meta:為數據的列頭。
掃碼關注有驚喜!

边栏推荐
- scrapy
- Step by step expansion of variable parameters in class templates
- Array related knowledge
- [day 27] given an integer n, print out the full permutation from 1 to n | Full Permutation template
- A method to realize automatic renaming of pictures uploaded by WordPress
- Pytorch learning 1 (learning documents on the official website)
- 【微服务|Sentinel】热点规则|授权规则|集群流控|机器列表
- 跨境电商多商户系统怎么选
- 关于接口测试自动化的总结与思考
- A statistical problem of shell script
猜你喜欢

全球芯片市场或陷入停滞,中国芯片逆势扩张加速提升自给率

Embedded development: embedded foundation callback function

赛迪顾问发布《“十四五” 关键应用领域之数据库市场研究报告》(附下载)

打印输出数(递归方法解决)

Debug tool
![[安洵杯 2019]Attack](/img/1a/3e82a54cfcb90ebafebeaa8ee1ec01.png)
[安洵杯 2019]Attack

请求一下子太多了,数据库危

类模板中可变参的逐步展开

What is the difference between the FAT32 and NTFS formats on the USB flash disk

What if the win system cannot complete the update and is revoking the status change
随机推荐
Bidding announcement: Oracle database maintenance service procurement of the First Affiliated Hospital of Jinan University
[WUSTCTF2020]girlfriend
Crane: a new way of dealing with dictionary items and associated data
Step by step expansion of variable parameters in class templates
Acwing game 57
【每日3题(3)】盒子中小球的最大数量
Rereading the classic: the craft of research (1)
[OS command injection] common OS command execution functions and OS command injection utilization examples and range experiments - based on DVWA range
基于 Nebula Graph 构建百亿关系知识图谱实践
JVM parameter setting and analysis
How to split microservices
解析Activity启动-生命周期角度
[day 27] given an integer n, print out the full permutation from 1 to n | Full Permutation template
Does Xinhua San still have to rely on ICT to realize its 100 billion enterprise dream?
Prometheus 2.26.0 new features
AXI总线
Summary of basic usage of command line editor sed
AGCO AI frontier promotion (6.27)
隐私计算FATE-离线预测
简析国内外电商的区别