使用Sensei機器學習API匯入封裝的配方
本教學課程使用 Sensei Machine Learning API 建立 引擎,在使用者介面中又稱為「配方」 。
開始使用前,請務必注意Adobe Experience Platform Data Science Workspace 會使用不同的辭彙來參照API和UI中的類似元素。 在本教學課程中使用API辭彙,下表概述相關辭彙:
Engine包含用於解決特定問題的機器學習演演算法和邏輯。 下圖提供視覺效果,顯示中的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容器中的封裝配方檔案來建立Engine,您必須為封裝的配方檔案提供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
請求Scala
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建立引擎,而且取得唯一引擎識別碼做為回應本文的一部分。 您可在下一個教學課程中使用此Engine識別碼,瞭解如何 使用API建立、訓練和評估模型.