How to: |
A scoring application enables you to score new data using an RStat scoring routine. Once deployed, scoring routines become user-defined functions (also known as FUSELIB routines). These routines can be used to apply the model formula to new data within any DEFINE or COMPUTE expression. You can define the expression containing the RStat scoring routine using the Function Arguments dialog box or by manually entering the WebFOCUS syntax.
In this example, we have generated and deployed a scoring routine based on a binary Decision Tree Model. Scoring routines can be generated for the following models: Decision Tree (numeric, binary and multinomial), Regression (linear, general linear, poisson, logistic, and multinomial) and Clustering (KMeans, Ewkm, and Hierarchical), NNet, Boost, Random Forest, Survival, Market Basket Analysis, and Association Rules.
RStat brings the power of predictive analytics to the operational enterprise. Any WebFOCUS application can select new data to be scored and then provide ad hoc analytics through active reports, plot the prediction on a map or graph, or support real-time decision-making through KPI dashboards and transactional process flows.
You can use any data source that contains the input variables defined for the model. For the purposes of this example, use the AB_NewCustomers data file.
The Computed Field Creator dialog box opens.
Define the expression as the scoring function with your new data fields as the model input variables and the computed field (SCORE) as the final parameter.
Note: Optionally, you may create a Define field. For the purposes of this example, create a Compute field.
Note: You can define RStat scoring routines within a COMPUTE expression by using the Function Arguments dialog box or by creating a command using WebFOCUS syntax.
The Function Arguments dialog box opens and lists all available built-in functions. A list of predefined functions are grouped into categories that include Character, Data Source and Decoding, Date and Time, Format Conversion, Numeric, and System. Each of the available functions is a routine that takes input parameters and returns a value.
If any RStat Scoring Routines are found within the current application directory, RStat Scoring Routines is added as a category and the related functions appear in the Select a function list. Once the retrieve is completed successfully, the button text changes to Refresh Scoring Routines. You can use the Refresh button to update the list of available routines if you know that the new routines have been added to the current application directory or the existing ones have changed.
Note: If no routines are found, the button text changes to No Scoring Routines Found, the RStat Scoring Routine Category is not added to the available list, and the button is disabled.
The Input Parameters, Types, and Value columns appear for the function.
The function argument is added to the COMPUTE expression.
Enter the following command in the expression window of the Computed Field Creator dialog box:
AB_CREDITSCORE_TREE(AGE, EDUCATION, OCCUPATION, INCOME, SCORE)
The COMPUTE expression appears as follows.
APPROVED/A3 = IF SCORE EQ '1' THEN 'YES' ELSE 'NO';
The Compute tool generates the following expression:
COMPUTE SCORE/A2 = ab_creditscore_tree(AB_NEWCUSTOMERS.SEG_01.AGE, AB_NEWCUSTOMERS.SEG_01.EDUCATION, AB_NEWCUSTOMERS.SEG_01.MARITAL, AB_NEWCUSTOMERS.SEG_01.GENDER, AB_NEWCUSTOMERS.SEG_01.OCCUPATION, AB_NEWCUSTOMERS.SEG_01.INCOME, 'A2'); COMPUTE APPROVED/A3 = IF SCORE EQ '1' THEN 'YES' ELSE 'NO';
You can use RStat scoring routines to apply the model formula to new data within any expression within a COMPUTE or DEFINE.
The calling syntax of a scoring routine is determined based on the input and target variables defined within the model. A sample routine call might look like:
SCORING_ROUTINE(INPUT_1, INPUT_2, INPUT_3, INPUT_4, INPUT_5, INPUT_6, TARGET)
For example:
AB_CREDITSCORE_TREE(AGE, EDUCATION, MARITAL, GENDER, OCCUPATION, INCOME, SCORE)
You can use any data source that contains the input variables defined for the model. For the purposes of this example, use the AB_NewCustomers data file.
Define the expression as the scoring function with your new data fields as the model input variables and the computed field (SCORE) as the final parameter.
Note: Optionally, you may create a Define field. For the purposes of this example, create a Compute field.
Note: You can define RStat scoring routines within a COMPUTE expression by using the Function Arguments dialog box or by creating a command using WebFOCUS syntax.
The Function Arguments dialog box opens and lists all available built-in functions. A list of predefined functions are grouped into categories that include Character, Data Source and Decoding, Date and Time, Format Conversion, Numeric, and System. Each of the available functions is a routine that takes input parameters and returns a value.
If any RStat Scoring Routines are found within the current application directory, RStat Scoring Routines is added as a category and the related functions appear in the Select a function list. Once the retrieve is completed successfully, the button text changes to Refresh Scoring Routines. You can use the Refresh button to update the list of available routines if you know that the new routines have been added to the current application directory or the existing ones have changed.
Note: If no routines are found, the button text changes to No Scoring Routines Found, the RStat Scoring Routine Category is not added to the available list, and the button is disabled.
The Input Parameters, Types, and Value columns appear for the function.
The following image shows the Function Arguments dialog box with these options.
The function argument is added to the COMPUTE expression.
Enter the following command in the expression window of the Computes tab:
AB_CREDITSCORE_TREE(AGE, EDUCATION, OCCUPATION, INCOME, SCORE)
The COMPUTE expression appears as follows.
APPROVED/A3 = IF SCORE EQ '1' THEN 'YES' ELSE 'NO';
The Compute tool generates the following expression:
COMPUTE SCORE/A2 = ab_creditscore_tree(AB_NEWCUSTOMERS.SEG_01.AGE, AB_NEWCUSTOMERS.SEG_01.EDUCATION, AB_NEWCUSTOMERS.SEG_01.MARITAL, AB_NEWCUSTOMERS.SEG_01.GENDER, AB_NEWCUSTOMERS.SEG_01.OCCUPATION, AB_NEWCUSTOMERS.SEG_01.INCOME, 'A2'); COMPUTE APPROVED/A3 = IF SCORE EQ '1' THEN 'YES' ELSE 'NO';
WebFOCUS |