CAFP: A Post-Processing Framework for Group Fairness via Counterfactual Model Averaging
Organizations: School of Civil Engineering, Universidad Politecnica de Madrid, Profesor Aranguren 3, Madrid, 28040, Spain. · Bain&Company, Velazquez, Madrid, 28006, Spain.
Abstract
Ensuring fairness in machine learning predictions is a critical challenge, especially when models are deployed in sensitive domains such as credit scoring, healthcare, and criminal justice. While many fairness interventions rely on data preprocessing or algorithmic constraints during training, these approaches often require full control over the model architecture and access to protected attribute information, which may not be feasible in real-world systems. In this paper, we propose Counterfactual Averaging for Fair Predictions (CAFP), a model-agnostic post-processing method that mitigates unfair influence from protected attributes without retraining or modifying the original classifier. CAFP operates by generating counterfactual versions of each input in which the sensitive attribute is flipped, and then averaging the model's predictions across factual and counterfactual instances. We provide a theoretical analysis of CAFP, showing that it eliminates direct dependence on the protected attribute, reduces mutual information between predictions and sensitive attributes, and provably bounds the distortion introduced relative to the original model. Under mild assumptions, we further show that CAFP achieves perfect demographic parity and reduces the equalized odds gap by at least half the average counterfactual bias.
Figures & tables
| Method | Fairness Type | Access to Model Internals | Uses Protected Attribute at Test Time | Retraining Required | Theoretical Guarantees |
|---|---|---|---|---|---|
| Equalized Odds Post-processing Hardt et al. (2016) | Group (EO) | No | Yes | No | Partial |
| Reject Option Classification Kamiran et al. (2012) | Group (DP, EO) | No | Yes | No | No |
| Calibrated Equalized Odds Pleiss et al. (2017) | Group (EO) | No | Yes | No | Partial |
| FairBatch Roh et al. (2021) | Group (DP, EO) | Yes | Yes | Yes | No |
| Counterfactual Equalized Odds Mishler et al. (2021) | Counterfactual | No | Yes | No | Yes |
| Path-specific Fairness Chiappa (2019) | Counterfactual (Path-based) | Yes | Yes | Yes | Yes |
| Property | Guarantee |
|---|---|
| Attribute Independence | If depends on only directly and , then is independent of : |
| Bounded Distortion | The absolute difference between the original and CAFP prediction is half the counterfactual bias: |
| The expected distortion is similarly bounded: | |
| Model | Acc. | 95% CI | SD |
|---|---|---|---|
| LR | 0.8464 | [0.8457, 0.8471] | 0.0035 |
| LR + Eq.Odds | 0.8185 | [0.8176, 0.8194] | 0.0044 |
| LR + R. O. | 0.7836 | [0.7807, 0.7866] | 0.0148 |
| LR + CAFP | 0.8432 | [0.8425, 0.8440] | 0.0037 |
| RF | 0.8411 | [0.8404, 0.8418] | 0.0036 |
| RF + Eq.Odds | 0.8138 | [0.8130, 0.8145] | 0.0038 |
| Model | AOD | 95% CI | SD |
|---|---|---|---|
| LR | -0.0961 | [-0.0990, -0.0933] | 0.0142 |
| LR + Eq.Odds | -0.0019 | [-0.0057, 0.0019] | 0.0192 |
| LR + R. O. | 0.1048 | [0.1020, 0.1077] | 0.0145 |
| LR + CAFP | 0.0075 | [0.0047, 0.0104] | 0.0143 |
| RF | -0.0847 | [-0.0879, -0.0816] | 0.0159 |
| RF + Eq.Odds | -0.0025 | [-0.0067, 0.0017] | 0.0213 |
| Model | DPD | 95% CI | SD |
|---|---|---|---|
| LR | -0.1868 | [-0.1882, -0.1854] | 0.0071 |
| LR + Eq.Odds | -0.0909 | [-0.0928, -0.0889] | 0.0097 |
| LR + R. O. | -0.0461 | [-0.0488, -0.0435] | 0.0134 |
| LR + CAFP | -0.1157 | [-0.1174, -0.1140] | 0.0085 |
| RF | -0.1928 | [-0.1944, -0.1912] | 0.0083 |
| RF + Eq.Odds | -0.1928 | [-0.1944, -0.1912] | 0.0083 |
| Model | Acc. | 95% CI | SD |
|---|---|---|---|
| LR | 0.6662 | [0.6629, 0.6695] | 0.014 |
| LR + Eq.Odds | 0.6200 | [0.6166, 0.6233] | 0.017 |
| LR + R. O. | 0.6539 | [0.6506, 0.6572] | 0.017 |
| LR + CAFP | 0.6653 | [0.6627, 0.6679] | 0.013 |
| RF | 0.6616 | [0.6589, 0.6644] | 0.014 |
| RF + Eq.Odds | 0.6225 | [0.6176, 0.6274] | 0.025 |
| Model | AOD | 95% CI | SD |
|---|---|---|---|
| LR | -0.2034 | [-0.2119, -0.1948] | 0.0431 |
| LR + Eq.Odds | -0.0017 | [-0.0117, 0.0083] | 0.0503 |
| LR + R. O. | 0.0123 | [-0.0018, 0.0264] | 0.0709 |
| LR + CAFP | -0.1305 | [-0.1372, -0.1238] | 0.0337 |
| RF | -0.1491 | [-0.1607, -0.1374] | 0.0587 |
| RF + Eq.Odds | 0.0047 | [-0.0049, 0.0143] | 0.0484 |
| Model | DPD | 95% CI | SD |
|---|---|---|---|
| LR | -0.2356 | [-0.2436, -0.2276] | 0.0403 |
| LR + Eq.Odds | -0.0329 | [-0.0423, -0.0236] | 0.0473 |
| LR + R. O. | -0.0220 | [-0.0356, -0.0084] | 0.0686 |
| LR + CAFP | -0.1631 | [-0.1692, -0.1570] | 0.0308 |
| RF | -0.1825 | [-0.1933, -0.1718] | 0.0542 |
| RF + Eq.Odds | -0.0273 | [-0.0367, -0.0178] | 0.0476 |
| Model | Acc. | 95% CI | SD |
|---|---|---|---|
| LR | 0.7415 | [0.7359, 0.7471] | 0.0284 |
| LR + Eq.Odds | 0.7189 | [0.7111, 0.7266] | 0.0390 |
| LR + R. O. | 0.6842 | [0.6754, 0.6929] | 0.0440 |
| LR + CAFP | 0.7379 | [0.7321, 0.7438] | 0.0293 |
| RF | 0.7547 | [0.7495, 0.7599] | 0.0265 |
| RF + Eq.Odds | 0.7390 | [0.7331, 0.7449] | 0.0298 |
| Model | AOD | 95% CI | SD |
|---|---|---|---|
| LR | -0.0961 | [-0.1142, -0.0779] | 0.0915 |
| LR + Eq.Odds | -0.0139 | [-0.0323, 0.0045] | 0.0929 |
| LR + R. O. | 0.0248 | [0.0037, 0.0460] | 0.1067 |
| LR + CAFP | -0.0324 | [-0.0480, -0.0169] | 0.0786 |
| RF | -0.0437 | [-0.0580, -0.0293] | 0.0724 |
| RF + Eq.Odds | -0.0027 | [-0.0210, 0.0156] | 0.0923 |
| Model | DPD | 95% CI | SD |
|---|---|---|---|
| LR | -0.1068 | [-0.1228, -0.0908] | 0.0806 |
| LR + Eq.Odds | -0.0289 | [-0.0452, -0.0126] | 0.0824 |
| LR + R. O. | 0.0055 | [-0.0159, 0.0269] | 0.1077 |
| LR + CAFP | -0.0505 | [-0.0647, -0.0364] | 0.0713 |
| RF | -0.0599 | [-0.0719, -0.0480] | 0.0603 |
| RF + Eq.Odds | -0.0217 | [-0.0364, -0.0070] | 0.0740 |
| Prediction Type | Accuracy | DPD | AOD |
|---|---|---|---|
| Factual | 0.8464 | -0.1868 | -0.0961 |
| Counterfactual | |||
| 0.8463 | -0.1775 | -0.0912 | |
| CAFP | 0.8432 | -0.1157 | 0.0075 |
Explore similar work
Tuning Derivatives for Causal Fairness in Machine Learning
Do Fair Models Reason Fairly? Counterfactual Explanation Consistency for Procedural Fairness in Credit Decisions
hidden procedural bias'' missed by standard fairness metrics and algorithms. We propose Counterfactual Explanation Consistency (CEC), a framework that detects and mitigates this bias by aligning feature attributions between individuals and their counterfactual counterparts. Key contributions include a nearest-neighbor counterfactual generation method, a modified baseline for integrated gradient comparisons, an individual-level procedural fairness metric, and a corresponding training loss. We introduce a taxonomy identifying Regime B'' (same outcome, different reasoning) as a critical blind spot. Experiments on synthetic data, German Credit, Adult Income, and HMDA mortgage data demonstrate that outcome-fair baselines exhibit substantial hidden bias, while CEC substantially reduces it with modest utility cost.