The HP4SCORE Procedure
Example 3.1 Fit Statistics
The following statements run PROC HP4SCORE and compute the misclassification rate of the scored output. Before SAS Enterprise Miner 14.1, the target values from the input data set had to be merged with the predictions in the scored output before fit statistics were computed. This is not necessary with SAS Enterprise Miner 14.1 and later.
filename outmodel "C:\Temp\HPForestModel";
proc HPFOREST data=sampsio.hmeq;
input CLAge CLNo Loan MortDue Value YoJ DebtInc/level=interval;
input Bad Delinq Derog nInq Reason/level=nominal;
target Job/level=nominal;
ods output FitStatistics=fitstats;
save file=outmodel;
quit;
Output 3.1.1 shows that the program ran locally and that four threads were used. The default number of threads is the number of processor cores in the computer. The listing also shows the values of the training parameters, the number of observations read (5,960), and the number of observations used in training (5,681). A total of 279 observations are missing the target value and are excluded from training.
Output 3.1.1: Output from PROC HPFOREST
| Performance Information | |
|---|---|
| Execution Mode | Single-Machine |
| Number of Threads | 16 |
| Data Access Information | |||
|---|---|---|---|
| Data | Engine | Role | Path |
| SAMPSIO.HMEQ | V9 | Input | On Client |
| Model Information | ||
|---|---|---|
| Parameter | Value | |
| Variables to Try | 3 | (Default) |
| Maximum Trees | 100 | (Default) |
| Actual Trees | 100 | |
| Inbag Fraction | 0.6 | (Default) |
| Prune Fraction | 0 | (Default) |
| Prune Threshold | 0.1 | (Default) |
| Leaf Fraction | 0.00001 | (Default) |
| Leaf Size Setting | 1 | (Default) |
| Leaf Size Used | 1 | |
| Category Bins | 30 | (Default) |
| Interval Bins | 100 | |
| Minimum Category Size | 5 | (Default) |
| Node Size | 100000 | (Default) |
| Maximum Depth | 20 | (Default) |
| Alpha | 1 | (Default) |
| Exhaustive | 5000 | (Default) |
| Rows of Sequence to Skip | 5 | (Default) |
| Split Criterion | . | Gini |
| Preselection Method | . | Loh |
| Missing Value Handling | . | Valid value |
| Number of Observations | |
|---|---|
| Type | N |
| Number of Observations Read | 5960 |
| Number of Observations Used | 5681 |
Output 3.1.2 shows the baseline fit statistics.
Output 3.1.2: Baseline Fit Statistics Output
| Baseline Fit Statistics | |
|---|---|
| Statistic | Value |
| Average Square Error | 0.121 |
| Misclassification Rate | 0.580 |
| Log Loss | 1.460 |
The following statements print the first 10 observations of the table of fit statistics, which are shown in Output 3.1.3. The misclassification rate drops from 0.18835 to 0.02535 as the number of trees in the forest grows from 1 to 10.
proc print data=fitstats(obs=10);
run;
Output 3.1.3: First 10 Observations Fit Statistics Output
| Obs | NTrees | NLeaves | PredAll | PredOob | MiscAll | MiscOob | LogLossAll | LogLossOob |
|---|---|---|---|---|---|---|---|---|
| 1 | 1 | 665 | 0.0512 | 0.0888 | 0.20331 | 0.326 | 2.020 | 4.605 |
| 2 | 2 | 1347 | 0.0330 | 0.0812 | 0.12744 | 0.309 | 0.567 | 3.929 |
| 3 | 3 | 2036 | 0.0279 | 0.0762 | 0.08203 | 0.288 | 0.391 | 3.407 |
| 4 | 4 | 2782 | 0.0252 | 0.0727 | 0.05580 | 0.280 | 0.332 | 2.970 |
| 5 | 5 | 3530 | 0.0230 | 0.0693 | 0.04189 | 0.272 | 0.310 | 2.543 |
| 6 | 6 | 4262 | 0.0211 | 0.0645 | 0.03133 | 0.253 | 0.296 | 2.173 |
| 7 | 7 | 4917 | 0.0209 | 0.0615 | 0.02852 | 0.245 | 0.300 | 1.778 |
| 8 | 8 | 5649 | 0.0202 | 0.0587 | 0.02394 | 0.233 | 0.296 | 1.546 |
| 9 | 9 | 6384 | 0.0196 | 0.0568 | 0.02236 | 0.224 | 0.292 | 1.374 |
| 10 | 10 | 7112 | 0.0192 | 0.0548 | 0.02042 | 0.211 | 0.290 | 1.242 |
The following statements print the final row of the table of fit statistics, which are shown in Output 3.1.4. The misclassification rate is 0.00334 in the final model.
proc print data=fitstats(firstobs=100);
run;
Output 3.1.4: Last Observation Fit Statistics Output
| Obs | NTrees | NLeaves | PredAll | PredOob | MiscAll | MiscOob | LogLossAll | LogLossOob |
|---|---|---|---|---|---|---|---|---|
| 100 | 100 | 70598 | 0.0164 | 0.0408 | 0.00493 | 0.120 | 0.280 | 0.541 |
The following code inputs the model that PROC HPFOREST created and outputs predictions for each observation in the input data set:
proc hp4score data=sampsio.hmeq;
score file=outmodel out=scoreout3;
run;
Output 3.1.5 shows that PROC HP4SCORE was run with four threads; 5,960 observations were read and output even though 279 of them have a missing target value.
Output 3.1.5: Performance Information
| Performance Information | |
|---|---|
| Execution Mode | Single-Machine |
| Number of Threads | 16 |
| Data Access Information | |||
|---|---|---|---|
| Data | Engine | Role | Path |
| SAMPSIO.HMEQ | V9 | Input | On Client |
| WORK.SCOREOUT3 | V9 | Output | On Client |
| Number of Observations | |
|---|---|
| Type | N |
| Number of Observations Read | 5960 |
| Number of Observations Used | 5960 |
| Sum of Frequencies Used | 5960 |
The following code computes the misclassification rate. Note that PROC MEANS excludes the observations that have missing target values.
data score;
set scoreout3;
if upcase(JOB) ne upcase(I_JOB) then misclass=1;
else misclass=0;
run;
proc means data=score(where=(JOB ne ''));
var misclass;
run;
Output 3.1.6 shows the output from PROC MEANS with a misclassification rate of 0.0033445, the same as in the fit statistics table from PROC HPFOREST.
Output 3.1.6: Output from PROC MEANS with Misclassification Rate
| Analysis Variable : misclass | ||||
|---|---|---|---|---|
| N | Mean | Std Dev | Minimum | Maximum |
| 5681 | 0.0049287 | 0.0700377 | 0 | 1.0000000 |