選取您的 Cookie 偏好設定

我們使用提供自身網站和服務所需的基本 Cookie 和類似工具。我們使用效能 Cookie 收集匿名統計資料,以便了解客戶如何使用我們的網站並進行改進。基本 Cookie 無法停用,但可以按一下「自訂」或「拒絕」以拒絕效能 Cookie。

如果您同意,AWS 與經核准的第三方也會使用 Cookie 提供實用的網站功能、記住您的偏好設定,並顯示相關內容,包括相關廣告。若要接受或拒絕所有非必要 Cookie,請按一下「接受」或「拒絕」。若要進行更詳細的選擇,請按一下「自訂」。

AWS CLI v1 範例

焦點模式
AWS CLI v1 範例 - Amazon SageMaker AI

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

上一節的範例適用於 AWS CLI v2。下列來自端點的請求和回應範例使用 AWS CLI 第 1 版。

在下列程式碼範例中,請求包含單一記錄,而回應就是其機率值。

aws sagemaker-runtime invoke-endpoint \ --endpoint-name test-endpoint-sagemaker-xgboost-model \ --content-type text/csv \ --accept text/csv \ --body '1,2,3,4' \ /dev/stderr 1>/dev/null

從先前的代碼範例中,回應輸出如下。

0.6

在下列程式碼範例中,請求包含兩筆記錄,而回應會包含其機率 (以逗號分隔)。

aws sagemaker-runtime invoke-endpoint \ --endpoint-name test-endpoint-sagemaker-xgboost-model \ --content-type text/csv \ --accept text/csv \ --body $'1,2,3,4\n5,6,7,8' \ /dev/stderr 1>/dev/null

從先前的程式碼範例中,--body 中的 $'content' 運算式會給出命令將內容中的 '\n' 解譯為分行符號。回應輸出如下。

0.6,0.3

在下列程式碼範例中,請求包含兩筆記錄,回應會包含其機率,並以分行符號分隔。

aws sagemaker-runtime invoke-endpoint \ --endpoint-name test-endpoint-csv-1 \ --content-type text/csv \ --accept text/csv \ --body $'1,2,3,4\n5,6,7,8' \ /dev/stderr 1>/dev/null

從先前的代碼範例中,回應輸出如下。

0.6 0.3

在下列程式碼範例中,請求包含單一記錄,而回應是來自包含三個類別之多類別模型的機率值。

aws sagemaker-runtime invoke-endpoint \ --endpoint-name test-endpoint-csv-1 \ --content-type text/csv \ --accept text/csv \ --body '1,2,3,4' \ /dev/stderr 1>/dev/null

從先前的代碼範例中,回應輸出如下。

0.1,0.6,0.3

在下列程式碼範例中,請求包含兩筆記錄,而回應會包含來自包含三個類別之多類別模型的機率值。

aws sagemaker-runtime invoke-endpoint \ --endpoint-name test-endpoint-csv-1 \ --content-type text/csv \ --accept text/csv \ --body $'1,2,3,4\n5,6,7,8' \ /dev/stderr 1>/dev/null

從先前的代碼範例中,回應輸出如下。

0.1,0.6,0.3 0.2,0.5,0.3

在下列程式碼範例中,請求包含兩筆記錄,而回應包含預測標籤和機率。

aws sagemaker-runtime invoke-endpoint \ --endpoint-name test-endpoint-csv-2 \ --content-type text/csv \ --accept text/csv \ --body $'1,2,3,4\n5,6,7,8' \ /dev/stderr 1>/dev/null

從先前的代碼範例中,回應輸出如下。

1,0.6 0,0.3

在下列程式碼範例中,請求包含兩筆記錄,而回應則包含標籤標題和機率。

aws sagemaker-runtime invoke-endpoint \ --endpoint-name test-endpoint-csv-3 \ --content-type text/csv \ --accept text/csv \ --body $'1,2,3,4\n5,6,7,8' \ /dev/stderr 1>/dev/null

從先前的代碼範例中,回應輸出如下。

"['cat','dog','fish']","[0.1,0.6,0.3]" "['cat','dog','fish']","[0.2,0.5,0.3]"

在下列程式碼範例中,請求包含單一記錄,而回應就是其機率值。

aws sagemaker-runtime invoke-endpoint \ --endpoint-name test-endpoint-sagemaker-xgboost-model \ --content-type text/csv \ --accept text/csv \ --body '1,2,3,4' \ /dev/stderr 1>/dev/null

從先前的代碼範例中,回應輸出如下。

0.6

在下列程式碼範例中,請求包含兩筆記錄,而回應會包含其機率 (以逗號分隔)。

aws sagemaker-runtime invoke-endpoint \ --endpoint-name test-endpoint-sagemaker-xgboost-model \ --content-type text/csv \ --accept text/csv \ --body $'1,2,3,4\n5,6,7,8' \ /dev/stderr 1>/dev/null

從先前的程式碼範例中,--body 中的 $'content' 運算式會給出命令將內容中的 '\n' 解譯為分行符號。回應輸出如下。

0.6,0.3

在下列程式碼範例中,請求包含兩筆記錄,回應會包含其機率,並以分行符號分隔。

aws sagemaker-runtime invoke-endpoint \ --endpoint-name test-endpoint-csv-1 \ --content-type text/csv \ --accept text/csv \ --body $'1,2,3,4\n5,6,7,8' \ /dev/stderr 1>/dev/null

從先前的代碼範例中,回應輸出如下。

0.6 0.3

在下列程式碼範例中,請求包含單一記錄,而回應是來自包含三個類別之多類別模型的機率值。

aws sagemaker-runtime invoke-endpoint \ --endpoint-name test-endpoint-csv-1 \ --content-type text/csv \ --accept text/csv \ --body '1,2,3,4' \ /dev/stderr 1>/dev/null

從先前的代碼範例中,回應輸出如下。

0.1,0.6,0.3

在下列程式碼範例中,請求包含兩筆記錄,而回應會包含來自包含三個類別之多類別模型的機率值。

aws sagemaker-runtime invoke-endpoint \ --endpoint-name test-endpoint-csv-1 \ --content-type text/csv \ --accept text/csv \ --body $'1,2,3,4\n5,6,7,8' \ /dev/stderr 1>/dev/null

從先前的代碼範例中,回應輸出如下。

0.1,0.6,0.3 0.2,0.5,0.3

在下列程式碼範例中,請求包含兩筆記錄,而回應包含預測標籤和機率。

aws sagemaker-runtime invoke-endpoint \ --endpoint-name test-endpoint-csv-2 \ --content-type text/csv \ --accept text/csv \ --body $'1,2,3,4\n5,6,7,8' \ /dev/stderr 1>/dev/null

從先前的代碼範例中,回應輸出如下。

1,0.6 0,0.3

在下列程式碼範例中,請求包含兩筆記錄,而回應則包含標籤標題和機率。

aws sagemaker-runtime invoke-endpoint \ --endpoint-name test-endpoint-csv-3 \ --content-type text/csv \ --accept text/csv \ --body $'1,2,3,4\n5,6,7,8' \ /dev/stderr 1>/dev/null

從先前的代碼範例中,回應輸出如下。

"['cat','dog','fish']","[0.1,0.6,0.3]" "['cat','dog','fish']","[0.2,0.5,0.3]"

在下列程式碼範例中,請求包含單一記錄,而回應就是其機率值。

aws sagemaker-runtime invoke-endpoint \ --endpoint-name test-endpoint-jsonlines \ --content-type application/jsonlines \ --accept application/jsonlines \ --body '{"features":["This is a good product",5]}' \ /dev/stderr 1>/dev/null

從先前的代碼範例中,回應輸出如下。

{"score":0.6}

在下列程式碼範例中,請求包含兩筆記錄,而回應包含預測標籤和機率。

aws sagemaker-runtime invoke-endpoint \ --endpoint-name test-endpoint-jsonlines-2 \ --content-type application/jsonlines \ --accept application/jsonlines \ --body $'{"features":[1,2,3,4]}\n{"features":[5,6,7,8]}' \ /dev/stderr 1>/dev/null

從先前的代碼範例中,回應輸出如下。

{"predicted_label":1,"probability":0.6} {"predicted_label":0,"probability":0.3}

在下列程式碼範例中,請求包含兩筆記錄,而回應包含標籤標題和機率。

aws sagemaker-runtime invoke-endpoint \ --endpoint-name test-endpoint-jsonlines-3 \ --content-type application/jsonlines \ --accept application/jsonlines \ --body $'{"data":{"features":[1,2,3,4]}}\n{"data":{"features":[5,6,7,8]}}' \ /dev/stderr 1>/dev/null

從先前的代碼範例中,回應輸出如下。

{"predicted_labels":["cat","dog","fish"],"probabilities":[0.1,0.6,0.3]} {"predicted_labels":["cat","dog","fish"],"probabilities":[0.2,0.5,0.3]}

在下列程式碼範例中,請求包含單一記錄,而回應就是其機率值。

aws sagemaker-runtime invoke-endpoint \ --endpoint-name test-endpoint-jsonlines \ --content-type application/jsonlines \ --accept application/jsonlines \ --body '{"features":["This is a good product",5]}' \ /dev/stderr 1>/dev/null

從先前的代碼範例中,回應輸出如下。

{"score":0.6}

在下列程式碼範例中,請求包含兩筆記錄,而回應包含預測標籤和機率。

aws sagemaker-runtime invoke-endpoint \ --endpoint-name test-endpoint-jsonlines-2 \ --content-type application/jsonlines \ --accept application/jsonlines \ --body $'{"features":[1,2,3,4]}\n{"features":[5,6,7,8]}' \ /dev/stderr 1>/dev/null

從先前的代碼範例中,回應輸出如下。

{"predicted_label":1,"probability":0.6} {"predicted_label":0,"probability":0.3}

在下列程式碼範例中,請求包含兩筆記錄,而回應包含標籤標題和機率。

aws sagemaker-runtime invoke-endpoint \ --endpoint-name test-endpoint-jsonlines-3 \ --content-type application/jsonlines \ --accept application/jsonlines \ --body $'{"data":{"features":[1,2,3,4]}}\n{"data":{"features":[5,6,7,8]}}' \ /dev/stderr 1>/dev/null

從先前的代碼範例中,回應輸出如下。

{"predicted_labels":["cat","dog","fish"],"probabilities":[0.1,0.6,0.3]} {"predicted_labels":["cat","dog","fish"],"probabilities":[0.2,0.5,0.3]}

在下列程式碼範例中,請求是 CSV 格式,回應是 JSON 行格式。

aws sagemaker-runtime invoke-endpoint \ --endpoint-name test-endpoint-csv-in-jsonlines-out \ --content-type text/csv \ --accept application/jsonlines \ --body $'1,2,3,4\n5,6,7,8' \ /dev/stderr 1>/dev/null

從先前的代碼範例中,回應輸出如下。

{"probability":0.6} {"probability":0.3}

在下列程式碼範例中,請求是 JSON 行格式,而回應是 CSV 格式。

aws sagemaker-runtime invoke-endpoint \ --endpoint-name test-endpoint-jsonlines-in-csv-out \ --content-type application/jsonlines \ --accept text/csv \ --body $'{"features":[1,2,3,4]}\n{"features":[5,6,7,8]}' \ /dev/stderr 1>/dev/null

從先前的代碼範例中,回應輸出如下。

0.6 0.3

在下列程式碼範例中,請求為 CSV 格式,且回應作為 JSON 格式匯出格式。

aws sagemaker-runtime invoke-endpoint \ --endpoint-name test-endpoint-csv-in-jsonlines-out \ --content-type text/csv \ --accept application/jsonlines \ --body $'1,2,3,4\n5,6,7,8' \ /dev/stderr 1>/dev/null

從先前的代碼範例中,回應輸出如下。

{"predictions":[{"label":1,"score":0.6},{"label":0,"score":0.3}]}

在下列程式碼範例中,請求是 CSV 格式,回應是 JSON 行格式。

aws sagemaker-runtime invoke-endpoint \ --endpoint-name test-endpoint-csv-in-jsonlines-out \ --content-type text/csv \ --accept application/jsonlines \ --body $'1,2,3,4\n5,6,7,8' \ /dev/stderr 1>/dev/null

從先前的代碼範例中,回應輸出如下。

{"probability":0.6} {"probability":0.3}

在下列程式碼範例中,請求是 JSON 行格式,而回應是 CSV 格式。

aws sagemaker-runtime invoke-endpoint \ --endpoint-name test-endpoint-jsonlines-in-csv-out \ --content-type application/jsonlines \ --accept text/csv \ --body $'{"features":[1,2,3,4]}\n{"features":[5,6,7,8]}' \ /dev/stderr 1>/dev/null

從先前的代碼範例中,回應輸出如下。

0.6 0.3

在下列程式碼範例中,請求為 CSV 格式,且回應作為 JSON 格式匯出格式。

aws sagemaker-runtime invoke-endpoint \ --endpoint-name test-endpoint-csv-in-jsonlines-out \ --content-type text/csv \ --accept application/jsonlines \ --body $'1,2,3,4\n5,6,7,8' \ /dev/stderr 1>/dev/null

從先前的代碼範例中,回應輸出如下。

{"predictions":[{"label":1,"score":0.6},{"label":0,"score":0.3}]}
隱私權網站條款Cookie 偏好設定
© 2025, Amazon Web Services, Inc.或其附屬公司。保留所有權利。