Saving an sklearn model to blob storage from AzureML
Simply put, I have a sklearn model in Azure ML. I want to write the model to a specific blob storage container to save it. I've already authenticated the connection to the right blob container. Per docs :
# Create a blob client using the local file name as the name for the blob
blob_client = blob_service_client.get_blob_client(container=container_name, blob=file_name)
# Upload the created file
with open(file=upload_file_path, mode="rb") as data:
blob_client.upload_blob(data)
However, this requires me to first save the model to a local file. Is there a local file store associated with AzureML?
Alternatively, could I write back to a datastore but point the datastore to a specific storage container?
First, save your model in local as below.
Here,
os.path.abspath('credit_defaults_model')gives path to local filesystem. There you can save the model executing above ml code.Then you will get files highlighted in image.
Later, you upload the
model.pklfile to blob storage.Output:
Here, model is uploaded successfully to blob.