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 Pima Indians Diabetes data set is in the UCI Machine Learning Repository (Lichman 2013) and is available at http://archive.ics.uci.edu/ml/datasets/Pima+Indians+Diabetes.[3]The following SAS statements create a SAS data set from a URL:

   data diabetes;
      %let url=//archive.ics.uci.edu/ml/machine-learning-databases;
      infile "http:&url/pima-indians-diabetes/pima-indians-diabetes.data"
            device=url delimiter=',';
      input NumPregnancies
            PlasmaGlucose
            DiastolicBloodPr
            TricepsSkinfold
            HrSerumInsulin
            BodyMassIndex
            DiabetesPedigreeFn
            Age
            Diabetes $
      ;
   run;

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;
   ods output FitStatistics=fitstats;
   save file="model";
run;

Figure 7.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 50. 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 7.1: PROC HPFOREST Getting Started Example Output

The HPFOREST Procedure

Performance Information
Execution ModeSingle-Machine
Number of Threads4

Data Access Information
DataEngineRolePath
WORK.DIABETESV9InputOn Client

Model Information
ParameterValue 
Variables to Try3(Default)
Maximum Trees100(Default)
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 7.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 7.2: PROC HPFOREST Getting Started Example Output

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


Figure 7.3 shows the first 10 and last 10 observations of the fit statistics. When PROC HPFOREST runs in single-machine mode, it 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 the model fluctuates between 0.230 and 0.238, 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 7.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)
.3630.04480.10920.045640.11070.98162.436
.7350.02770.09790.046640.10780.24622.008
.10940.02320.10000.026010.11370.12011.941
.14320.02040.09540.026510.11170.08221.743
.17820.01870.09080.018290.11260.06681.516
.21310.01760.08870.020640.11100.06571.386
.24300.01750.08520.016610.10840.06771.198
.28170.01630.08130.015270.10450.06531.058
.31740.01560.07820.012920.10210.06400.953
.35510.01520.07770.011580.10190.06380.899
........
........
........
.327400.01230.06360.001850.09430.06180.227
.330420.01240.06350.002010.09400.06190.227
.334260.01230.06350.001850.09450.06180.227
.337940.01230.06360.002010.09360.06180.227
.341400.01230.06360.002010.09400.06180.227
.344920.01230.06350.001850.09400.06170.224
.348460.01230.06350.002180.09460.06180.220
.351950.01230.06350.002010.09410.06180.221
.355750.01230.06350.001680.09410.06180.221
.359210.01230.06340.001680.09430.06180.220


Estimates of variable importance appear after the fit statistics. The Number of Rules column in Figure 7.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 7.4: PROC HPFOREST Getting Started Example Output

Loss Reduction Variable Importance
VariableNumber
of Rules
GiniOOB
Gini
MarginOOB
Margin
PlasmaGlucose13410.1216680.041300.2433360.16453
NumPregnancies6980.031116-0.012260.0622320.01934
BodyMassIndex16650.075439-0.023870.1508780.04945
HrSerumInsulin8150.029283-0.024930.0585660.00500
TricepsSkinfold7800.023756-0.025840.047512-0.00134
Age18140.068814-0.028740.1376280.03839
DiastolicBloodPr12280.038636-0.039660.077272-0.00008
DiabetesPedigreeFn20050.064256-0.056100.1285120.00764




[3] Disclaimer:SAS may reference other websites or content or resources for use at Customer's sole discretion. SAS has no control over any websites or resources that are provided by companies or persons other than SAS. Customer acknowledges and agrees that SAS is not responsible for the availability or use of any such external sites or resources, and does not endorse any advertising, products, or other materials on or available from such websites or resources. Customer acknowledges and agrees that SAS is not liable for any loss or damage that may be incurred by Customer or its end users as a result of the availability or use of those external sites or resources, or as a result of any reliance placed by Customer or its end users on the completeness, accuracy, or existence of any advertising, products, or other materials on, or available from, such websites or resources.