Hi folks,
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!!
Tim
Hi @TimStettner,
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
Logging
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.
Database
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..
Best, David
Hello,
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
https://communities.sas.com/t5/SAS-Communities-Library/Scoring-using-Models-Deployed-into-MAS-over-R...
Maybe @SophiaRowland or @Roel can help you out.
BR,
Koen
Hi @TimStettner!
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
Hi @TimStettner,
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
Logging
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.
Database
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..
Best, David
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!