我有一个 sklearn k-means 模型。我正在训练模型并将其保存在 pickle 文件中,以便稍后可以使用 azure ml 库进行部署。我正在训练的模型使用名为MultiColumnLabelEncoder 的自定义特征编码器。管道模型定义如下:
# Pipeline
kmeans = KMeans(n_clusters=3, random_state=0)
pipe = Pipeline([
("encoder", MultiColumnLabelEncoder()),
('k-means', kmeans),
])
#Training the pipeline
model = pipe.fit(visitors_df)
prediction = model.predict(visitors_df)
#save the model in pickle/joblib format
filename = 'k_means_model.pkl'
joblib.dump(model, filename)
Run Code Online (Sandbox Code Playgroud)
模型保存效果很好。部署步骤与此链接中的步骤相同:
但是部署总是失败并出现以下错误:
File "/var/azureml-server/create_app.py", line 3, in <module>
from app import main
File "/var/azureml-server/app.py", line 27, in <module>
import main as user_main
File "/var/azureml-app/main.py", line 19, in <module>
driver_module_spec.loader.exec_module(driver_module)
File "/structure/azureml-app/score.py", line 22, …Run Code Online (Sandbox Code Playgroud)