question

vishalcv-5036 avatar image
0 Votes"
vishalcv-5036 asked vishalcv-5036 commented

How to use a registred model in a python script(in Azure) ?

I used Azure AutoML service to test various models and after choosing the best one I registered it in my workspace.

Process done for registering:
1. I downloaded the model(a zipped folder containing 3 files) into my laptop
2. Unzipped the folder in my laptop
3. Uploaded the unzipped folder(containing the score, environment yml and pkl file ) in the Azure "Models" pane and registered a model under the name "lgbm"

What I want to achieve:
I want to use the registered model to make some predictions on a "validation" Dataset I have in Azure(already registered) and check out the accuracy metrics once again.

Steps done:
1. Registered the validation dataset in Azure properly
2. Started the Azure VM and Opened a new notebook
3. Got the validation data into the script

Where I got stuck :
Unable to get the registered model into my script and make predictions:

Code:

import azureml.core
from azureml.core import Workspace

Load the workspace from the saved config file

ws = Workspace.from_config()
print('Ready to use Azure ML {} to work with {}'.format(azureml.core.VERSION, ws.name))

from azureml.core import Dataset
import glob
tab_data_set = Dataset.Tabular.from_delimited_files(path=(default_ds, 'UI/07-11-2021_055454_UTC/test_pred.csv'))
tab_data_set = tab_data_set.to_pandas_dataframe()

model_path = Model.get_model_path('lgbm')
model = joblib.load(model_path)


Error
ModelNotFoundException: ModelNotFoundException:
Message: Model lgbm not found in cache at azureml-models or in current working directory /mnt/batch/tasks/shared/LS_root/mounts/clusters/azuremlvm201/code/Users/vishal_c_v. For more info, set logging level to DEBUG.
InnerException None
ErrorResponse
{
"error": {
"message": "Model lgbm not found in cache at azureml-models or in current working directory /mnt/batch/tasks/shared/LS_root/mounts/clusters/azuremlvm201/code/Users/vishal_c_v. For more info, set logging level to DEBUG."
}
}


















azure-machine-learning
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

ramr-msft avatar image
1 Vote"
ramr-msft answered

@vishalcv-5036 Thanks for the question. Can you check the get_details() and see the model name. You don't register a model by creating a Model object. To register a model from a an AutoML run, you can:

model = run.register_model(description = description, iteration = iteration_id)

If you don't provide the iteration id (aka child run), then the model with the best metric will be registered.

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@ramr-msft
Thank you.

I had made the model via the Auto ML UI. According to the documentation the best model should be automatically registered but that is not the case here as I dont see it in the "Models" pane.

Please correct me if Im wrong, I might even be missing something.

1 Vote 1 ·

@vishalcv-5036 Thanks for the details. You can deploy the best model, Please follow the document for the same.


0 Votes 0 ·
ramr-msft avatar image
0 Votes"
ramr-msft answered vishalcv-5036 commented

@vishalcv-5036 Thanks for the details, AutoML does not automatically register models at this time. You can register manually via SDK or UI via the "Deploy" button (which registers and deploys the model).

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@ramr-msft
Thank you very much for the clarification.

1 Vote 1 ·

@vishalcv-5036 Thanks, If the suggested response helped, do click on "Mark as Answer" and "Up-Vote" for the answer that helped you for benefit of the community.

0 Votes 0 ·