Register model in Azure Machine Learning
Register your model in Azure Machine Learning along with additional files needed for scoring
Uploading additional files with your trained model
Often users want to register their machine learning model along with additional files needed for scoring in Azure Machine Learning, and not just a single pickled model file. There are two common ways to do this, you can either do this from an experiment you have run or directly from a local set of files on your machine. This example explains the latter.
Code example for registering additional files
In this example all the files we want to be registered are saved within the 'outputs' folder, and these files will be registered together in the Azure Machine Learning workspace that we have already created.
from azureml.core import Workspace, Model
import pickle
#Define the name of the model as will be seen in Azure Machine Learning
model_name = 'my-model'
#Define the local folder which contains the files to register
model_path = 'outputs'
#Define the location of the machine learning workspace
subscription_id = 'subscription-id'
resource_group = 'resource-group'
workspace_name = 'my-workspace'
#An earlier created model and pandas dataframe you want to
#register together, saved to the same folder
pickle.dump(model, model_path + '/model.pkl', 'wb'))
dataframe.to_csv(model_path + '/dataframe.csv')
#Connect to your workspace
ws = Workspace(subscription_id = subscription_id,
resource_group = resource_group,
workspace_name = workspace_name)
Model.register(workspace = ws,
model_path = model_path,
model_name = model_name,
description = "My model with associated files")
Related articles
Deploy a machine learning model to ACI in Azure Machine Learning
Run an experiment in Azure Machine Learning
Schedule pipelines and experiments in Azure Machine Learning