GRADBOOST Procedure

Example 17.4 Mitigating Bias of a Boosting Tree Model

This example uses the GRADBOOST procedure to create a gradient boosting tree model while minimizing the demographic parity for the Job variable. The response variable for the gradient boosting tree model is Bad, a classification variable that has two values (0 for payment of loan and 1 for default). The other variables are predictor variables for the model.

The following statements load the data table mylib.hmeq into your CAS session. For this example, the statements assume that your CAS engine libref is named mylib, but you can substitute any appropriately defined CAS engine libref.

data mylib.hmeq;
   set sampsio.hmeq;
run;

The following statements use PROC GRADBOOST to create a gradient boosting tree model without minimizing the demographic parity:

proc gradboost data=mylib.hmeq nTrees=20 seed=12345;
   input CLAge CLNo DebtInc Derog
         Loan MortDue Value / level=interval;
   input Reason / level=nominal;
   target Bad / level=nominal;
   output out=mylib.scored copyvars=(_ALL_);
   saveState rstore=mylib.model;
run;

The NTREES= option specifies that there are 20 trees to grow in the boosting model. The SEED= option specifies the random number seed for model building to be 12345. The two INPUT statements specify CLAge, CLNo, DebtInc, Derog, Loan, MortDue, Value, and Reason as the input variables. The TARGET statement specifies Bad as the target variable. The OUTPUT statement generates the data table mylib.scored, which contains the predicted mortgage default from the model for each observation and contains all variables from the input data table as copy variables. The SAVESTATE statement creates an analytic store for the model and saves it as a binary object in the data table mylib.model.

Output 17.4.1 displays the fit statistics for the boosting model.

Output 17.4.1: Fit Statistics Table

The GRADBOOST Procedure

Fit Statistics
Number
of Trees
Training
Average
Square Error
Training
Misclassification
Rate
Training
Log Loss
10.14640.1990.461
20.13590.1990.432
30.12720.1990.410
40.12020.1990.392
50.11430.1930.377
60.10950.1750.364
70.10540.1620.353
80.10210.1560.344
90.09920.1370.336
100.09660.1280.329
110.09430.1230.322
120.09250.1160.317
130.09080.1140.312
140.08960.1130.308
150.08850.1140.304
160.08720.1130.300
170.08640.1130.297
180.08570.1130.294
190.08490.1130.291
200.08420.1120.289


After you train a gradient boosting tree model, you might want to view the demographic parity of the trained model. You can do this by running the ASSESSBIAS procedure. For more information about PROC ASSESSBIAS, see Chapter 3, ASSESSBIAS Procedure.

The following statements use PROC ASSESSBIAS to assess the bias measurements of the model:

proc assessbias data=mylib.scored;
   target bad / event="1" level=nominal;
   var P_Bad1;
   fitstat pvar=P_BAD0 / pevent="0";
   sensitiveVar Job;
run;

Output 17.4.2 displays the bias metric values of the model. PROC ASSESSBIAS also produces other output not shown here.

Output 17.4.2: Bias Metrics Table

The ASSESSBIAS Procedure

Bias Metrics
Bias StatisticBias Statistic LabelBias Statistic
Value
Base LevelCompare LevelNote
DemographicParityDemographic Parity (Statistical Parity)0.1170SelfOffice 
PredictiveParityPredictive Parity0.0836SalesOffice 
EqualAccuracyEqual Accuracy0.1090OfficeSales 
EqualizedOddsEqualized Odds0.1806SelfSalesThe maximum TPR difference is greater than the maximum FPR difference.
EqualOpportunityEqual Opportunity0.1806SelfSales 


In order to use the MITIGATEBIAS statement to reduce the demographic parity, you must specify the levels of the response (target) variable and the corresponding predicted variables. You can use the DESCRIBE statement in the ASTORE procedure to obtain this information. The following statements use PROC ASTORE to describe the model:

proc astore;
   describe rstore=mylib.model;
run;

Output 17.4.3 lists the output variables created by the model. The predicted variables are P_BAD1 and P_BAD0. Their corresponding response (target) levels are 1 and 0, respectively.

Output 17.4.3: Output Variables Table

The ASTORE Procedure

Output Variables
NameLengthTypeLabel
P_BAD18NumPredicted: BAD=1
P_BAD08NumPredicted: BAD=0
I_BAD12CharacterInto: BAD
_WARN_4CharacterWarnings


The following statements use PROC GRADBOOST to create a gradient boosting tree model, while minimizing the demographic parity for Job by using the MITIGATEBIAS statement:

ods graphics on;

proc gradboost data=mylib.hmeq nTrees=20 seed=12345;;
   input CLAge CLNo DebtInc Derog
         Loan MortDue Value / level=interval;
   input Reason / level=nominal;
   target Bad / level=nominal;
   output out=mylib.scored;
   saveState rstore=mylib.model;
   mitigateBias pevents="1 0"
                pvars=(P_BAD1 P_BAD0)
                seed=12345
                sensitivevar=Job
                targetEvent="1"
                maxiter=11;
run;

The PEVENTS= option lists the levels of the response (target) variable Bad. The predicted variables correspond to the levels that are listed in the PVARS= option. The PVARS= option lists the predicted variables that contain the posterior probability for each level in model prediction that corresponds to the response (target) variable Bad. The SEED= option specifies the seed for the pseudorandom number generator to be 12345. The SENSITIVEVAR= option names the variable Job as the sensitive variable for the purpose of reducing the value of the bias measurement. The TARGETEVENT= option specifies the value 1 as the event of interest. The MAXITER= option specifies 11 as the maximum number of iterations for the EGR algorithm.

Output 17.4.4 displays the information about the options that are used for bias mitigation. Output 17.4.5 displays the model accuracy and bias metric values over each iteration of the EGR algorithm. Output 17.4.6 shows the iteration history, which is a graphical representation of the iteration history table. The graph displays the bias metric and the misclassification rate for each iteration. PROC GRADBOOST selects the iteration that has the lowest bias metric. In this case, the 10th iteration is selected; the graph indicates this selection by using the legend and a vertical line. The MITIGATEBIAS statement also creates other tables, which are not shown here but are listed in the section ODS Table Names.

Output 17.4.4: Mitigation Information Table

The GRADBOOST Procedure

Mitigation Information
DescriptionCharacter ValueValue
Bias MetricDEMOGRAPHICPARITY.
Sensitive VariableJOB.
ResponseBAD.
Bound Value100100
Learning Rate0.010.01
Maximum Iteration1111
Tolerance0.0050.005
Event Level1.


Output 17.4.5: Iteration History Table

EGR Iteration History
IterationDemographic Parity
(Statistical Parity)
Misclassification
Rate
Multi-Class
Log Loss
10.1170340.11240.2887
20.1009850.11360.2896
30.1098360.11540.2901
40.1057090.11440.2895
50.0964010.11540.2902
60.1006210.11480.2906
70.0850660.11410.2917
80.0986040.11480.2927
90.0726970.11680.2933
100.0648120.11640.2940
110.0728830.11580.2937


Output 17.4.6: Iteration History Graph

Iteration History Graph


Last updated: August 06, 2026