測試受控線上端點

已完成

部署即時服務之後,您可以從用戶端應用程式使用,以預測新資料案例的標籤。

使用 Azure Machine Learning Studio

您可瀏覽至 [端點] 頁面,以列出 Azure Machine Learning Studio 中的所有端點。 在 [即時端點] 索引標籤中,會顯示所有端點。

您可以選取端點來檢閱其詳細資料和部署記錄。

此外,您可以使用 Studio 來測試端點。

Diagram showing different hyperparameter values resulting in different models by performing hyperparameter tuning.

使用 Azure Machine Learning Python SDK

若要進行測試,您也可以使用 Azure Machine Learning Python SDK 來叫用端點。

一般來說,您會使用下列結構,將資料以 JSON 格式傳送給部署的模型:

{
  "data":[
      [0.1,2.3,4.1,2.0], // 1st case
      [0.2,1.8,3.9,2.1],  // 2nd case,
      ...
  ]
}

部署的模型的回應是一個 JSON 集合,其中包含在資料中所提交每個案例的預測。 下列程式碼範例會叫用端點並顯示回應:

# test the blue deployment with some sample data
response = ml_client.online_endpoints.invoke(
    endpoint_name=online_endpoint_name,
    deployment_name="blue",
    request_file="sample-data.json",
)

if response[1]=='1':
    print("Yes")
else:
    print ("No")