Calling Model Service¶
完成模型版本部署上线操作后,可通过模型服务的接口,调用已部署的模型服务。
获取模型服务接口URL¶
模型服务接口URL的范式为:
{URI-scheme}://{domainName}/eap/metrics/{namespace}/api/v1.0/eap-dev/{modelName-deployment}/predictions
其中:
URI-sheme
:协议,支持HTTP协议。domainName
:服务的网关地址,其范式为eap-{enos-environment}.{abc}.com
,其中enos-environment
为EnOS的部署环境名称。namespace
:部署服务的容器资源名称,如下图所示:modelName
:模型名称。
请求示例¶
以调用某个预测模型的服务为例,请求格式如下:
url: http://eap.{domainName}/eap/metrics/eap-dev/api/v1.0/eap-dev/demo-deployment/predictions
method: POST
requestBody:
{
"data": {
"names": [
"AGE",
"AGE1",
"AGE1",
"AGE1"
],
"ndarray": [
[
6,
3,
2,
2
]
]
}
}
feedback接口请求示例¶
feedback接口请求格式如下:
url: http://eap.{domainName}/eap/metrics/eap-dev/api/v1.0/eap-dev/demo-deployment/feedback
method:POST
requestBody:
{
"request": {
"data": {
"names": [
"AGE",
"RACE",
"DCAPS",
"VOL"
],
"ndarray": [
[
1,
1,
1,
100
]
]
}
},
"response": {
"meta": {
"routing": {
"eg-router": 1
}
},
"data": {
"names": [
"t:0",
"t:1",
"t:2"
],
"ndarray": [
[
0.027491291429107768,
0.00240284367849394,
1.0586489239828885E-4
]
]
}
},
"reward": 1
}
其中:
request
:传入测试数据。response
:返回真实数据。data
:真实预测结果。routing
:老虎机部署参数,指定进行预测的模型版本(按照模型版本部署顺序)。reward
:老虎机参数,激励值。