首页 > 解决方案 > 在azure模型注册后如何进行预测?

问题描述

我创建了一个简单的模型,然后在 azure 中注册。我怎样才能做出预测?

from sklearn import svm
import joblib
import numpy as np

# customer ages
X_train = np.array([50, 17, 35, 23, 28, 40, 31, 29, 19, 62])
X_train = X_train.reshape(-1, 1)
# churn y/n
y_train = ["yes", "no", "no", "no", "yes", "yes", "yes", "no", "no", "yes"]

clf = svm.SVC(gamma=0.001, C=100.)
clf.fit(X_train, y_train)

joblib.dump(value=clf, filename="churn-model.pkl")

登记:

from azureml.core import Workspace
ws = Workspace.get(name="myworkspace", subscription_id='My_subscription_id', resource_group='ML_Lingaro')

from azureml.core.model import Model
model = Model.register(workspace=ws, model_path="churn-model.pkl", model_name="churn-model-test")

预言:

from azureml.core.model import Model
import os

model = Model(workspace=ws, name="churn-model-test")
X_test = np.array([50, 17, 35, 23, 28, 40, 31, 29, 19, 62])
model.predict(X_test) ???? 

错误:AttributeError: 'Model' object has no attribute 'predict'

标签: azureazure-machine-learning-service

解决方案


好问题——一开始我也有同样的误解。缺少的部分是模型“注册”和模型“部署”之间存在差异。注册只是为了跟踪和在以后的地点和时间轻松下载。部署是您所追求的,使模型可用于评分。

文档中有一个关于部署的完整部分。我的建议是首先在本地部署它进行测试。


推荐阅读