The HPFOREST Procedure

Getting Started: HPFOREST Procedure

This example uses diabetes data to illustrate PROC HPFOREST. Diabetes is a major American disease. The American Diabetes Association estimates that over 8% of Americans have diabetes, and diabetes costs Americans over $175 billion a year. The National Institute of Diabetes and Digestive and Kidney Diseases (NIDDK) has been studying diabetes and obesity in the Akimel O’otham (formerly known as Pima Indians) in Arizona for over 30 years. Smith et al. (1988) prepared some of the NIDDK data for forecasting the onset of diabetes and then donated the data for community use. Since then, the data have been applied to dozens of experimental algorithms for predicting the onset of diabetes.

The following SAS statements create a SAS data set:

data diabetes;
   input NumPregnancies
        PlasmaGlucose
        DiastolicBloodPr
        TricepsSkinfold
        HrSerumInsulin
        BodyMassIndex
        DiabetesPedigreeFn
        Age
        Diabetes $;
   datalines;
 6  148  72 35   0 33.6 0.627 50 2
 1   85  66 29   0 26.6 0.351 31 1
 8  183  64  0   0 23.3 0.672 32 2
 1   89  66 23  94 28.1 0.167 21 1
 0  137  40 35 168 43.1 2.288 33 2
 5  116  74  0   0 25.6 0.201 30 1
 3   78  50 32  88 31.0 0.248 26 2
10  115   0  0   0 35.3 0.134 29 1
 2  197  70 45 543 30.5 0.158 53 2

   ... more lines ...   

 2  122  70 27   0 36.8 0.340 27 1
 5  121  72 23 112 26.2 0.245 30 1
 1  126  60  0   0 30.1 0.349 47 2
 1   93  70 31   0 30.4 0.315 23 1
;

The variable diabetes has values 0 and 1, 1 indicating the presence of diabetes. The other variables are raw measures on interval scales, except for DiabetesPedigreeFn, which is an interval variable created by Smith et al. (1988) to capture the family history of diabetes. PROC HPFOREST uses an interval scale for numeric variables and a nominal scale for categorical variables unless the scale is specified. The following statements run PROC HPFOREST and save the model in a binary file:

proc hpforest data=diabetes ;
   input NumPregnancies
         PlasmaGlucose
         DiastolicBloodPr
         TricepsSkinfold
         HrSerumInsulin
         BodyMassIndex
         DiabetesPedigreeFn
         Age ;
   target Diabetes / level=binary;
   ods output FitStatistics=fitstats;
   save file="model";
run;

Figure 1 shows that the program ran locally and that four threads were used. The default number of threads is the number of processors in the computer. The listing also shows the values of the training parameters and the number of observations (768). No parameters are specified in the PROC HPFOREST statement; therefore, all the values are default. The maximum number of decision trees to create is 100. The VARS_TO_TRY= option value is 3, indicating that three of the eight input variables are randomly selected to be considered for a splitting rule.

Figure 1: PROC HPFOREST Getting Started Example Output

The HPFOREST Procedure

Performance Information
Execution ModeSingle-Machine
Number of Threads16

Data Access Information
DataEngineRolePath
WORK.DIABETESV9InputOn Client

Model Information
ParameterValue 
Variables to Try3(Default)
Maximum Trees100(Default)
Actual Trees100 
Inbag Fraction0.6(Default)
Prune Fraction0(Default)
Prune Threshold0.1(Default)
Leaf Fraction0.00001(Default)
Leaf Size Setting1(Default)
Leaf Size Used1 
Category Bins30(Default)
Interval Bins100 
Minimum Category Size5(Default)
Node Size100000(Default)
Maximum Depth20(Default)
Alpha1(Default)
Exhaustive5000(Default)
Rows of Sequence to Skip5(Default)
Split Criterion.Gini
Preselection Method.BinnedSearch
Missing Value Handling.Valid value

Number of Observations
TypeN
Number of Observations Read768
Number of Observations Used768


Figure 2 shows the baseline fit statistics. PROC HPFOREST first computes baseline statistics without using a model. The listing shows a baseline misclassification rate of 0.349, because that is the proportion of observations for which the value of diabetes is 1.

Figure 2: PROC HPFOREST Getting Started Example Output

Baseline Fit Statistics
StatisticValue
Average Square Error0.227
Misclassification Rate0.349
Log Loss0.647


Figure 3 shows the first 10 and last 10 observations of the fit statistics. PROC HPFOREST computes fit statistics for a sequence of forests that have an increasing number of trees. As the number of trees increases, the fit statistics usually improve (decrease) at first and then level off and fluctuate in a small range. Forest models provide an alternative estimate of average square error and misclassification rate, called the out-of-bag (OOB) estimate. The OOB estimate is a convenient substitute for an estimate that is based on test data and is a less biased estimate of how the model will perform on future data. For more information, see the section Bagging the Data. The listing shows that the OOB error estimate is worse (larger) than the estimate that evaluates all observations on all trees. This is usual. The OOB misclassification rate for models with many trees fluctuates between 0.233 and 0.240, which is in a range much less than the baseline rate of rate of 0.349. Therefore, you can conclude that the model is good.

Figure 3: PROC HPFOREST Getting Started Example Output

Number
of Trees
Number
of Leaves
Average
Square
Error
(Train)
Average
Square
Error
(OOB)
Misclassification
Rate
(Train)
Misclassification
Rate
(OOB)
Log
Loss
(Train)
Log
Loss
(OOB)
1890.15100.3770.15100.3773.4788.672
21960.08370.3230.13280.3390.8657.067
33140.05900.2860.06640.3240.2585.848
44130.05040.2700.05990.3100.1945.129
55260.04720.2570.03780.3110.1674.302
66310.04190.2400.03520.2930.1563.718
77370.03970.2330.02730.2880.1553.429
88440.03850.2290.02860.2860.1553.173
99580.03560.2140.01690.2760.1502.741
1010560.03460.2040.01820.2680.1482.494
........
........
........
9195450.02620.1610.00000.2280.1400.567
9296570.02620.1610.00000.2300.1400.568
9397610.02620.1610.00000.2250.1400.567
9498690.02620.1610.00000.2280.1400.568
9599800.02620.1610.00000.2250.1400.566
96100760.02630.1610.00000.2290.1410.566
97101810.02630.1610.00000.2280.1400.565
98102950.02620.1610.00000.2280.1400.565
99104100.02620.1610.00000.2270.1400.564
100105150.02610.1600.00000.2280.1400.563


Estimates of variable importance appear after the fit statistics. The Number of Rules column in Figure 4 shows the number of splitting rules that use a variable. The section Measuring Variable Importance explains the measures of importance. Each measure is computed twice: once on training data and once on out-of-bag data. As with fit statistics, the out-of-bag estimates are less biased. The rows are sorted by the OOB Gini measure, which is a more stringent measure than the OOB margin measure. The OOB Gini column is negative for seven variables, and the OOB margin column is negative for two variables. The splitting rules that involve these two variables are, on average, spurious. The main conclusion from fitting the forest model to these data is that plasmaGlucose is the most important predictor of future onset of diabetes.

Figure 4: PROC HPFOREST Getting Started Example Output

Loss Reduction Variable Importance
VariableNumber
of Rules
GiniOOB
Gini
MarginOOB
Margin
PlasmaGlucose13310.1225450.041230.2450890.16359
NumPregnancies7470.031608-0.013380.0632160.01889
HrSerumInsulin8830.031949-0.021410.0638980.00871
BodyMassIndex16820.077170-0.023850.1543400.05160
TricepsSkinfold7360.022025-0.025700.044049-0.00292
Age17540.066089-0.029160.1321770.03828
DiastolicBloodPr12340.038067-0.036530.0761340.00326
DiabetesPedigreeFn20480.065277-0.055010.1305550.00954


Last updated: May 25, 2022