模型部署在Azure机器学习中失败
I am following the procedure as described
import pandas as pd
import sklearn
from sklearn.svm import SVC
import pickle
import joblib
from sklearn.model_selection import train_test_split
dataset = pd.read_csv("https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data", header = None, names= colnames )
dataset = dataset.replace({"class": {"Iris-setosa":1,"Iris-versicolor":2, "Iris-virginica":3}})
X = dataset.drop(['class'], axis=1)[:,0]
y = dataset['class']
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.25, random_state = 0)
classifier = SVC(kernel = 'linear', random_state = 0)
#Fit the model on training data
classifier.fit(X_train, y_train)
#Make the prediction
y_pred = classifier.predict(X_test)
## Save as a pickle file
filename= 'final_mod_v1.pkl'
joblib.dump(classifier,open(filename, 'wb'))
在“模型”选项卡中,我注册了该模型。然后,我尝试将模型部署为Web服务。以下是评分脚本文件。
import json
import numpy as np
import os
import pickle
import joblib
from sklearn.svm import SVC
from azureml.core import Model
def init():
global model
model_name = 'classifier'
path = Model.get_model_path(model_name)
model = joblib.load(path)
def run(data):
try:
data = json.loads(data)
result = model.predict(data['data'])
return {'data' : result.tolist() , 'message' : "Successfully classified Iris"}
except Exception as e:
error = str(e)
return {'data' : error , 'message' : 'Failed to classify iris'}
以下是 conda_depentencies.yml :
channels:
- anaconda
- conda-forge
dependencies:
- python=3.6.2
- pip:
- pandas==1.1.5
- azureml-defaults
- joblib==0.17.0
- scikit-learn==0.23.2
name: azureml_2d0fd20031db3baaed8684d5f08fe619
我对上面脚本中的最后一行感到困惑azureml_2d0fd20031db31db3baaed8684d5f08fe619
name: azureml_2d0fd20031db3baaed8684d5f08fe619
部署部署失败了。部署日志显示:
container "classifier" in pod "wk-caas-9a4c565844b043cfa9d8ba246af11ff5-517e6d8f74175a01ffc43147e5dd8133-pod" is waiting to start: PodInitializing
如果我能为此获得指导,这将有所帮助。
I am following the procedure as described here.
I am trying to register models and deploy them in Azure machine learning. I have the following script:
import pandas as pd
import sklearn
from sklearn.svm import SVC
import pickle
import joblib
from sklearn.model_selection import train_test_split
dataset = pd.read_csv("https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data", header = None, names= colnames )
dataset = dataset.replace({"class": {"Iris-setosa":1,"Iris-versicolor":2, "Iris-virginica":3}})
X = dataset.drop(['class'], axis=1)[:,0]
y = dataset['class']
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.25, random_state = 0)
classifier = SVC(kernel = 'linear', random_state = 0)
#Fit the model on training data
classifier.fit(X_train, y_train)
#Make the prediction
y_pred = classifier.predict(X_test)
## Save as a pickle file
filename= 'final_mod_v1.pkl'
joblib.dump(classifier,open(filename, 'wb'))
In the models tab I registered the model. Then I tried to deploy the model as web service. The following is the scoring script file.
import json
import numpy as np
import os
import pickle
import joblib
from sklearn.svm import SVC
from azureml.core import Model
def init():
global model
model_name = 'classifier'
path = Model.get_model_path(model_name)
model = joblib.load(path)
def run(data):
try:
data = json.loads(data)
result = model.predict(data['data'])
return {'data' : result.tolist() , 'message' : "Successfully classified Iris"}
except Exception as e:
error = str(e)
return {'data' : error , 'message' : 'Failed to classify iris'}
The following is the conda_dependencies.yml:
channels:
- anaconda
- conda-forge
dependencies:
- python=3.6.2
- pip:
- pandas==1.1.5
- azureml-defaults
- joblib==0.17.0
- scikit-learn==0.23.2
name: azureml_2d0fd20031db3baaed8684d5f08fe619
I am confused about the last line in the above script azureml_2d0fd20031db3baaed8684d5f08fe619
name: azureml_2d0fd20031db3baaed8684d5f08fe619
The deployment is failing. Deployment log shows:
container "classifier" in pod "wk-caas-9a4c565844b043cfa9d8ba246af11ff5-517e6d8f74175a01ffc43147e5dd8133-pod" is waiting to start: PodInitializing
It would be helpful if I can get a guidance on this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论