The annCode action generates SAS DATA step scoring code from a trained artificial neural network model. This allows for the deployment of the model outside of the CAS environment, enabling scoring of new data in traditional SAS environments. The generated code can be saved to a CAS table for further use.
| Parameter | Description |
|---|---|
| code | Requests that the action produce SAS score code. This parameter allows specifying output options for the generated code, such as the destination table. |
| listNode | Specifies which nodes (ALL, HIDDEN, INPUT, OUTPUT) to include in the scored output table. This is particularly useful for autoencoding to reduce input dimensions. |
| modelId | Specifies a model ID variable name to be included in the generated DATA step scoring code. By default, this is prefixed with 'ANN_' followed by the target variable name. |
| modelTable | Specifies the input table that contains the trained artificial neural network model to be used for generating the scoring code. |
This example creates a sample dataset named 'sample_data' with several input variables and a target variable, suitable for training a neural network model.
| 1 | DATA casuser.sample_data; |
| 2 | DO i = 1 to 100; |
| 3 | input1 = rand('UNIFORM'); |
| 4 | input2 = rand('UNIFORM') * 2; |
| 5 | input3 = rand('NORMAL', 0, 1); |
| 6 | target = (input1 + input2 > 2) + rand('NORMAL')*0.1; |
| 7 | OUTPUT; |
| 8 | END; |
| 9 | RUN; |
This example first trains a simple neural network model using the `annTrain` action and stores it in a table named 'my_model'. Then, it uses the `annCode` action to generate the corresponding SAS DATA step scoring code.
| 1 | PROC CAS; |
| 2 | neuralNet.annTrain / |
| 3 | TABLE={name='sample_data'}, |
| 4 | inputs={{name='input1'}, {name='input2'}, {name='input3'}}, |
| 5 | target='target', |
| 6 | casOut={name='my_model', replace=true}; |
| 7 | neuralNet.annCode / |
| 8 | modelTable={name='my_model'}, |
| 9 | code={casOut={name='my_score_code', replace=true}}; |
| 10 | RUN; |
This example demonstrates a more detailed workflow. First, a neural network is trained with a specific architecture (one hidden layer with 5 neurons). The trained model is saved to 'my_detailed_model'. Then, `annCode` is used to generate scoring code with a custom model identifier ('MyFirstANN') and saves the code into the 'my_detailed_score_code' CAS table.
| 1 | PROC CAS; |
| 2 | neuralNet.annTrain / |
| 3 | TABLE={name='sample_data'}, |
| 4 | inputs={{name='input1'}, {name='input2'}, {name='input3'}}, |
| 5 | target='target', |
| 6 | arch='NEURAL', |
| 7 | hidden={{n=5, act='TANH'}}, |
| 8 | casOut={name='my_detailed_model', replace=true}; |
| 9 | neuralNet.annCode / |
| 10 | modelTable={name='my_detailed_model'}, |
| 11 | modelId='MyFirstANN', |
| 12 | code={casOut={name='my_detailed_score_code', replace=true}}; |
| 13 | RUN; |
A telecom company has trained a neural network to predict customer churn. They need to generate SAS DATA step code to deploy this model in their production scoring environment t...
A manufacturing plant uses high-resolution images of its products for quality control. To speed up analysis, they use a neural network autoencoder to reduce the dimensionality o...
A financial institution maintains multiple versions of a credit risk model. To avoid confusion in their model inventory, each generated scoring code needs a specific, human-read...