GradCFA: A Hybrid Gradient-Based Counterfactual and Feature Attribution Explanation Algorithm for Local Interpretation of Neural Networks
Organizations: Department of Computer and Information Sciences, Northumbria University, Newcastle, UK, NE1 8ST
Abstract
Explainable Artificial Intelligence (XAI) is increasingly essential as AI systems are deployed in critical fields such as healthcare and finance, offering transparency into AI-driven decisions. Two major XAI paradigms, counterfactual explanations (CFX) and feature attribution (FA), serve distinct roles in model interpretability. This study introduces GradCFA, a hybrid framework combining CFX and FA to improve interpretability by explicitly optimizing feasibility, plausibility, and diversity - key qualities often unbalanced in existing methods. Unlike most CFX research focused on binary classification, GradCFA extends to multi-class scenarios, supporting a wider range of applications. We evaluate GradCFA's validity, proximity, sparsity, plausibility, and diversity against state-of-the-art methods, including Wachter, DiCE, CARE for CFX, and SHAP for FA. Results show GradCFA effectively generates feasible, plausible, and diverse counterfactuals while offering valuable FA insights. By identifying influential features and validating their impact, GradCFA advances AI interpretability. The code for implementation of this work can be found at: https://github.com/jacob-ws/GradCFs .
Figures & tables
| Dataset | Training | Validation | Testing |
|---|---|---|---|
| Credit Approval | 0.88 | 0.86 | 0.82 |
| Obesity | 0.90 | 0.84 | 0.85 |
| Fetal Health | 0.92 | 0.93 | 0.91 |
| Ablation Study Combinations | GradCFA | Previous Work | Multi-Class | |||||||||||||||||
| GradCFA | 1 | 2 | 3 | 4 | 5 | 6 | 7 | W/o Pert. | W/o Pen. | Wachter | DiCE | CARE | 0 | 1 | 2 | 3 | 4 | 5 | 6 | |
| Credit Approval Dataset for Binary Classification | ||||||||||||||||||||
| Prox. | 0.15 | 0.14 | 0.12 | 0.19 | 0.16 | 0.16 | 0.13 | 0.23 | 0.23 | 0.21 | 0.03 | 0.12 | 0.18 | - | - | - | - | - | - | - |
| Spars | 0.18 | 0.19 | 0.16 | 0.21 | 0.20 | 0.20 | 0.17 | 0.25 | 0.27 | 0.24 | 0.10 | 0.28 | 0.56 | - | - | - | - | - | - | - |
| Plaus | 0.37 | 0.68 | 0.53 | 0.61 | 0.46 | 0.45 | 0.54 | 0.42 | 0.51 | 0.45 | 0.56 | 0.51 | 0.47 | - | - | - | - | - | - | - |
| Div | 0.96 | 0.86 | 0.72 | 0.82 | 0.92 | 0.80 | 0.88 | 0.94 | 0.91 | 0.92 | 0.35 | 0.84 | 0.68 | - | - | - | - | - | - | - |
| Feature | Query | Counterfactual Values | ||||
|---|---|---|---|---|---|---|
| Age | 34.14 | 28.55 | 33.44 | 35.34 | 37.26 | 46.75 |
| Debt | 2.75 | 4.2 | 3.9 | 3.4 | 5.1 | 8.0 |
| YE | 2.5 | 3.28 | 3.93 | 2.94 | 3.54 | 2.5 |
| Income | 200.01 | 199.00 | 200.00 | 205.00 | 105.00 | 195.00 |
| Gender | 1 | 1 | 1 | 1 | 0 | 0 |
| MS | 1 | 1 | 1 | 1 | 1 | 1 |
| Feature | Query | Counterfactual Values | ||||
|---|---|---|---|---|---|---|
| Age | 19.0 | 20.0 | 19.0 | 21.0 | 23.0 | 22.0 |
| Height | 1.75 | 1.68 | 1.72 | 1.65 | 1.66 | 1.65 |
| Weight | 100.0 | 53.4 | 51.9 | 62.3 | 51.6 | 61.8 |
| FVFC | 2.0 | 1.9 | 1.9 | 1.9 | 2.0 | 2.0 |
| NCP | 3.0 | 3.0 | 3.0 | 2.9 | 3.0 | 3.0 |
| CH2O | 2.0 | 1.9 | 2.0 | 2.0 | 2.0 | 2.0 |
| Feature | Query | Counterfactual Values | ||||
|---|---|---|---|---|---|---|
| LBE | 125.0 | 128.9 | 148.0 | 128.3 | 141.5 | 142.2 |
| LB | 125.0 | 132.8 | 124.9 | 124.8 | 132.1 | 118.2 |
| AC | 10.0 | 5.1 | 2.8 | 0.1 | 5.5 | 2.2 |
| FM | -4.6e-11 | -3e-11 | -7.4e-11 | -1.1e-11 | 1.5e-11 | 1.2e-11 |
| UC | 2.3e-10 | 3e-10 | -1.2e-10 | 4.3e-10 | -4e-10 | -2e-10 |
| ASTV | 41.0 | 56.9 | 55.1 | 52.6 | 44.2 | 41.0 |
| Feature | Val. | Prox. | Spars. | Plaus. | Div. |
|---|---|---|---|---|---|
| Fixed | |||||
| PriorDefault | 0.37 | - | - | - | - |
| Income | 0.54 | 0.26 | 0.24 | 0.87 | 0.82 |
| Industry | 0.62 | 0.25 | 0.22 | 0.61 | 0.86 |
| CreditScore | 0.65 | 0.24 | 0.24 | 0.50 | 0.88 |
| BankCustomer | 0.67 | 0.23 | 0.23 | 0.46 | 0.88 |
| Feature | Val. | Prox. | Spars. | Plaus. | Div. |
| Fixed | |||||
| Weight | 0.18 | - | - | - | - |
| MTRANS | 0.52 | 0.33 | 0.42 | 0.62 | 0.71 |
| SMOKE | 0.57 | 0.29 | 0.37 | 0.67 | 0.75 |
| CALC | 0.59 | 0.28 | 0.35 | 0.61 | 0.76 |
| CAEC | 0.61 | 0.28 | 0.30 | 0.55 | 0.78 |
| Feature | Val. | Prox. | Spars. | Plaus. | Div. |
| Fixed | |||||
| D | 0.24 | - | - | - | - |
| A | 0.45 | - | - | - | - |
| AD | 0.51 | 0.48 | 0.49 | 0.77 | 0.79 |
| B | 0.53 | 0.47 | 0.47 | 0.71 | 0.77 |
| C | 0.56 | 0.47 | 0.46 | 0.69 | 0.80 |
Counterfactual Explanations
Counterfactual explanations show how changing an input could alter a model’s prediction, supporting model understanding, auditing, and actionable recourse.
See all 117 papers