neuralNet annCode

Standard Churn Model Scoring Code Generation

Scénario de test & Cas d'usage

Business Context

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 to score new customers daily.
About the Set : neuralNet

Training of classical artificial neural networks.

Discover all actions of neuralNet
Data Preparation

Create a dataset of telecom customer profiles with features like contract type, monthly charges, tenure, and a binary churn indicator.

Copied!
1DATA casuser.telecom_churn;
2 call streaminit(123);
3 DO i = 1 to 2000;
4 tenure = rand('INTEGER', 1, 72);
5 monthly_charges = 20 + rand('UNIFORM') * 100;
6 is_monthly_contract = rand('BERNOULLI', 0.55);
7 IF (tenure < 12 and monthly_charges > 70 and is_monthly_contract = 1) THEN DO;
8 churn = rand('BERNOULLI', 0.75);
9 END;
10 ELSE DO;
11 churn = rand('BERNOULLI', 0.1);
12 END;
13 OUTPUT;
14 END;
15RUN;

Étapes de réalisation

1
Train a neural network model using `annTrain` on the `telecom_churn` data and store the model in a CAS table named `churn_model`.
Copied!
1PROC CAS;
2 neuralNet.annTrain /
3 TABLE={name='telecom_churn'},
4 inputs={{name='tenure'}, {name='monthly_charges'}, {name='is_monthly_contract'}},
5 target='churn',
6 arch='NEURAL',
7 hidden={{n=10, act='RELU'}},
8 casOut={name='churn_model', replace=true};
9RUN;
2
Use `annCode` to generate the scoring code from the `churn_model` table and save it into a CAS table named `churn_scoring_code`.
Copied!
1PROC CAS;
2 neuralNet.annCode /
3 modelTable={name='churn_model'},
4 code={casOut={name='churn_scoring_code', replace=true}};
5RUN;

Expected Result


The action should successfully generate SAS DATA step code and store it in the `churn_scoring_code` table. The code should contain the logic to score new customers based on the trained churn model. A review of the output table should show the generated SAS code as a character variable, ready for deployment.