使用Sensei機器學習API匯入封裝的配方
此教學課程使用Sensei Machine Learning API來建立引擎,也稱為使用者介面中的配方。
在開始使用之前,請務必注意,Adobe Experience Platform Data Science Workspace使用不同的辭彙來參照API和UI中的類似元素。 在本教學課程中使用API辭彙,下表概述相關辭彙:
引擎包含用於解決特定問題的機器學習演演算法和邏輯。 下圖提供顯示Data Science Workspace中API工作流程的視覺效果。 本教學課程著重於建立引擎,即機器學習模型的大腦。
快速入門
本教學課程需要採用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
要求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引擎。 根據提供的POST,executionType
和type
金鑰會變更。
{
"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
索引鍵代表唯一的Engine識別碼,在下一個教學課程中是建立MLInstance的必要專案。 繼續後續步驟之前,請確定已儲存引擎識別碼。
後續步驟 next-steps
您已使用API建立引擎,且已取得唯一引擎識別碼作為回應本文的一部分。 當您瞭解如何使用API建立、訓練及評估模型時,可以在下一個教學課程中使用此引擎識別碼。