Using explainability techniques
We can use explainability techniques to identify potential biases in our models and then plan to improve them toward fairness. Here, we want to practice this concept with SHAP and identify fairness issues between male and female groups in the adult income dataset we practiced with in the previous chapter. Using the same SHAP explainer object we built for the XGBoost model we trained on adult income data in the previous chapter, in the following bar plots, we can see that there is a low, but non-negligible, dependency on sex regarding the whole dataset or only the incorrectly predicted data points:
Figure 7.4 – SHAP summary plot for the whole adult income dataset and incorrectly predicted data points
Now, we can extract the fraction of misclassified data points in each sex group, as follows:
X_WithPred.groupby(['Sex', 'Correct Prediction']).size().unstack(fill_value=0)
This will produce the...