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
| Selected Rows from Table FEATURE_OUT | |||||||||
|---|---|---|---|---|---|---|---|---|---|
| _Index_ | FeatureId | Name | IsNominal | FTGPipelineId | NInputs | InputVar1 | InputVar2 | InputVar3 | Label |
| 1 | 1 | cpy_int_med_imp_amount | 0 | 8 | 1 | amount | amount: Low missing rate - median imputation | ||
| 2 | 2 | ho_dtree_disct10_amount | 1 | 7 | 1 | amount | amount: High outlier - ten bin decision tree binning | ||
| 3 | 3 | ho_dtree_disct5_amount | 1 | 6 | 1 | amount | amount: High outlier - five bin decision tree binning | ||
| 4 | 4 | ho_quan_disct10_amount | 1 | 5 | 1 | amount | amount: High outlier - robust IQR + ten bin quantile binning | ||
| 5 | 5 | ho_quan_disct5_amount | 1 | 4 | 1 | amount | amount: High outlier - robust IQR + five bin quantile binning | ||
| 6 | 6 | ho_winsor_amount | 0 | 3 | 1 | amount | amount: High outlier - winsorize | ||
| 7 | 7 | cpy_nom_mode_imp_lab_age | 1 | 9 | 1 | age | age: Low missing rate - mode imputation + label transformation | ||
| 8 | 8 | cpy_nom_mode_imp_lab_checking | 1 | 9 | 1 | checking | checking: Low missing rate - mode imputation + label transformation | ||
| 9 | 9 | lchehi_lab_checking | 1 | 2 | 1 | checking | checking: Low cardinality, high (entropy, IQV) - label transformation | ||
| 10 | 10 | cpy_nom_mode_imp_lab_coapp | 1 | 9 | 1 | coapp | coapp: Low missing rate - mode imputation + label transformation | ||
| 11 | 11 | lchehi_lab_coapp | 1 | 2 | 1 | coapp | coapp: Low cardinality, high (entropy, IQV) - label transformation | ||
| 12 | 12 | cpy_nom_mode_imp_lab_duration | 1 | 9 | 1 | duration | duration: Low missing rate - mode imputation + label transformation | ||
| 13 | 13 | cpy_nom_mode_imp_lab_employed | 1 | 9 | 1 | employed | employed: Low missing rate - mode imputation + label transformation | ||
| 14 | 14 | lchehi_lab_employed | 1 | 2 | 1 | employed | employed: Low cardinality, high (entropy, IQV) - label transformation | ||
| 15 | 15 | grp_rare1_existcr | 1 | 1 | 1 | existcr | existcr: Very low entropy - group rare | ||
| 16 | 16 | cpy_nom_mode_imp_lab_foreign | 1 | 9 | 1 | foreign | foreign: Low missing rate - mode imputation + label transformation | ||
| 17 | 17 | cpy_nom_mode_imp_lab_history | 1 | 9 | 1 | history | history: Low missing rate - mode imputation + label transformation | ||
| 18 | 18 | lchehi_lab_history | 1 | 2 | 1 | history | history: Low cardinality, high (entropy, IQV) - label transformation | ||
| 19 | 19 | cpy_nom_mode_imp_lab_housing | 1 | 9 | 1 | housing | housing: Low missing rate - mode imputation + label transformation | ||
| 20 | 20 | lchehi_lab_housing | 1 | 2 | 1 | housing | 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.