In my recent blog I focused on the process to deploy models with SAS Model Manager to Hadoop. I mentioned that deploying is a key step for any data scientist and SAS Model Manager assists in bringing the models into production processes. While publishing to Hadoop is an example for batch processing, I would like to focus now on an example where we deploy with real-time scoring execution as the end-goal. One way to do this is by publishing a model to the SAS Micro Analytic Score Service. And just as in my blog where I was publishing to Hadoop, SAS Model Manager can help with that.
But what is SAS Micro Analytics Score Service? SAS Micro Analytic Service or MAS is a memory-resident, high-performance program execution service. As a SAS platform service, it is not available for individual license, but is included in selected SAS solutions (SAS Event Stream Processing, SAS Decision Manager and SAS Model Manager).
Let’s see how MAS works with SAS Model Manager. When SAS Model Manager is installed, a publishing destination for SAS Micro Analytic Service is created automatically -- it’s named “maslocal.” So users can publish models to this SAS Micro Analytic Service publishing destination.
Let’s publish the Interactive_Forest that I was publishing in my blog to Hadoop now to MAS. For that you can open the model in SAS Model manager. We know that the model is in SAS Model Manager because we see in SAS Model Studio that it has been registered in SAS Model Manager:
After opening the model in SAS Model Manager and before starting to publish to a MAS destination, it’s best to validate the score code type of your model. That score code type can be found on the properties tab when opening the model details in SAS Model Manager.
Models with a score code type of DATA step, DS2 package, or DS2 multi-type can be published to the SAS Micro Analytic Service.
When the model that needs to be published is an analytic store, there’s some extra configuration required. This is because the compute service will extract the analytic store (ASTORE) from the analytic store’s CAS table. This table is located in the ModelStore caslib and the compute service copies the ASTORE to the /opt/sas/viya/config/data/modelsvr/astore directory. Each server that hosts the SAS MAS service must have access to a /models/astores/viya file system path which maps to the /opt/sas/viya/config/data/modelsvr/astore directory.
Details for the above remark can be found here.
It should look like this:
Once the conditions are fulfilled, we can publish the selected model:
For some more information around ASTORE and Viya 3.3 have a look here .
With SAS Viya 3.4, there are even more procedures that can create ASTORE models:
After a successful publishing of the model you should see the following:
As mentioned before (and documented in this blog) I published the same model to Hadoop. So the same model is now published to two different target destinations.
After publishing the model to the SAS Micro Analytical Service, we can now call this model via REST API’s from other solutions.
Next step is to consume this model via SAS Viya REST APIs. The API’s are based on resource-oriented URLs. The SAS Viya REST APIs are grouped for convenience into a number of API categories. For now we want to list and execute the MAS deployed models.
The API’s we need for that are coming from the Decision Management group. The documentation can be found on developer.sas.com:
Important note: before start using REST APIs you need to:
Configure your SAS Environment for API Use:
Understand Authentication and Access tokens: a client application that needs to make a REST API request must first be authenticated and obtain an access token. That token is then used on subsequent requests.
Info around this can be found here.
For instance, to retrieve the collection of published MAS modules we can use:
When doing this request with Postman it looks like this:
Hint: Domain and token are variables you can store within a Postman environment.
Hint: under tests one can write output to Postman console which is sometimes easier to read then the JSON output.
Having the id of the module allows us to find the steps of the scoring module:
From the response, we filter out the input variables which we will use in the scoring step.
From the response we learn as well that one of the steps is a score step:
Now we have all information to do the scoring of some input variables:
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.