The TREESPLIT Procedure
Scoring
After you create a tree model, you can apply it to training or test data for model assessment or to new data for making predictions. The process of applying a model to a data table is called scoring. You can score data as described in the following sections.
Scoring the Input Data Table
Usually, the purpose of scoring training data is to diagnose the model. The training data table is the data table that you specify with the DATA= option. To score the training data, use the OUTPUT statement to create an output data table that contains one observation for each observation in the training data. You can specify the output data table by using the OUT= option in the OUTPUT statement.
In the following example, the input data table (mycas.hmeq) is scored after the tree model has been created:
proc treesplit data=mycas.hmeq; class Bad Delinq Derog Job Ninq Reason; model Bad = Delinq Derog Job Ninq Reason; output out=mycas.scored; run;
For classification trees, the scored data table also contains one new variable for each level of the response variable. These new variables have the prefix "P_"; for all observations in the same leaf, these new variables represent the proportion of the training observations in that leaf that have that particular response level. For example, if the name of the categorical response variable is Color and it has two levels, Blue and Green, then the scored data table contains the variable P_ColorBlue (which provides the proportion of training data in this leaf that have the response level Blue) and the variable P_ColorGreen (which provides the proportion of training data in this leaf that have the response level Green).
For regression trees, the scored data table contains exactly one new variable with the prefix "P_", which represents the average value of the response variable for all observations in the same leaf. For example, if the name of the continuous response variable is logSalary, then the scored data table contains one new variable, P_logSalary, which represents the average value of the response variable logSalary in the training data for observations in the same leaf.
Scoring Using DATA Step Code
You can use the CODE statement to generate SAS DATA step code that you can use to score new data. The following example uses PROC TREESPLIT to produce SAS DATA step code:
proc treesplit data=mycas.hmeq; class Bad Delinq Derog Job Ninq Reason; model Bad = Delinq Derog Job Ninq Reason; code file="treesplit_data_step.sas"; run;