Fairness Comparison

Experiment initialization and data preparation

from piml import Experiment
from piml.models import GLMClassifier, ExplainableBoostingClassifier

exp = Experiment()
exp.data_loader("SimuCredit", silent=True)
exp.data_summary(feature_exclude=["Race", "Gender"], silent=True)
exp.data_prepare(target="Approved", task_type="classification", silent=True)

Train Model

exp.model_train(GLMClassifier(), name="GLM")
exp.model_train(ExplainableBoostingClassifier(), name="EBM")

Fairness Metric

metrics_result = exp.model_fairness_compare(models=["GLM", "EBM"],
                                            show="metrics",
                                            metric="AIR",
                                            group_category=["Race", "Gender"],
                                            reference_group=[1., 1.],
                                            protected_group=[0., 0.],
                                            favorable_threshold=0.5,
                                            return_data=True,
                                            figsize=(6, 4))
metrics_result.data
Adverse Impact Ratio
Group Index Group Category Reference Group Protected Group GLM_AIR EBM_AIR
0 0 Race 1.0 0.0 0.7124 0.6453
1 1 Gender 1.0 0.0 0.8326 0.7819


Fairness Segmented

segmented_result = exp.model_fairness_compare(models=["GLM", "EBM"],
                                              show="segmented",
                                              metric="AIR",
                                              segment_feature="Balance",
                                              group_category=["Race", "Gender"],
                                              reference_group=[1., 1.],
                                              protected_group=[0., 0.],
                                              favorable_threshold=0.5,
                                              segment_bins=5,
                                              return_data=True,
                                              figsize=(8, 4))
segmented_result.data
Group: 0 (Race), Group: 1 (Gender)
Segment Lower Bound Upper Bound Group Index GLM_AIR EBM_AIR
0 0 0.97 306.61 0 0.8251 0.4405
1 0 0.97 306.61 1 0.9017 0.6953
2 1 306.62 601.40 0 0.6900 0.5457
3 1 306.62 601.40 1 0.7452 0.6506
4 2 601.47 1027.23 0 0.6338 0.6963
5 2 601.47 1027.23 1 0.5918 0.7080
6 3 1027.29 1864.90 0 0.6135 0.7131
7 3 1027.29 1864.90 1 0.6028 0.8209
8 4 1864.94 20384.87 0 0.7490 0.8734
9 4 1864.94 20384.87 1 0.7147 0.8212


Total running time of the script: ( 0 minutes 57.140 seconds)

Estimated memory usage: 21 MB

Gallery generated by Sphinx-Gallery