in a "real-time"-scoring scenario for a predictive model we want to use MAS as publishing destination for this model.
The scoring should then be called via the microanalyticScore API, and here the generated endpoint/step "score".
So far, so good.
I'm now struggeling a bit with an additional requirement:
We also want to collect the input/output data from this scoring "somewhere" in SAS (as file, table, in CAS, or however).
Is there any option to add this as a step in the MAS module? Or could we add this in the DS2 score code within Model Manager?
Hope there is any idea how we could solve that.
Thanks in advance!!
Are you using SAS Intelligent Decisioning (ID) or not?
Have you read this SAS Communities Library Article?
Home > SAS Communities Library >
Scoring using Models Deployed into MAS over REST API: A Step-by-Step Guide
Started 06-05-2023 | Modified 06-05-2023
I would recommend against adding a step within the model code to write out the results as this could increase the time it takes for the model to execute. Instead, there is an archive feature in MAS to record the inputs and outputs of REST API calls. To use the archive feature, SAS Micro Analytic Service must be configured with a persistent volume to use as a location in which to store the log files. This link to the documentation explains more: https://go.documentation.sas.com/doc/en/mascdc/v_027/masag/n0yfb6f53gngamn1tn7k0a5c60i6.htm
My answer will focus on two main ways of doing this and I will also augment the answers to include the SAS Container Runtime (SCR) as one possibility that is available in addition to MAS in SAS Viya 4:
1. Making use of the Logging, this builds on top of what @SophiaRowland as already mentioned
2. Writing to a database
The logging of both MAS and SCR are a great way of enabling your use case because they require only a one time setup by the admin. Also logging is extremely fast and thus as a minimal performance impact for the scoring. Making use of the archival function for MAS mentioned by @SophiaRowland is a great way of doing it (https://go.documentation.sas.com/doc/en/mascdc/default/masag/n0yfb6f53gngamn1tn7k0a5c60i6.htm), or of course you can make use of the base MAS logs, but it would require capturing them and parsing them (https://go.documentation.sas.com/doc/en/mascdc/default/masag/n1bpmaoscsf0rnn0z1dz3i6n0k4a.htm). In SCR it can be set via the option SAS_SCR_LOG_LEVEL_SCR_IO (https://go.documentation.sas.com/doc/en/mascrtcdc/default/mascrtag/p1syrp759enejnn1s6jvuw1ia9c5.htm?...) for the logs and then parsing needs to be applied.
Capturing the In/Outputs and writing them to a database is a bit more tricky. First this introduces a bigger performance penalty then logging, even with concepts like connection pooling etc., you might it time outs, have to do retries, etc.. Also note that MAS currently only supports a subset of the SAS Viya supported databases (https://go.documentation.sas.com/doc/en/mascdc/default/masag/n1f863xqncrgajn15lz2xl7ffk1h.htm), same applies for SCR (https://go.documentation.sas.com/doc/en/mascrtcdc/default/mascrtag/n15q5afwsfkjl5n1cfvcn7xz4x22.htm). The next thing is of course what you already touched on namely that if we are talking just a model it would require changing the Score Code of your model to include the database connect and write, which would be a manual step and similar to @SophiaRowland I would also advise against going that route. As @sbxkoenk mentions if using SAS Intelligent Decisioning is an option, this would open two additional ways of doing it by adding a node after the model in the decision - either making use of a Custom DS2 code or making use of the Record Contacts node (https://go.documentation.sas.com/doc/en/edmcdc/default/edmug/n10hwvizrf0fbgn1mdhwahnwfavz.htm?reques...).
In any way the Database approach would also require to be reimplemented for each new model/decision.
So with all of that out of the way, I want to quickly mention that of course the calling application could also save the In/Outputs but that would be a decentralized effort and require contact with different users.
The logging based approach to me as the most upside, while requiring little configuration and on going effort and also opening the avenue to potentially use other logging modules to track module performance, etc..
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.