I used Azure AI Automated ML to create a classification model, and then deployed an Endpoint from that model. The endpoint gets me back the predicted value, but not the probability. Is there an easy way to add the probability to the output of the endpoint?
I've seen a couple of similar questions, either without answers, or with answers that don't seem to directly apply in this scenario.
You need to use the extra global parameter called
predict_probain the method field of your input body when invoking the endpoint.Example:
If your endpoint accepts only
input_dataas a parameter, then you need to create your endpoint using a custom scoring script.First, register your best model and download the artifacts. You can refer to this notebook to download artifacts of the best run and register it.
azureml-examples/sdk/python/jobs/automl-standalone-jobs/automl-classification-task-bankmarketing/automl-classification-task-bankmarketing.ipynb at main · Azure/azureml-examples · GitHub
Then, when you download the artifacts, you can see the scoring scripts like shown in below image.
Download any one of the scoring files into your local system because this file contains the script which accepts the global parameters. It is not necessary to use the same script; you can develop your script according to your needs. Below is a sample code chunk where it checks for
predictorpredict_proba.Next, go to the model tab where you registered the model and deploy it as a real-time endpoint.
Then you will get a screen like below. Click on more options to upload the downloaded scoring script.
Then, enter the endpoint name, compute type as managed, and Authentication type as Key-based authentication.
In Code + environment, turn on Customize environment and scoring script options. Upload the downloaded script and select the required environment.
After configuring all the settings, deploy it.
Now you can test the deployment with the
predict_probaparameter and get results.Code:
You also refer below documentation on how to deploy auto ml models.
Deploy an AutoML model with an online endpoint - Azure Machine Learning | Microsoft Learn
Output:
Default
Giving
predict_proba