Analytic Store Scoring Action Set

Example 1.1 Describing an Analytic Store

Describing an Analytic Store

This section contains PROC CAS code.

Note: Input data must be in a CAS table that is accessible in your CAS session. This table has a two-level name; the first level is your CAS engine libref and the second level is the table name. You refer to this table in the CAS procedure by specifying only the second level. For more information about two-level names, see Chapter 3: Shared Concepts in SAS Visual Data Mining and Machine Learning 8.3: Procedures Guide. For more information about PROC CAS and programming in CASL, see Getting Started with CASL, SAS Cloud Analytic Services: CAS Procedure Programming Guide and Reference, and SAS Viya: System Programming Guide.

This example uses the dmagecr data set from the SAS Sample library to illustrate how to describe an analytic store that is created by another SAS Viya action and saved in a data table.

The dmagecr contains 1,000 observations and contains the variables age, amount, and so on.

This example assumes that the analytic store has been created and is visible by the CAS session and that all the necessary input tables are visible so that they can be accessed.

The following DATA step loads the dmagecr data set into a CAS data table named mycas.dmagecr and adds an id variable for each input record of the input table. The id variable is also copied to the output table. It acts as a record identifier and is needed to join the records in the input table to their corresponding records in the output table. These statements assume that the CAS engine libref is named mycas, but you can substitute any appropriately named CAS engine libref.

    data mycas.dmagecr;
       set sampsio.dmagecr;
       id=_n_;
    run;

The following code uses the svmtrain subaction of the svm action set to produce an analytic store. The input table is dmagecr, and the input interval variables checking, coapp, and depend are specified in the var parameter of the action. The target variable telephon is specified in the emtarget parameter. The state of the training is saved in a table named save, as specified in the savestate parameter.

proc cas;
   action svm.svmtrain /
      table={name='dmagecr'},
      var={'checking', 'coapp', 'depends'},
      emtarget={name='telephon', options={order='formatted', leveltype='nominal'}},
      kernel=2,
      degree=2,
      id= {'id'},
      savestate={name='save', replace=true};
run;

The following statements use PROC CAS to load the aStore action set and run the describe action. The ODS TRACE ON statement tracks the ODS tables that the describe action produces.

ods trace on;
proc cas;
   aStore.describe rstore={name='save'}, epcode=TRUE;
   run;
quit;

Output 1.1.1 shows the following tables, which are produced by the preceding code:

  • The "Run Information" table contains the analytic component and the time the state was saved.

  • The "Input Variables" table contains the description of the input variables.

  • The "Output Variables" table contains the description the output variables.

Output 1.1.1: Output Tables from the Describe Action

 

Run Information
  
Analytic Enginesvmachine
Time Created18May2018:12:22:50

Input Variables
NameLengthRoleMeasurement LevelData TypeFormat
checking8InputIntervalNum 
coapp8InputIntervalNum 
depends8InputIntervalNum 
telephon8TargetClassificationNum 
id8Id Num 

Output Variables
NameLengthMeasurement LevelLabel
id8Num 
_P_8NumDecision Function
P_telephon28NumPredicted: telephon=2
P_telephon18NumPredicted: telephon=1
I_telephon32CharInto: telephon
_WARN_4CharWarnings


Every time you re-create the store for the same analytic problem, the Time Created row in the "Run Information" table changes.

Describing an Analytic Store

This section contains Lua code for the analysis in the CASL version of this example, which contains details about the results.

Note: In order to run this code, the data that are described in the CASL version need to be loaded into CAS. One way to do this is to convert the dmagecr data to the comma-separated-value (CSV) file dmagecr.csv and then use the following code to load the CSV file into CAS:

   s:loadtable{casLib="casuser", path="dmagecr.csv"}

For more information about coding in Lua, see Getting Started with SAS Viya for Lua and SAS Viya: System Programming Guide.

The following code describes the analytic store in the table mycas.save. You can print all the tables that the describe action produces.

s:loadactionset{actionset='aStore'}
r = s:describe{
     rstore={name='save'},
     epcode=true
}
print(r.epcode)
print(r.Description)
print(r.InputVariables)
print(r.OutputVariables)

The output of the print command is not shown here.

Describing an Analytic Store

This section contains Python code for the analysis in the CASL version of this example, which contains details about the results.

Note: In order to run this code, the data that are described in the CASL version need to be loaded into CAS. One way to do this is to convert the dmagecr data to the comma-separated-value (CSV) file dmagecr.csv and then use the following code to load the CSV file into CAS:

   s.upload_file('dmagecr.csv')
  

For more information about coding in Python, see Getting Started with SAS Viya for Python and SAS Viya: System Programming Guide.

The following code describes the analytic store in the table mycas.save. You can print all the tables that the describe action produces.

s.loadactionset('aStore')
m=s.describe(
     rstore='SAVE',
     epcode=True
    )
print(m.Description)
print(m.InputVariables)
print(m.OutputVariables)
print(m.epcode)

The output of the print function is not shown here.

Describing an Analytic Store

The following code describes the analytic store in the table mycas.save. You can print all the tables that the describe action produces.

  loadActionSet(s, "aStore")
  results <- cas.aStore.describe(s, rstore="save", epcode=TRUE)
  print(results$Description)
  print(results$InputVariables)
  print(results$OutputVariables)
  print(results$epcode)

The output of the print function is not shown here.

Last updated: June 07, 2018