BookmarkSubscribeRSS Feed

Publish and Run a Model In-Database From the User Interface – A Teradata Example

Started ‎02-07-2022 by
Modified ‎02-07-2022 by
Views 2,545

Following up my introductory article about publishing and running a model in-database, I wanted to illustrate this process from different perspectives. The first scenario was about using code. In this second scenario, we will put ourselves in the position of the person who designs models using SAS Viya User Interfaces like SAS Model Studio and SAS Model Manager or designs rule sets/decisions in SAS Intelligent Decisioning.  

 

Prerequisites

 

Before a Data Scientist can easily publish SAS models or decisions in Teradata using SAS Model Studio, SAS Model Manager or SAS Intelligent Decisioning, there is one step that a SAS administrator will have to do first: creating the appropriate Publishing Destination for Teradata.

 

This is done in SAS Environment Manager => Publishing Destinations.

 

nir_post_71_01_create_publishing_destination.png

Select any image to see a larger version.
Mobile users: To view the images, select the "Full" version at the bottom of the page.

 

It’s a simple step where the administrator will specify a name for the destination, a Teradata CASLIB with write capabilities, and the model table: a table in Teradata that will act as a repository of models (the first time, it will be created in the referenced CASLIB).  

 

Design a model

 

This is the part that is done in SAS Model Studio instead of SAS Code (my previous article). I won’t learn you how to do that, there’s a good probability that you know better than me on this topic. Let’s assume we have a pipeline designed in SAS Model Studio and we want to publish the champion model in Teradata.

 

Here is a very simple pipeline example with 2 models:

 

nir_post_71_02_model_studio.png

 

 

Design a rule set or decision

 

If instead of a model, we want to publish a decision (a rule set can also be published) then let’s assume we have an existing decision ready to go.

 

Here is a very simple decision relying on 3 rule sets:

 

nir_post_71_03_intelligent_decisioning.png

 

 

Publish the model in Teradata from SAS Model Studio

 

Now that we have a pipeline in SAS Model Studio, we are now able to publish models in the Teradata publishing destination, created earlier. In the “Pipeline Comparison” tab, you can select a model and click on “Publish models” as shown below:

 

nir_post_71_04_model_studio_publish.png

 

Then we specify how we want to publish:

 

  • The model name in Teradata
  • If you want to replace it in case the same name already exists
  • Which destination (here the Teradata published destination)

 

nir_post_71_05_model_studio_publish_dialog.png

 

 

Publish the model in Teradata from SAS Model Manager

 

If instead of directly publishing from SAS Model Studio, you or your users manage numerous models, you might use SAS Model Manager. Of course, publishing models is also possible from this application:

 

nir_post_71_06_model_manager_publish.png

 

You get a similar dialog box:

 

nir_post_71_07_model_manager_publish_dialog.png

 

Publish the rule set/decision in Teradata from SAS Intelligent Decisioning

 

Finally, if you want to run decisions or rule sets in a publishing destination, SAS Intelligent Decisioning also offers you a way to easily publish them:

 

nir_post_71_08_decisioning_publish.png

 

 

Decisions can be published in Teradata for example only if they contain objects that are supported for the destination. Rule sets, lookup tables, models from SAS Model Manager, etc. are supported for in-database destinations. Some components like Python code files, data query files or MAS modules are not supported. This is documented here.

 

This time, you will get asked if you want to add some runtime tracking information to the decision. Then when you run the decision in the database, additional metadata are written to the output table.

 

nir_post_71_09_decisioning_publish_dialog.png

 

Run the model/decision/rule set in Teradata

 

So far, we have seen that multiple SAS applications provide a way to publish models or decisions interactively and easily.

 

When it comes to the execution of the model or decision, the only way to do it is programmatically. So everything mentioned in my previous article (Publish and Run a Model In-Database From Code – A Teradata Example – “Run the model in Teradata” section) will still apply here.

 

As stated in this previous article, to run a model in Teradata from SAS, we use the SCOREACCEL procedure (and the runmodel statement) or the modelPublishing.runModelExternal CAS action (the SCOREACCEL runmodel statement calls this CAS action behind the scenes):

 

 

proc scoreaccel sessref=mysession ;
   runmodel
      target=teradata
      caslib="tera"
      modelname="mymodel"
      modeltable="sas_model_table"
      intable="hmeq_prod"
      outtable="hmeq_prod_code_scored"
      outkey="RECORD_PK"
      ;
quit ;

 

In the modelname property, you specify the name of the model/rule set/decision that you want to run in Teradata.  

 

Conclusion

 

In this article, we have illustrated how a SAS user can design a model or decision and publish it in Teradata from a user interface perspective.

 

I also have a YouTube on this topic:

 

 

Thanks for reading.

 

Find more articles from SAS Global Enablement and Learning here.

Version history
Last update:
‎02-07-2022 03:03 PM
Updated by:
Contributors

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Free course: Data Literacy Essentials

Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning  and boost your career prospects.

Get Started