Save trained model from AutoML/Designer as pickle file to disk - Azure ML in current version 2023?

Ishwar Sukheja 5 Reputation points
2023-02-20T15:37:54.0466667+00:00

Hi,

Save trained model from AutoML/Designer as pickle file to disk - Azure ML in current version 2023?

Currently, the model is saved as ilearner model. How can I save my model to .pkl file.

Thanks,

Ishwar Sukheja

Azure Machine Learning
Azure Machine Learning
An Azure machine learning service for building and deploying models.
3,343 questions
0 comments No comments
{count} vote

1 answer

Sort by: Most helpful
  1. Ramr-msft 17,826 Reputation points
    2023-02-22T14:14:42.4033333+00:00

    @Ishwar Sukheja Thanks, To save a trained model from AutoML/Designer as a pickle file to disk in Azure ML, you can use the following code:

    import pickle
     
    filename = 'model.pkl'
    pickle.dump(model, open(filename, 'wb'))
    
    

    In this code, model is the trained model that you want to save, and filename is the name of the pickle file that you want to save the model to. The wb argument in the open function specifies that the file should be opened in write binary mode.

    Once you have saved the model to disk, you can load it back into memory using the following code:

    # Load the model from disk
    loaded_model = pickle.load(open(filename, 'rb'))
    

    In this code, filename is the name of the pickle file that you saved the model to, and loaded_model is the variable that will contain the loaded model. The rb argument in the open function specifies that the file should be opened in read binary mode.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.