REGISTERMODEL Procedure
Example 31.3 Register an Analytic Store with Prescored Data
This example shows how to use the REGISTERMODEL procedure to register an analytic store model by using prescored data with a partitioning variable for assessment.
The following DATA step creates the data table mylib.hmeq in your CAS session. These statements assume that your CAS engine libref is named mylib, but you can substitute any appropriately defined CAS engine libref. The statements also replace the missing values of the REASON variable with a new value, Unknown.
data mylib.hmeq;
set sampsio.hmeq;
if reason = "" then reason = "Unknown";
run;
The following statements run the PARTITION procedure to create the partitioned data table mylib.hmeq_part. These statements divide the mylib.hmeq data table into three partitions and save the partition index variable _PartInd_ in the mylib.hmeq_part data table.
proc partition
data = mylib.hmeq
samppct = 60
samppct2 = 10
seed = 123
nThreads = 1
partind;
output out = mylib.hmeq_part;
run;
The following statements run the FOREST procedure to build a forest to predict the variable reason, which represents the reason for the mortgage loan application. The procedure uses the partition variable _PartInd_ to indicate the training, validation, and testing partitions. It also outputs an analytic store named mylib.forestStore_hmeq and a scored output table named mylib.scored_hmeq. The target variable and the partition variables are both copied to the scored output table.
proc forest data = mylib.hmeq_part seed = 123;
input loan value mortdue debtinc derog / level = interval;
input job / level = nominal;
target reason / level = nominal;
saveState rstore = mylib.forestStore_hmeq;
partition rolevar = _PartInd_(train = '1' validate = '0' test = '2');
output out = mylib.scored_hmeq copyvars = (reason _PartInd_);
run;
The following statements run the ASTORE procedure to download the analytic store mylib.forestStore_hmeq as a binary file:
proc astore;
download rstore = mylib.forestStore_hmeq
store = "forestAstore.sasast";
run;
The following statements run PROC REGISTERMODEL to register the analytic store model in SAS Model Manager and use the scored output table for assessment:
proc registermodel
name = "Forest Astore"
description = "Forest Astore Model"
data = mylib.scored_hmeq
algorithm = FOREST
function = CLASSIFICATION
replace;
project name="myProject" folder="myFolder";
astoremodel store = "forestAstore.sasast";
target reason / level=nominal event="HomeImp";
assessment partitionvar=_PartInd_(train="1" valid="0" test="2");
run;
The NAME= option specifies the name to register the model under in SAS Model Manager. The DESCRIPTION= option specifies the description of the model. The DATA= option specifies the data table to use for assessment. The ALGORITHM= option specifies that the forest algorithm was used to train the model. The FUNCTION= option specifies that the function of the model is classification. The REPLACE option indicates that you want to replace an existing model if a model that has the same name already exists in the same project.
The PROJECT statement specifies the project to register the model in. The NAME= option specifies the name of the project. The FOLDER= option specifies the folder where the project resides. The ASTOREMODEL statement with the STORE= option specifies the analytic store file to be uploaded to and registered in SAS Model Manager.
The TARGET statement specifies that the reason variable was used as the target variable to train the model. The LEVEL= option specifies that the measurement level of the target variable is NOMINAL. The EVENT= option specifies that the value HomeImp (for “home improvements”) be used as the event level. The ASSESSMENT statement specifies that you want to calculate the assessment statistics and register the assessment information in SAS Model Manager. The PARTITIONVAR= option specifies that the _PartInd_ variable be used as the partition variable in assessment; the variable value of 1 indicates the training partition, 0 indicates the validation partition, and 2 indicates the testing partition.
Output 31.3.1 displays the model registration information.
Output 31.3.1: Model Registration Information
| Registration Information | |
|---|---|
| Creation Time | 2024-02-19T15:54:32-04:00 |
| Model Name | Forest Astore |
| Model ID | 96908bf3-6b9b-44f2-8ad2-a758810fdf97 |
| Project Name | myProject |
| Project ID | 7de86372-654f-4501-a817-2d36a9cb178c |
| Project Version ID | c4a68493-cdd2-41c3-b09f-9ae886a74f45 |
| Folder ID | fd174b10-b616-4b99-af64-e56b1fca6fdf |
| Repository ID | f0e58396-8633-4a92-8004-d07b7676283a |