8.4. Fairness Simulation Study 1¶
This example demonstrates the use of PiML for fairness testing based on the integrated solas-ai
APIs. The SolasSimu1 data is modified from the Friedman
demo data. The covariates used for modeling are x1
, x2
, …, x5
, the response Label
is binary and it is a classification problem. The rest variables are demographic variables used for testing fairness. The data and APIs are contributed by Solas-AI.
Click the ipynb links to run examples in Google Colab.
8.4.1. Load and Prepare Data¶
[1]:
from piml import Experiment
exp = Experiment()
[3]:
# Choose SolasSimu1
exp.data_loader()
[4]:
# Exclude demographic features one-by-one: "Minority", "Majority", "Age >= 62", "Age < 62"
# Excluded features will show in grey color in the table
exp.data_summary()
[5]:
# Prepare dataset with default settings
exp.data_prepare()
[6]:
# Exploratory Data Analysis
exp.eda()
8.4.2. Train ML Model(s)¶
[7]:
# Choose GAM with default settings, click run;
# When training is finished, register the model
exp.model_train()
8.4.3. Fairness Testing¶
Suggested Procudure:
First select a registered model (in this case, GAM)
Group Setting:
Set Add Category=”By weights”, Enter “Race” in Category Name; Select “Majority” as reference; Select “Minority” as protected; Click on Add Button
Set Add Category=”By weights”, Enter “Age” in Category Name; Select “Age<62” as reference; Select “Age>=62” as protected; Click on Add Button
Switch to other tabs to view metrics and segmented breakdowns.
[8]:
exp.model_fairness_solas()
[ ]: