ASSESS Procedure
Example 3.1 Assess a Model That Has a Binary Target
(View the complete code for this example.)
The following example demonstrates how to use the ASSESS procedure to compute ROC information, lift information, and fit statistics for a model that has a nominal target.
The following DATA step creates a score data table from a previously trained model. For example, the model could be a tree-based model, a neural network, or a support vector machine.
data mylib.score2;
length good_bad $4;
input _PartInd_ good_bad p_good p_bad;
datalines;
0 good 0.6675 0.3325
0 good 0.5189 0.4811
0 good 0.6852 0.3148
0 bad 0.0615 0.9385
0 bad 0.3053 0.6947
0 bad 0.6684 0.3316
0 good 0.6422 0.3578
0 good 0.6752 0.3248
0 good 0.5396 0.4604
0 good 0.4983 0.5017
0 bad 0.1916 0.8084
0 good 0.5722 0.4278
0 good 0.7099 0.2901
0 good 0.4642 0.5358
0 good 0.4863 0.5137
1 bad 0.4942 0.5058
1 bad 0.4863 0.5137
1 bad 0.4942 0.5058
1 good 0.6118 0.3882
1 good 0.5375 0.4625
1 good 0.8132 0.1868
1 good 0.6914 0.3086
1 good 0.5700 0.4300
1 good 0.8189 0.1811
1 good 0.2614 0.7386
1 good 0.1910 0.8090
1 good 0.5129 0.4871
1 good 0.8417 0.1583
1 good 0.5500 0.4500
;
The following PROC ASSESS call uses five bins to do lift analysis and uses 0.2 as the incremental step size for ROC analysis:
proc assess data=mylib.score2 ncuts=5 nbins=5;
var p_good;
target good_bad / event="good" level=nominal;
fitstat pvar=p_bad / pevent="bad" ;
by _PartInd_;
run;
Output 3.1.1 shows the lift and gain for each bin in the first partition.
Output 3.1.1: Lift Regression Information for the First Partition
| Lift Information | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Variable | Event | Depth | Number of Observations | Number of Events | Captured Response Percent | Lift | Response Percent | Gain | |||||
| Individual | Cumulative | Individual | Cumulative | Cumulative Best | Individual | Cumulative | Individual | Best | |||||
| p_good | good | 0 | 0 | 0 | 0.00 | 0.00 | . | . | . | . | . | . | . |
| 20 | 3 | 3 | 27.27 | 27.27 | 1.363636 | 1.363636 | 1.363636 | 100.00 | 100.00 | 0.363636 | 0.363636 | ||
| 40 | 3 | 2 | 18.18 | 45.45 | 0.909091 | 1.136364 | 1.363636 | 66.67 | 83.33 | 0.136364 | 0.363636 | ||
| 60 | 3 | 3 | 27.27 | 72.73 | 1.363636 | 1.212121 | 1.363636 | 100.00 | 88.89 | 0.212121 | 0.363636 | ||
| 80 | 3 | 3 | 27.27 | 100.00 | 1.363636 | 1.250000 | 1.250000 | 100.00 | 91.67 | 0.250000 | 0.250000 | ||
| 100 | 3 | 0 | 0.00 | 100.00 | 0 | 1 | 1 | 0.00 | 73.33 | 0 | 0 | ||
Output 3.1.2 shows the ROC information, including the confusion matrix and its derivations, for each bin in the first partition.
Output 3.1.2: ROC Information for the First Partition
| ROC Information | |||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Variable | Event | Cutoff | TP | FP | FN | TN | FPR | FDR | TPR | FNR | TNR | ACC | KS | Youden Index | F1 Score | F0.5 Score | AUC | Gini | Gamma | Tau | Misclassification (Event) |
| p_good | good | 0 | 11 | 4 | 0 | 0 | 1 | 0.266667 | 1 | 0 | 0 | 0.733333 | 0 | 0 | 0.846154 | 0.774648 | 0.806818 | 0.613636 | 0.692308 | 0.257143 | 0.266667 |
| 0.200000 | 11 | 2 | 0 | 2 | 0.500000 | 0.153846 | 1 | 0 | 0.500000 | 0.866667 | 0 | 0.500000 | 0.916667 | 0.873016 | 0.806818 | 0.613636 | 0.692308 | 0.257143 | 0.133333 | ||
| 0.400000 | 11 | 1 | 0 | 3 | 0.250000 | 0.083333 | 1 | 0 | 0.750000 | 0.933333 | 1 | 0.750000 | 0.956522 | 0.932203 | 0.806818 | 0.613636 | 0.692308 | 0.257143 | 0.066667 | ||
| 0.600000 | 5 | 1 | 6 | 3 | 0.250000 | 0.166667 | 0.454545 | 0.545455 | 0.750000 | 0.533333 | 0 | 0.204545 | 0.588235 | 0.714286 | 0.806818 | 0.613636 | 0.692308 | 0.257143 | 0.466667 | ||
| 0.800000 | 0 | 0 | 11 | 4 | 0 | . | 0 | 1 | 1 | 0.266667 | 0 | 0 | 0 | 0 | 0.806818 | 0.613636 | 0.692308 | 0.257143 | 0.733333 | ||
| 1 | 0 | 0 | 11 | 4 | 0 | . | 0 | 1 | 1 | 0.266667 | 0 | 0 | 0 | 0 | 0.806818 | 0.613636 | 0.692308 | 0.257143 | 0.733333 | ||
Output 3.1.3 shows the error metrics of the nominal target in the first partition.
Output 3.1.3: Fit Statistics for the First Partition
| Fit Statistics | |||||
|---|---|---|---|---|---|
| Number of Observations | Squared Error | Mean Consequential Error | Multiclass Log Loss | ||
| Divisor of Average | Average | Root Average | |||
| 15 | 15 | 0.169127 | 0.411250 | 0.266667 | 0.514728 |
Output 3.1.4 shows the lift and gain for each bin in the second partition.
Output 3.1.4: Lift Regression Information for the Second Partition
| Lift Information | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Variable | Event | Depth | Number of Observations | Number of Events | Captured Response Percent | Lift | Response Percent | Gain | |||||
| Individual | Cumulative | Individual | Cumulative | Cumulative Best | Individual | Cumulative | Individual | Best | |||||
| p_good | good | 0 | 0 | 0 | 0.00 | 0.00 | . | . | . | . | . | . | . |
| 20 | 3 | 3 | 27.27 | 27.27 | 1.363636 | 1.363636 | 1.363636 | 100.00 | 100.00 | 0.363636 | 0.363636 | ||
| 40 | 3 | 3 | 27.27 | 54.55 | 1.363636 | 1.363636 | 1.363636 | 100.00 | 100.00 | 0.363636 | 0.363636 | ||
| 60 | 3 | 3 | 27.27 | 81.82 | 1.363636 | 1.363636 | 1.363636 | 100.00 | 100.00 | 0.363636 | 0.363636 | ||
| 80 | 3 | 0 | 0.00 | 81.82 | 0 | 1.022727 | 1.250000 | 0.00 | 75.00 | 0.022727 | 0.250000 | ||
| 100 | 2 | 2 | 18.18 | 100.00 | 0.909091 | 1 | 1 | 100.00 | 78.57 | 0 | 0 | ||
Output 3.1.5 shows the ROC information, including the confusion matrix and its derivations, for each bin in the second partition.
Output 3.1.5: ROC Information for the Second Partition
| ROC Information | |||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Variable | Event | Cutoff | TP | FP | FN | TN | FPR | FDR | TPR | FNR | TNR | ACC | KS | Youden Index | F1 Score | F0.5 Score | AUC | Gini | Gamma | Tau | Misclassification (Event) |
| p_good | good | 0 | 11 | 3 | 0 | 0 | 1 | 0.214286 | 1 | 0 | 0 | 0.785714 | 0 | 0 | 0.880000 | 0.820896 | 0.636364 | 0.272727 | 0.428571 | 0.098901 | 0.214286 |
| 0.200000 | 10 | 3 | 1 | 0 | 1 | 0.230769 | 0.909091 | 0.090909 | 0 | 0.714286 | 0 | -0.09091 | 0.833333 | 0.793651 | 0.636364 | 0.272727 | 0.428571 | 0.098901 | 0.285714 | ||
| 0.400000 | 9 | 3 | 2 | 0 | 1 | 0.250000 | 0.818182 | 0.181818 | 0 | 0.642857 | 0 | -0.18182 | 0.782609 | 0.762712 | 0.636364 | 0.272727 | 0.428571 | 0.098901 | 0.357143 | ||
| 0.600000 | 5 | 0 | 6 | 3 | 0 | 0 | 0.454545 | 0.545455 | 1 | 0.571429 | 1 | 0.454545 | 0.625000 | 0.806452 | 0.636364 | 0.272727 | 0.428571 | 0.098901 | 0.428571 | ||
| 0.800000 | 3 | 0 | 8 | 3 | 0 | 0 | 0.272727 | 0.727273 | 1 | 0.428571 | 0 | 0.272727 | 0.428571 | 0.652174 | 0.636364 | 0.272727 | 0.428571 | 0.098901 | 0.571429 | ||
| 1 | 0 | 0 | 11 | 3 | 0 | . | 0 | 1 | 1 | 0.214286 | 0 | 0 | 0 | 0 | 0.636364 | 0.272727 | 0.428571 | 0.098901 | 0.785714 | ||
Output 3.1.6 shows the error metrics of the nominal target in the second partition.
Output 3.1.6: Fit Statistics for the Second Partition
| Fit Statistics | |||||
|---|---|---|---|---|---|
| Number of Observations | Squared Error | Mean Consequential Error | Multiclass Log Loss | ||
| Divisor of Average | Average | Root Average | |||
| 14 | 14 | 0.221587 | 0.470731 | 0.142857 | 0.636734 |