SVMACHINE Procedure

Example 35.6 Mitigating Bias of a Support Vector Classification

This example uses the SVMACHINE procedure to create a support vector classification model while minimizing the equal opportunity bias for the Reason variable. The response variable for the support vector classification 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 SAS library. For this example, the statements assume that your SAS library is named mylib, but you can substitute any appropriately defined SAS library.

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

The following statements use PROC SVMACHINE to create a support vector classification model without minimizing the equal opportunity bias:

proc svmachine data=mylib.hmeq c=0.1;
   input clage clno debtinc loan mortdue value yoj delinq derog job ninq;
   input delinq derog job ninq / level=nominal;
   target bad;
   output out=mylib.scored copyvars=(_ALL_);
   savestate rstore=mylib.model;
run;

The C= option specifies 0.1 as the penalty for training. The two INPUT statements specify clage, clno, debtinc, loan, mortdue, value, yoj, delinq, derog, job, and ninq 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 35.6.1 displays the fit statistics for the classification model.

Output 35.6.1: Fit Statistics Table

The SVMACHINE Procedure

Fit Statistics
StatisticTraining
Accuracy0.9156
Error0.0844
Sensitivity0.0584
Specificity1.0000


After you train a support vector classification model, you might want to view the equal opportunity bias 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 reason;
run;

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

Output 35.6.2: Bias Metrics Table

The ASSESSBIAS Procedure

Bias Metrics
Bias StatisticBias Statistic LabelBias Statistic
Value
Base LevelCompare LevelNote
DemographicParityDemographic Parity (Statistical Parity)0.0165 HomeImp 
PredictiveParityPredictive Parity0.1373 HomeImp 
EqualAccuracyEqual Accuracy0.0344DebtConHomeImp 
EqualizedOddsEqualized Odds0.0242DebtConHomeImpThe maximum TPR difference is greater than the maximum FPR difference.
EqualOpportunityEqual Opportunity0.0242DebtConHomeImp 


In order to use the MITIGATEBIAS statement to reduce the equal opportunity bias, 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 35.6.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 35.6.3: Output Variables Table

The ASTORE Procedure

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


The following statements use PROC SVMACHINE to create a support vector classification model, while minimizing the equal opportunity bias for reason by using the MITIGATEBIAS statement:

ods graphics on;
proc svmachine data=mylib.hmeq c=0.1;
   input clage clno debtinc loan mortdue value yoj delinq derog job ninq;
   input delinq derog job ninq / level=nominal;
   target bad;
   mitigatebias biasmetric=EQUALOPPORTUNITY bound=75 pevents="1 0"
      pvars=(P_BAD1 P_BAD0) seed=12345 sensitivevar=reason targetevent="1";
   output out=mylib.scored copyvars=(_ALL_);
   savestate rstore=mylib.model;
run;

The BIASMETRIC= option specifies that equal opportunity be used as the bias metric. The BOUND= option specifies 75 as the bound value for the EGR algorithm. 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 reason 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.

Output 35.6.4 displays the information about the options that are used for bias mitigation. Output 35.6.5 displays the model accuracy and bias metric values over each iteration of the EGR algorithm. Output 35.6.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 SVMACHINE selects the iteration that has the lowest bias metric. In this case, the 8th 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 35.6.4: Mitigation Information Table

The SVMACHINE Procedure

Mitigation Information
DescriptionCharacter ValueValue
Bias MetricEQUALOPPORTUNITY.
Sensitive VariableREASON.
ResponseBAD.
Bound Value7575
Learning Rate0.010.01
Maximum Iteration1010
Tolerance0.0050.005
Event Level1.


Output 35.6.5: Iteration History Table

EGR Iteration History
IterationEqual OpportunityMisclassification
Rate
Multi-Class
Log Loss
10.0241850.19110.7700
20.0241850.19110.7641
30.0228430.19130.7673
40.0215000.19140.7757
50.0195710.19180.7790
60.0220960.19240.7692
70.0195710.19230.7820
80.0170450.19190.7867
90.0170450.19190.7875
100.0170450.19190.7904


Output 35.6.6: Iteration History Graph

Iteration History Graph


Note: Input data must be in a table that is accessible in your session. You can refer to this table by using a two-level name. The first level is a libref, and the second level is the table name. For more information, see the section Using SAS Viya Workbench in Chapter 2, Shared Concepts.

Last updated: September 23, 2026