Data Science Pilot Action Set

Automated Generation of Features Using the featureMachine Action

This section contains PROC CAS code.

Note: Input data must be accessible in your CAS session, either as a CAS table or as a transient-scope table. A CAS 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 2, Shared Concepts (SAS Viya: Machine Learning Procedures). A transient-scope table is called directly from the action and exists in memory for the duration of the action. For more information about accessing data, see SAS Viya: System Programming Guide. For more information about PROC CAS and programming in CASL, see SAS Cloud Analytic Services: CASL Programmer’s Guide and SAS Cloud Analytic Services: CASL Reference.

The following DATA step creates the reference data table mycas.dmagecr in your CAS session. These statements assume that your CAS engine libref is named mycas, but you can substitute any appropriately defined CAS engine libref.

data mycas.dmagecr;
   set sampsio.dmagecr;
run;

The following statements run the featureMachine action to automatically generate features that alleviate the data-quality issues listed in the transformationPolicy parameter (cardinality, entropy, and so on). The action produces four CAS output tables. The transformation_out table contains metadata about the feature transformation and generation pipelines. The feature_out table contains metadata about the generated features. The cas_out table contains the scored input data table. The astore_out table contains the analytic store scoring object.

proc cas;
   loadactionset "dataSciencePilot";
   dataSciencePilot.featureMachine
                            / table                  = "DMAGECR"
                              target                 = "good_bad"
                              explorationPolicy      = {}
                              screenPolicy           = {}
                              transformationPolicy   = {missing = True,
                                                        cardinality = True,
                                                        entropy = True,
                                                        iqv = True,
                                                        skewness = True,
                                                        kurtosis = True,
                                                        Outlier = True
                                                       }
                              transformationOut      = {name    = "TRANSFORMATION_OUT",
                                                        replace = True}
                              featureOut             = {name    = "FEATURE_OUT",
                                                        replace = True}
                              casOut                 = {name    = "CAS_OUT",
                                                        replace = True}
                              saveState              = {name    = "ASTORE_OUT",
                                                        replace = True}
                              ;
   run;
   fetch / table = "FEATURE_OUT";
   run;
quit;

The table parameter names the input reference data table. The target parameter names the target variable. The explorationPolicy parameter names the data exploration policy; this example uses the default setting. The screenPolicy parameter names the variable screening policy; this example uses the default setting. The transformationPolicy parameter names the feature transformation and generation policy. By selectively switching specific data-quality issues, you can control the amount of feature transformation exploration and generation that is done.

The transformationOut parameter names the transformation CAS output table. The featureOut parameter names the features CAS output table. The casOut parameter names the CAS output table. The saveState parameter names the CAS output table to store the analytic store scoring object.

A sample of the feature transformation and generation table is shown in Output 11.6.1.

Output 11.6.1: Generated Features Sample

Results from table.fetch

Selected Rows from Table FEATURE_OUT
_Index_FeatureIdNameIsNominalFTGPipelineIdNInputsInputVar1InputVar2InputVar3Label
11cpy_int_med_imp_amount081amount  amount: Low missing rate - median imputation
22ho_dtree_disct10_amount171amount  amount: High outlier - ten bin decision tree binning
33ho_dtree_disct5_amount161amount  amount: High outlier - five bin decision tree binning
44ho_quan_disct10_amount151amount  amount: High outlier - robust IQR + ten bin quantile binning
55ho_quan_disct5_amount141amount  amount: High outlier - robust IQR + five bin quantile binning
66ho_winsor_amount031amount  amount: High outlier - winsorize
77cpy_nom_mode_imp_lab_age191age  age: Low missing rate - mode imputation + label transformation
88cpy_nom_mode_imp_lab_checking191checking  checking: Low missing rate - mode imputation + label transformation
99lchehi_lab_checking121checking  checking: Low cardinality, high (entropy, IQV) - label transformation
1010cpy_nom_mode_imp_lab_coapp191coapp  coapp: Low missing rate - mode imputation + label transformation
1111lchehi_lab_coapp121coapp  coapp: Low cardinality, high (entropy, IQV) - label transformation
1212cpy_nom_mode_imp_lab_duration191duration  duration: Low missing rate - mode imputation + label transformation
1313cpy_nom_mode_imp_lab_employed191employed  employed: Low missing rate - mode imputation + label transformation
1414lchehi_lab_employed121employed  employed: Low cardinality, high (entropy, IQV) - label transformation
1515grp_rare1_existcr111existcr  existcr: Very low entropy - group rare
1616cpy_nom_mode_imp_lab_foreign191foreign  foreign: Low missing rate - mode imputation + label transformation
1717cpy_nom_mode_imp_lab_history191history  history: Low missing rate - mode imputation + label transformation
1818lchehi_lab_history121history  history: Low cardinality, high (entropy, IQV) - label transformation
1919cpy_nom_mode_imp_lab_housing191housing  housing: Low missing rate - mode imputation + label transformation
2020lchehi_lab_housing121housing  housing: Low cardinality, high (entropy, IQV) - label transformation


Automated Generation of Features Using the featureMachine Action

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 accessible to the CAS server. 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 statements run the featureMachine action to automatically generate features that alleviate the data-quality issues listed in the transformationPolicy parameter (cardinality, entropy, and so on). The action produces four CAS output tables. The transformation_out table contains metadata about the feature transformation and generation pipelines. The feature_out table contains metadata about the generated features. The cas_out table contains the scored input data table. The astore_out table contains the analytic store scoring object.

s:loadactionset{actionset="dataSciencePilot"}

s:dataSciencePilot_featureMachine {
                              table                  = {name="DMAGECR"},
                              target                 = "good_bad"
                              explorationPolicy      = {},
                              screenPolicy           = {},
                              transformationPolicy   = {missing = True,
                                                        cardinality = True,
                                                        entropy = True,
                                                        iqv = True,
                                                        skewness = True,
                                                        kurtosis = True,
                                                        Outlier = True
                                                       },
                              transformationOut      = {name    = "TRANSFORMATION_OUT",
                                                        replace = True},
                              featureOut             = {name    = "FEATURE_OUT",
                                                        replace = True},
                              casOut                 = {name    = "CAS_OUT",
                                                        replace = True},
                              saveState              = {name    = "ASTORE_OUT",
                                                        replace = True}

}

The table parameter names the input reference data table. The target parameter names the target variable. The explorationPolicy parameter names the data exploration policy; this example uses the default setting. The screenPolicy parameter names the variable screening policy; this example uses the default setting. The transformationPolicy parameter names the feature transformation and generation policy. By selectively switching specific data-quality issues, you can control the amount of feature transformation exploration and generation that is done.

The transformationOut parameter names the transformation CAS output table. The featureOut parameter names the features CAS output table. The casOut parameter names the CAS output table. The saveState parameter names the CAS output table to store the analytic store scoring object.

For example output from the action, see the CASL code examples.

Automated Generation of Features Using the featureMachine Action

This section contains R 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 accessible to the CAS server. 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:

m <- cas.read.csv(s, "dmagecr.csv", casOut=list(name="dmagecr"))

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

The following statements run the featureMachine action to automatically generate features that alleviate the data-quality issues listed in the transformationPolicy parameter (cardinality, entropy, and so on). The action produces four CAS output tables. The transformation_out table contains metadata about the feature transformation and generation pipelines. The feature_out table contains metadata about the generated features. The cas_out table contains the scored input data table. The astore_out table contains the analytic store scoring object.

cas.loadActionSet(s,"dataSciencePilot")

cas.dataSciencePilot.featureMachine(
   s,
   table                 = list(name ="DMAGECR"),
   target                = "good_bad",
   explorationPolicy     = list(),
   screenPolicy          = list(),
   transformationPolicy  = list(missing = True, cardinality = True,
                                entropy = True, iqv = True,
                                skewness = True, kurtosis = True, Outlier = True),
   transformationOut     = list(name= "TRANSFORMATION_OUT", replace = True),
   featureOut            = list(name= "FEATURE_OUT", replace = True),
   casOut                = list(name= "CAS_OUT", replace = True),
   saveState             = list(name= "ASTORE_OUT", replace = True)

)

The table parameter names the input reference data table. The target parameter names the target variable. The explorationPolicy parameter names the data exploration policy; this example uses the default setting. The screenPolicy parameter names the variable screening policy; this example uses the default setting. The transformationPolicy parameter names the feature transformation and generation policy. By selectively switching specific data-quality issues, you can control the amount of feature transformation exploration and generation that is done.

The transformationOut parameter names the transformation CAS output table. The featureOut parameter names the features CAS output table. The casOut parameter names the CAS output table. The saveState parameter names the CAS output table to store the analytic store scoring object.

For example output from the action, see the CASL code examples.

Automated Generation of Features Using the featureMachine Action

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 accessible to the CAS server. 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 statements run the featureMachine action to automatically generate features that alleviate the data-quality issues listed in the transformationPolicy parameter (cardinality, entropy, and so on). The action produces four CAS output tables. The transformation_out table contains metadata about the feature transformation and generation pipelines. The feature_out table contains metadata about the generated features. The cas_out table contains the scored input data table. The astore_out table contains the analytic store scoring object.

s.loadactionset(actionset="dataSciencePilot")
s.dataSciencePilot.featureMachine(
     table                   = {"name" : "DMAGECR"},
     target                  = "good_bad",
     explorationPolicy       = {},
     screenPolicy            = {},
     transformationPolicy    = {"missing":True, "cardinality":True,
                                "entropy":True, "iqv":True,
                                "skewness":True, "kurtosis":True, "Outlier":True},
     transformationOut       = {"name" : "TRANSFORMATION_OUT", "replace" : True},
     featureOut              = {"name" : "FEATURE_OUT", "replace" : True},
     casOut                  = {"name" : "CAS_OUT", "replace" : True},
     saveState               = {"name" : "ASTORE_OUT", "replace" : True}
)

The table parameter names the input reference data table. The target parameter names the target variable. The explorationPolicy parameter names the data exploration policy; this example uses the default setting. The screenPolicy parameter names the variable screening policy; this example uses the default setting. The transformationPolicy parameter names the feature transformation and generation policy. By selectively switching specific data-quality issues, you can control the amount of feature transformation exploration and generation that is done.

The transformationOut parameter names the transformation CAS output table. The featureOut parameter names the features CAS output table. The casOut parameter names the CAS output table. The saveState parameter names the CAS output table to store the analytic store scoring object.

For example output from the action, see the CASL code examples.

Last updated: August 04, 2026