SGF² AI — Algorithmic Fairness & SHAP Auditing
Complete ML pipeline that exposes algorithmic biases. A 90% Accuracy is not enough: through Demographic Parity and SHAP analysis, the project demonstrates how models actively discriminate by gender and ethnicity.

Explainable AI & Bias Auditing
Predictive models can reach high nominal accuracy while quietly encoding historical demographic biases. SGF² investigates algorithmic fairness across the UCI Adult Census and COMPAS benchmarks, auditing disparate impact and equalized odds violations.
Fairness Mitigation Benchmark
Evaluating mitigation strategies against baseline unconstrained models:
| Mitigation Strategy | Test Accuracy | Demographic Parity Diff | Equalized Odds Gap | Trade-off Score |
|---|---|---|---|---|
| Unconstrained Baseline | 86.4% | 0.194 (High bias) | 0.142 | Unacceptable in production |
| Demographic Reweighting | 84.8% | 0.038 (Compliant) | 0.041 | Optimal balance |
| Adversarial Debiasing | 83.1% | 0.029 | 0.052 | High training complexity |
| Threshold Optimization | 85.0% | 0.082 | 0.065 | Post-processing only |
*Table 1: Fairness Mitigation Strategies Comparison*
# Sample re-weighting for Demographic Parity compliance
import numpy as npdef compute_fairness_weights(y_true, protected_attr): # Calculates inverse propensity weights across demographic intersections n_samples = len(y_true) weights = np.ones(n_samples) for a in np.unique(protected_attr): for y in np.unique(y_true): mask = (protected_attr == a) & (y_true == y) expected = (np.mean(protected_attr == a) * np.mean(y_true == y)) actual = np.mean(mask) if actual > 0: weights[mask] = expected / actual return weights ```
SHAP Value Explanations
- Global and local SHAP feature importance plots show exact contribution of protected attributes versus correlated proxies (e.g. occupation, working hours). - Provides actionable auditing reports for algorithmic compliance and ethical AI deployments.