使用Sensei机器学习API导入包装好的方法
本教程使用 Sensei Machine Learning API 创建 引擎,在用户界面中又称为“方法” 。
在开始之前,请务必注意Adobe Experience Platform Data Science Workspace 使用不同的术语来引用API和UI中的类似元素。 在本教程中使用API术语,下表概述了相关术语:
引擎包含用于解决特定问题的机器学习算法和逻辑。 下图提供了一个可视化图表,其中显示了 Data Science Workspace. 本教程侧重于创建引擎,即机器学习模型的大脑。
快速入门
本教程需要一个格式为Docker URL的打包“方法”文件。 请遵循 将源文件打包到方法中 本教程介绍如何创建打包的“方法”文件或提供您自己的文件。
{DOCKER_URL}
:智能服务的Docker图像的URL地址。
本教程要求您已完成 Adobe Experience Platform身份验证教程 以便成功调用 Platform API。 完成身份验证教程将提供所有中所有所需标头的值 Experience Platform API调用,如下所示:
{ACCESS_TOKEN}
:在身份验证后提供的特定持有者令牌值。{ORG_ID}
:在独特的Adobe Experience Platform集成中找到您的组织凭据。{API_KEY}
:在独特的Adobe Experience Platform集成中找到的特定API密钥值。
创建引擎
可以通过向/engines端点发出POST请求来创建引擎。 已创建的引擎是根据必须作为API请求的一部分包含的已打包方法文件的形式配置的。
创建具有Docker URL的引擎 create-an-engine-with-a-docker-url
要使用存储在Docker容器中的打包的配方文件创建引擎,您必须为打包的配方文件提供Docker URL。
API格式
POST /engines
请求Python/R
curl -X POST \
https://platform.adobe.io/data/sensei/engines \
-H 'Authorization: {ACCESS_TOKEN}' \
-H 'X-API-KEY: {API_KEY}' \
-H 'content-type: multipart/form-data' \
-H 'x-gw-ims-org-id: {ORG_ID}' \
-H `x-sandbox-name: {SANDBOX_NAME}` \
-F 'engine={
"name": "Retail Sales Engine Python",
"description": "A description for Retail Sales Engine, this Engines execution type is Python",
"type": "Python"
"artifacts": {
"default": {
"image": {
"location": "{DOCKER_URL}",
"name": "retail_sales_python",
"executionType": "Python"
}
}
}
}'
engine.name
engine.description
engine.type
type
是 Python
, R
, PySpark
, Spark
(Scala),或 Tensorflow
.artifacts.default.image.location
{DOCKER_URL}
此处显示。 完整的Docker URL具有以下结构: your_docker_host.azurecr.io/docker_image_file:version
artifacts.default.image.name
artifacts.default.image.executionType
executionType
是 Python
, R
, PySpark
, Spark
(Scala),或 Tensorflow
.请求PySpark
curl -X POST \
https://platform.adobe.io/data/sensei/engines \
-H 'Authorization: Bearer {ACCESS_TOKEN}' \
-H 'x-api-key: {API_KEY}' \
-H 'x-gw-ims-org-id: {ORG_ID}' \
-H 'x-sandbox-name: {SANDBOX_NAME}' \
-H 'content-type: multipart/form-data' \
-F 'engine={
"name": "PySpark retail sales recipe",
"description": "A description for this Engine",
"type": "PySpark",
"mlLibrary":"databricks-spark",
"artifacts": {
"default": {
"image": {
"name": "modelspark",
"executionType": "PySpark",
"packagingType": "docker",
"location": "v1d2cs4mimnlttw.azurecr.io/sarunbatchtest:0.0.1"
}
}
}
}'
name
description
type
mlLibrary
artifacts.default.image.location
artifacts.default.image.executionType
请求Scale
curl -X POST \
https://platform.adobe.io/data/sensei/engines \
-H 'Authorization: Bearer {ACCESS_TOKEN}' \
-H 'x-api-key: {API_KEY}' \
-H 'x-gw-ims-org-id: {ORG_ID}' \
-H 'x-sandbox-name: {SANDBOX_NAME}' \
-H 'content-type: multipart/form-data' \
-F 'engine={
"name": "Spark retail sales recipe",
"description": "A description for this Engine",
"type": "Spark",
"mlLibrary":"databricks-spark",
"artifacts": {
"default": {
"image": {
"name": "modelspark",
"executionType": "Spark",
"packagingType": "docker",
"location": "v1d2cs4mimnlttw.azurecr.io/sarunbatchtest:0.0.1"
}
}
}
}'
name
description
type
mlLibrary
artifacts.default.image.location
artifacts.default.image.executionType
响应
成功响应将返回包含新创建引擎的详细信息的有效负载,包括其唯一标识符(id
)。 以下示例响应适用于 Python 引擎。 此 executionType
和 type
键会根据提供的POST而更改。
{
"id": "{ENGINE_ID}",
"name": "A name for this Engine",
"description": "A description for this Engine",
"type": "Python",
"algorithm": "Classification",
"created": "2019-01-01T00:00:00.000Z",
"createdBy": {
"userId": "Jane_Doe@AdobeID"
},
"updated": "2019-01-01T00:00:00.000Z",
"artifacts": {
"default": {
"image": {
"location": "{DOCKER_URL}",
"name": "An additional name for the Docker image",
"executionType": "Python",
"packagingType": "docker"
}
}
}
}
成功的响应会显示包含有关新创建引擎的信息的JSON有效负载。 此 id
key表示唯一引擎标识符,在下一个教程中需要它来创建MLInstance。 在继续后续步骤之前,请确保已保存引擎标识符。
后续步骤 next-steps
您已使用API创建了一个引擎,并且获取了唯一的引擎标识符作为响应正文的一部分。 了解如何使用此引擎标识符后,您可以在下一个教程中使用它 使用API创建、训练和评估模型.