azure - 在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'
解决方案
好问题——一开始我也有同样的误解。缺少的部分是模型“注册”和模型“部署”之间存在差异。注册只是为了跟踪和在以后的地点和时间轻松下载。部署是您所追求的,使模型可用于评分。
文档中有一个关于部署的完整部分。我的建议是首先在本地部署它进行测试。
推荐阅读
- c# - Newtonsoft JSON 反序列化适用于本地和实时环境,但不适用于 ASP.NET MVC 应用程序的测试
- node.js - 使用指向其个人资料的链接获取用户的 facebook id
- angular - 如何使用 [(ngModel)] 绑定按钮单击的值
- image - UWP:Gridview 中缓慢的 SVG 图像加载
- javascript - 如何减少 requestAnimationFrame() 方法中的 CPU 使用率
- django - 调度程序会减慢您的 Web 应用程序吗?
- java - 是否有一种轻量级方法可以在 Java 9+ 中添加安全点
- c++ - SHBrowseForFolderA 错误
- python - 为什么`repo init` 会因 GitError 而失败?
- android - 无效的 LOC 标头(错误的签名)