SAS Container Runtime (SCR) allows you to publish a SAS model as a container image in Azure. In this post you will learn how to create a container instance in Azure. Then, how to score the model using a simple curl command.
SAS Container Runtime (SCR, pronounced "soccer") is available since the SAS Viya version 2021.1.3. Azure, as a SAS model publishing destination is available from the same version.
The two minutes video shows you how to create an Azure Container Instance from a SCR image and how to score the SAS model inside, using curl.
The shade highlights the components discussed in this post. (Drawing credits: Deva Kumar).
Select any image to see a larger version.
Mobile users: To view the images, select the "Full" version at the bottom of the page.
The scenario assumes you published a SAS model, with SCR, as a container image, to an Azure Container Registry (ACR). You can read more about the required configuration in How to Publish a SAS Model to Azure with SCR: A Start-to-Finish Guide.
In the Azure Container Registry (ACR), named modelmanager, you can see two repositories, containing SCR images:
When you drill-down into the individual image (model) and tag (version), you will notice the SCR container image can be pulled with a simple docker command.
To score the model inside the image:
In the video, a container instance was created, for the champion model, called qs_tree1. To score the model, you will need these elements:
From a functional perspective, the model is classifying if the home loan application is likely to default, or not. The input data is for a home loan application. You will recognize without doubt, the structure of the famous HMEQ data set. The data section contains one data record, in json format.
To score the model you can write a simple curl command, from a Linux machine. The machine must be able (and allowed) to reach the Azure container instance.
curl --location --request POST 'http://qstree1.eastus.azurecontainer.io:8080/qs_tree1' --header 'Content-Type: application/json' --header 'Accept: application/json' --data ' {
"inputs": [
{ "name": "CLAGE", "value": 94.36666667 },
{ "name": "CLNO", "value": 9 },
{ "name": "DEBTINC", "value": 0 },
{ "name": "DELINQ", "value": 0 },
{ "name": "DEROG", "value": 0 },
{ "name": "JOB", "value": "Other" },
{ "name": "LOAN", "value": 0 },
{ "name": "MORTDUE", "value": 25860 },
{ "name": "NINQ", "value": 1 },
{ "name": "REASON", "value": "HomeImp" },
{ "name": "VALUE", "value": 39025 },
{ "name": "YOJ", "value": 10.5 }
]
} '
To format the json response, you can use jq, a JSON processor. Just add at the end:
| jq
so that you have:
} ' | jq
The response of the model score comes back in .json format.
In plain language, the model determines a 94% probability of no default on this home loan, and assigns I_BAD = 0, the predicted class.
In the Azure portal, you can watch the container activity: every curl request creates a spike. You can look at the container logs, connect and explore the container folders, set alerts and so on.
If you publish a new model version from SAS, you need to redeploy your container instance.
The ACR keeps track of the published versions. The :latest tag is associated with the last version published ( such as 2.0, 3.0, etc.). The number is the model version in SAS Model Manager, from when you published the model to Azure.
All the credits go to my colleague Deva Kumar. Thank you for teaching me how to score a model in Azure.
It is quite easy to create a container instance in Azure, from a SCR container image. Then, you can score the model using a simple curl command.
SAS documentation
Thank you for your time reading this article. If you liked the post, give it a thumbs up. Please comment and tell us what you think about the new SCR and Azure publishing destination.
Find more articles from SAS Global Enablement and Learning here.
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning and boost your career prospects.