SlowGuess/NeurIPS_2023_OCR huggingface dataset:
[1] A. Artelt and B. Hammer. "Even if ..." - Diverse Semifactual Explanations of Reject. In 2022 IEEE Symposium Series on Computational Intelligence (SSCI), pages 854-859, 2022.
[2] A. Artelt, R. Visser, and B. Hammer. “i do not know! but why?”—local model-agnostic example-based explanations of reject. Neurocomputing, 558:126722, 2023.
[3] S. Aryal and M. T. Keane. Even if explanations: Prior work, desiderata & benchmarks for semi-factual xai. *IJCAI*, 2023.
[4] S. Bach, A. Binder, G. Montavon, F. Klauschen, K.-R. Müller, and W. Samek. On pixel-wise explanations for non-linear classifier decisions by layer-wise relevance propagation. PloS one, 10(7), 2015.
[5] M. Barenstein. Propublica's COMPAS Data Revisited. arXiv preprint arXiv:1906.04711, 2019.
[6] S. Barker. Even, still and counterfactuals. Linguistics and Philosophy, 14(1):1-38, 1991.
[7] M. Benetton, P. Bracke, and N. Garbarino. Down payment and mortgage rates: evidence from equity loans. 2018.
[8] J. Bennett. Even if. Linguistics and Philosophy, 5(3):403-418, 1982.
[9] D. S. Boninger, F. Gleicher, and A. Strathman. Counterfactual thinking: From what might have been to what may be. Journal of personality and social psychology, 67(2):297, 1994.
[10] S. Boyd and L. Vandenberghe. Convex Optimization. Cambridge university press, 2004.
[11] Breast Cancer Surveillance Consortium. "data collection and sharing was supported by the national cancer institute-funded breast cancer surveillance consortium (hhsn261201100031c)". https://www.bcsc-research.org/data/rfdataset/risk-estimation-dataset-download, 2022.
[12] N. Carlini and D. Wagner. Towards Evaluating the Robustness of Neural Networks. In 2017 IEEE Symposium on Security and Privacy (sp), pages 39-57. IEEE, 2017.
[13] J. Cohen. Statistical Power Analysis. Current Directions in Psychological Science, 1(3):98-101, 1992.
[14] L. Cummins and D. Bridge. Kleor: A knowledge lite approach to explanation oriented retrieval. Computing and Informatics, 25(2-3):173-193, 2006.
[15] S. Dandl, G. Casalicchio, B. Bischl, and L. Bothmann. Interpretable Regional Descriptors: Hyperbox-Based Local Explanations, 2023.
[16] G. De Toni, B. Lepri, and A. Passerini. Synthesizing explainable counterfactual policies for algorithmic recourse with program synthesis. Machine Learning, pages 1-21, 2023.
[17] A. Dhurandhar, P.-Y. Chen, R. Luss, C.-C. Tu, P. Ting, K. Shanmugam, and P. Das. Explanations based on the missing: Towards contrastive explanations with pertinent negatives. In Advances in neural information processing systems, pages 592-603, 2018.
[18] R. Dominguez-Olmedo, A. H. Karimi, and B. Schölkopf. On the adversarial robustness of causal algorithmic recourse. In International Conference on Machine Learning, pages 5324-5342. PMLR, 2022.
[57] D. S. Watson, L. Gultchin, A. Taly, and L. Floridi. Local explanations via necessity and sufficiency: Unifying theory and practice. In Uncertainty in Artificial Intelligence, pages 1382-1392. PMLR, 2021.
[58] D. Whitley. A genetic algorithm tutorial. Statistics and computing, 4(2):65-85, 1994.
[59] Z. Xie, T. He, S. Tian, Y. Fu, J. Zhou, and D. Chen. Joint gaussian mixture model for versatile deep visual model explanation. Knowledge-Based Systems, 280:110989, 2023.
[60] R. Xin, C. Zhong, Z. Chen, T. Takagi, M. Seltzer, and C. Rudin. Exploring the whole rashomon set of sparse decision trees. arXiv preprint arXiv:2209.08040, 2022.
[61] M. Zhang and N. Hurley. Avoiding Monotony: Improving the Diversity of Recommendation Lists. In Proceedings of the 2008 ACM conference on Recommender systems, pages 123-130, 2008.
[62] Z. Zhao, D. Leake, X. Ye, and D. Crandall. Generating Counterfactual Images: Towards a C2C-VAE Approach. In Workshop Proceedings of the 30th International Conference on Case-Based Reasoning co-located with the 30th International Conference on Case-Based Reasoning (ICCBR 2022, 2022).
A Property Analysis
A.1 Proof of Lemma 3.3
Proof. We can rewrite  $\mathcal{J}$  to
$$
\mathcal {J} = \max  _ {a _ {1}, \dots , a _ {m} \in \mathcal {A}} \left\{\frac {1}{m} \sum_ {i = 1} ^ {m} P (\mathbf {x}, a _ {i}) G (\mathbf {x}, a _ {i}) + \frac {1}{m} \sum_ {i = 1} ^ {m} \min  _ {\lambda_ {i} \geq 0} \lambda_ {i} H (\mathbf {x}, a _ {i}) + \gamma R \left(\left\{\mathbb {S F} (\mathbf {x}, a _ {i}; \mathcal {M}) \right\} _ {i = 1} ^ {m}\right) \right\}. \tag {13}
$$
We derive the fact that, for any  $i$ ,
$$
\min  _ {\lambda_ {i} \geq 0} \lambda_ {i} R (\mathbf {x}, a _ {i}) = \left\{ \begin{array}{l l} - \infty & H (\mathbf {x}, a _ {i}) <   0 \\ 0 & \text {o t h e r w i s e} \end{array} \right.
$$
where  $-\infty$  comes from setting  $\lambda_{i} = \infty$  and 0 is obtained by setting  $\lambda_{p_i} = 0$ . By the linearity of summation, we can further derive
$$
\frac{1}{m}\sum_{i = 1}^{m}\min_{\lambda_{i}\geq 0}\lambda_{i}R(\mathbf{x},a_{i}) = \left\{ \begin{array}{ll} - \infty & \exists i,H(\mathbf{x},a_{i}) <   0\\ 0 & \text{otherwise} \end{array} \right..
$$
That is, if any constraint for the robustness is unsatisfied, the dual player will minimise the objective towards  $-\infty$ ; however, the primal player cannot optimise towards  $\infty$  given that the limit of the gain function and the diversity are finite. In other words, if the constraints are satisfied, the primal player can freely optimise the objective. Once  $H(\mathbf{x},a_{i})\geq 0,\forall a_{i}$  are satisfied, the objective becomes
$$
\begin{array}{l} \tilde {\mathcal {J}} := \max  _ {a _ {1}, \dots , a _ {m} \in \mathcal {A} ^ {+}} \frac {1}{m} \sum_ {i = 1} ^ {m} P (\mathbf {x}, a _ {i}) G (\mathbf {x}, a _ {i}) + \gamma R \left(\left\{\mathbb {S F} (\mathbf {x}, a _ {i}; \mathcal {M}) \right\} _ {i = 1} ^ {m}\right) \\ \geq \min  _ {a _ {1}, \dots , a _ {m} \in \mathcal {A} ^ {+}} \frac {1}{m} \sum_ {i = 1} ^ {m} P (\mathbf {x}, a _ {i}) G (\mathbf {x}, a _ {i}) + \gamma R \left(\left\{\mathbb {S F} (\mathbf {x}, a _ {i}; \mathcal {M}) \right\} _ {i = 1} ^ {m}\right) \tag {14} \\ > 0 \\ \end{array}
$$
as  $P(\mathbf{x},a_i) > 0$  and  $G(\mathbf{x},a_i)\geq 0$  for any  $a_{i}\in \mathcal{A}^{+}$ ; also,  $R\geq 0$  holds. We conclude the proof here.
A.2 A Probabilistic Relaxation of Robustness
Absolute robustness is difficult to guarantee, and common practice is to relax this via a probabilistic approach [26].
Assume there is a distribution over the sample space  $\mathcal{B}_s(\mathbf{x},a)$  denoted by  $\operatorname*{Pr}(\mathcal{B}_s(\mathbf{x},a))$ . We write  $\pmb{\theta} \sim \operatorname*{Pr}(\mathcal{B}_s(\mathbf{x},a))$  to indicate that  $\pmb{\theta}$  is sampled from the set  $\mathcal{B}_s(\mathbf{x},a)$  under the density  $\operatorname*{Pr}(\cdot)$ . Let  $\mathbb{E}[h(\pmb{\theta})|\mathbf{x},a]$  denote the expectation of  $\pmb{\theta}$  in this configuration. Hence, we modify Equation (8) to
$$
\mathbb {E} [ h (\boldsymbol {\theta}) | \mathbf {x}, a ] > \tilde {\psi}, \tag {15}
$$
where  $\tilde{\psi}$  is a function that adjusts the base score threshold  $\psi$ . It is crucial to have this threshold function in order to consider the variance of scores in the neighbor set. Particularly, we would like most neighbors to remain in a similarly "good" state, with low variance between them.
Moreover, we explicitly impose  $h(\mathbb{S}\mathbb{F}(\mathbf{x},a;\mathcal{M})) - \psi >0$ . It places a hard constraint to avoid the case in which the neighbors of the semifactual are robust, but the "semifactual" itself has crossed the decision boundary to become a counterfactual. Whilst somewhat unlikely, this situation is theoretically possible, and requires consideration. In this case,  $H$  is re-written as  $H_{p}$ , which represents a combination of (i) the probabilistic robustness, and (ii) the absolute robustness for the semifactual  $H_{a}$  such that:
$$
H _ {p} (\mathbf {x}, a) = \mathbb {E} [ h (\boldsymbol {\theta}) | \mathbf {x}, a ] - \tilde {\psi} \quad H _ {a} (\mathbf {x}, a) = h (\mathbb {S F} (\mathbf {x}, a; \mathcal {M})) - \psi . \tag {16}
$$
In practice,  $H_{p}$  is still non-trivial to solve. Monte Carlo (MC) sampling is a common strategy to apply here such that, by sampling a fixed sized batch  $\mathbf{B} = \{\pmb {\theta}:\pmb {\theta}\sim \operatorname *{Pr}(\mathcal{B}_s(\mathbf{x},a))\}$ ,
$$
H _ {p} (\mathbf {x}, a) = \mathbb {E} [ h (\boldsymbol {\theta}) | \mathbf {x}, a ] - \tilde {\psi} \approx (1 / | \mathbf {B} |) \sum_ {\boldsymbol {\theta} \in \mathbf {B}} h (\boldsymbol {\theta}) - \tilde {\psi}. \tag {17}
$$
This implies that we substitute an unbiased estimator for the population mean.
B Actionability Constraints
B.1 Non-Causal
Here we define the actionability constraints used in the various domains. It may be assumed that the direction features are allowed to change corresponds with positive gain. We use various sized "action sets" to fully test all algorithms in various setups. The German Credit data used 15 actionable features to be closely in line with Mothilal et al. [39] whom allowed all features to be mutable. However, we also used 7 on Lending Club, and 4 on Adult Census/Breast Cancer to test the algorithms in situations with smaller action spaces also for completeness.
We ordered categorical features in a sensible fashion to "direct" semifactual "even if" thinking, and when we say a categorical feature could decrease/increase, we are referring to this pre-defined order. If you are interested in the exact ordering, please refer to our code which contains all the lists, but here we summarise. In reality however, a user must specify their exact actionability constraints, what we have specified here is designed to be representative what is possible for the "average" individual.
B.1.1 German Credit Dataset
The continuous features used were 'duration', 'amount', 'age', the categorical ones were 'status', 'credit_history', 'purpose', 'savings', 'employment_duration', 'installment_rate', 'personal_status_sex', 'other_debtors', 'present_residence', 'property', 'other_installmentplans', 'housing', 'number Credits', 'job', 'people_liable', 'telephone', 'foreign-worker'. As actionable features for semifactual recourse, we considered the following:
- duration: We allowed people to increase the duration of their loan.
- amount: We allowed people to increase the amount of their loan.
status: We allowed people to move towards having lower status.
- credit_history: We allowed people to move towards e.g. having a late payment if their credit history was otherwise good.
- savings: This feature was allowed to decrease.
- employment_duration: This feature was allowed to decrease in case people wanted to e.g. start a new job.
- installment_rate: This feature was allowed to move towards lower payments.
- other_debtors: this feature was allowed to add another co-applicant.
- present_residence: This feature was allowed to move towards e.g. renting in case the user desired to do so whilst searching for a new house with their loan.
- property: this feature was allowed to move towards having no property in case the user desired to sell their house/car etc to help pay for e.g. a downpayment.
- other_installmentplans: This feature was allowed to add other installment plans.
- housing: this feature was allowed to move towards renting away from e.g. owning.
- number Credits: This feature was allowed to increase if the user desired to acquire more credit cards.
- job: this feature was allowed to decrease in case the individual desired to get a different, less demanding job within their institution, or indeed quite their job to e.g. start a business.
- people_liable: This feature was allowed to move towards more people being liable.
B.1.2 Lending Club
The continuous features used were 'loan_amnt', 'pub_rec_bankruptcies', 'annual_inc', 'dti', the categorical ones were 'emp_length', 'term', 'grade', 'home Ownership', 'purpose'. As actionable features for semifactual recourse, we considered the following:
- home Ownership: This feature was allowed to decrease towards e.g. renting.
- annual_inc: this feature was allowed to decrease if the person desired to e.g. work less hours.
- emp_length: This feature was allowed to decrease in case the individual desired to change careers.
- dti: dept to income ratio, this feature was allowed to increase.
- pub_rec_bankruptcies: This feature was allowed to increase in case the user decided they wanted to declare bankruptcy to e.g. try and keep some assets.
- loan_amnt: this feature was allowed to increase.
term: This feature was allowed to decrease.
B.1.3 Breast Cancer
The continuous features used were none, the categorical ones were 'agegrp', 'density', 'race', 'Hispanic', 'bmi', 'agefirst', 'nrelbc', 'brstproc', 'lastmamm', 'surgmeno', 'hrt'. As actionable features for semifactual recourse, we considered the following:
- bmi: This feature was allowed to move towards less healthy BMI levels in case the patient e.g. has hypothyroidism.
- brstproc: this feature was allowed to move towards having had a previous breast procedure in case the patient would like to do so or was advised.
-  $hrt$ : This feature was allowed to move towards starting HRT, in case a person may wish to alleviate synptoms of the menopause.
- agegrp: this feature was allowed to get older in case the individual would like to take no action confident that it would not lead to cancer in the next few years/decades.
B.2 Causal
In the causal setting, we allowed a user's age to increase a maximum of 5 years to mimic the motivating examples in the paper about a user having a bank loan accepted. In such a situation, the user may want to e.g. work less hours over the next 5 years whilst they repay the loan, and still have it accepted.
Next, we detail the direction features are allowed to change, and what direction corresponds to positive gain.
B.2.1 Adult Income Census
We use the features "sex", "age", "native-country", "marital-status", "education-num", "hours-per-week", which are the variables in the causal graph of Nabi & Shpitser [41]. We consider "age" and "hours-per-week" as actionable. We allow "age" to increase a maximum of five years, and "hours-per-week" to decrease.
For positive gain, we considered: Age, marital status, and education-num increasing corresponding to positive gain, and hours-per-week decreasing corresponding to positive gain. A persons sex was seen as neutral gain.
B.2.2 COMPAS
We use the features "age", "race", "sex" and "priors count", which are the variables in the causal graph of Nabi & Shpitser [41]. We consider "age" and "priors count" as actionable. As actionability constraints, we assume that both features are non-negative and can only be increase. Age specifically is only allowed to increase by 5 years for each individual.
For positive gain, we considered: Age and priors count increasing corresponding to positive gain. A persons sex and race was seen as neutral gain.
C Hyperparameter Choices
In this section, we discuss the hyperparameter specifications for the causal and non-causal cases respectively.
C.1 Non-Causal
Here we note the values for the hyperparameters used in our demonstrations. All were obtained though pilot grid-searches across each dataset. The hyperparameter choices are summarised in Table 1
Table 1: Hyperparameter Specifications
Data	λp	λs	γd	γp
German credit	30	10	1	1e-1
Lending Club	30	10	1	1e-1
Breast Cancer	10	10	10	1e-1
For S-GEN itself, we used the same hyperparameters everywhere outside of the above table. The number of generations spent searching for a solution was 20. The population size was fixed at  $\{12, 24, 48, 72, 96, 120\}$ , for diversity sizes of  $\{1, 2, 4, 6, 8, 10\}$ , respectively. The mutation rate was 0.05. The number of "elite" solutions passed on for each generation was 4. The probability of a crossover happening was 0.5. The number of Monte Carlo trials for each instance was 100. The continuous features were perturbed (in mutation or population initialization) by the output from sampling a standard normal distribution with standard deviation equal to the max actionable feature value, minus the min actionable feature value, multiplied by 0.05.
C.2 Causal
In our causal tests we chose  $\lambda$  as 1.0, and this was gradually decreased by a momentum of  $\eta = 0.9$  each iteration to put more emphases on the maximization of gain.
D Algorithm Pseudocode
Algorithm 1 S-GEN: Genetic Algorithm to Generate semifactual Recourse with Robustness and Diversity in a Non-Causal Model Agnostic Setting
Require: x the user feature   
Require:  $h(\cdot)$  the predictive model   
Require: m the expected number of suggestions   
Require: n the number of candidates,  $n > m$    
Ensure:  $\mathbf{R}_{SF}$  the set of semifactual(s)   
1: Sample  $n$  candidates  $\mathbf{D}\gets \{\pmb {\theta}_i\sim \mathcal{X}\}_{i = 1}^n$    
2: while the stopping criterion is not satisfied do   
3: Obtain the fitness scores f with respect to D   
4: Save the fittest  $\pmb {\theta}^{*}\in \mathbf{D}$  according to f   
5: Let D evolve by natural selection according to f, crossover, mutation, and elitism with  $\mathbf{x}^*$    
6: end while   
7: Collect the best m unique candidates from  $\{\pmb {\theta}\in \mathbf{D}:h(\pmb {\theta}) = h(\mathbf{x}) = 1\}$  to  $\mathbf{R}_{SF}$  , according to the corresponding fitness scores in f   
8: if  $|\mathbf{R}_{SF}| <   m$  then   
9: Complement  $\mathbf{R}_{SF}$  to m elements with  $\pmb{\theta}$  randomly drawn from  $\mathbf{R}_{SF}$    
10: end if
E Code
For our full code used please see:
https://github.com/EoinKenny/Semifactual_Recourse_Generation
The ability to reproduce the results is given.
Algorithm 2 S-GEN: Algorithm to Generate Robust & Diverse Causal semifactual Explanations for Differentiable Classifiers
Require: x the user feature vector   
Require:  $h(\cdot)$  the predictive model   
Require:  $\mathcal{M}$  the differentiable SCM   
Require:  $\epsilon$  the epsilon robustness   
Require:  $\eta$  the momentum parameter   
Require:  $\tau$  the learning rate   
Require: Proj(·) a projection function that ensures the action is actionable   
Ensure:  $\mathbf{R}_{SF}$  the set of semifactual(s)   
1:  $\mathbf{R}_{SF} \gets \emptyset$    
2:  $i \gets 0$    
3: for  $a \in \mathcal{A}$  do   
4: Move to next loop if the SF generated with the initial  $a$  does not satisfy the constraints.   
5:  $a_i \gets a$    
6: while not converged do   
7: Sample a batch of neighbors from  $\mathbb{B}_s(\mathbf{x}, a_i)$ , denoted by  $\mathbf{B}_i$    
8: if  $h(\mathbb{S}\mathbb{F}(\mathbf{x}, a_i; \mathcal{M})) = 0$  or  $h(\pmb{\theta}) = 0$ ,  $\exists \pmb{\theta} \in \mathbf{B}_i$  then break   
9: end if   
11:  $\mathcal{J}_i \gets -\lambda_i \mathcal{L}(h(\mathbb{S}\mathbb{F}(\mathbf{x}, a_i; \mathcal{M})), h(\mathbf{x})) - \sum_{\pmb{\theta}_i \in \mathcal{B}_i} \frac{\lambda_i}{|\mathbf{B}_i|} \mathcal{L}(h(\pmb{\theta}_i), h(\mathbf{x})) + \hat{P}(\mathbf{x}, a_i) \hat{G}(\mathbf{x}, a_i)$    
12:  $a_i \gets \mathrm{Proj}(a_i + \tau \nabla_{a_i} \mathcal{J}_i)$    
13:  $\lambda_i \gets \eta \lambda_i$    
14: end while   
15:  $\mathbf{R}_{SF} \gets \mathbf{R}_{SF} \cup \{\mathbb{S}\mathbb{F}(\mathbf{x}, a_i; \mathcal{M})\}$    
16:  $i \gets i + 1$    
17: if  $i \geq m$  then break   
18: end if   
19: end for
F Individual Dataset Results
The results are presented in Figure 4.
Figure 4: Results: The ability of S-GEN to create semifactuals is compared to DiCE* and PIECE*. Overall, S-GEN does the best, achieving significantly better results to both baselines on 11/16 tests. Moreover, S-GEN was only significantly worse than either baseline on a single test (i.e., plausibility on German Credit), with the remaining four tests being competitive between methods. Standard error bars are shown.
G.1 Non-Casual
DiCE Our modification to DiCE, starts by generating a counterfactual(s) for a query. Next, we use the algorithm again, but on the generated counterfactuals(s), to make them generate a second counterfactual, which goes back over the decision boundary. In effect, this generates a semifactual(s) for a query.
PIECE Second, we use the PIECE framework by Kenny and Keane [29], but apply it to tabular data. Following the authors, we divide the training data into two sets, the first corresponding to those predicted as the original class  $c$ , and the second to those predicted as the counterfactual class  $c'$ , these are again split into the respective features. Hence, if there are 2 classes, with 4 features, there are  $2 \times 4 = 8$  sets of data. These sets were then modeled using the best fit found for a Beta distribution on continuous features, and a simple Categorical distribution for categorical features. To generate a semifactual predicted as  $c$ , we take the probability of each feature value in the query using the models of the counterfactual class  $c'$ , and modify each to be its expected statistical value in  $c'$  one-by-one (from the lowest probability to the highest), until the next would take it over the decision boundary. In the case of continuous features, as done by Kenny and Keane [29], we take the probability as being the minimum of the two integrals either side of the feature value in the distribution. In the case the expected feature values lie outside the actionability range, we clip them to the closest value allowed.
DSER For Diverse Explanation of Reject [1] (DSER) we had to modify the technique in two main ways. Most notably, the techniques doesn't deal with categorical features, so to overcome this, we optimised treating all one hot encoded features as real-valued, and then projected each categorical feature onto its nearest value. Next, the method addresses diversity by iterating all different sets of possible features, in our domains this is computationally intractable. Hence, we optimise one semifactual at a time, each time pushing each solution as far as possible from those already found.
G.2 Causal
Karimi et al. (2021) The method by Karimi et al. [25] is a recourse method designed to minimise cost whilst traversing the decision boundary. To modify the technique, we simply stop the optimization when the next step would take it over the decision boundary.
Dominguez et al. (2022) The method by Dominguez et al. [18] is identical to Karimi et al. [25], but they add in a robustness component. Namely, they take an individual  $x$ , and solve an inner loss which means that an individual of distance  $\epsilon = 0.1$  (in our tests) close to  $x$ , with the same recourse given, will also achieve recourse. We simply keep the same optimization process, but aim to solve a different objective. The objective we solve is to move towards the decision boundary, but when the recourse option causes either  $x$  or the individual close to it to cross the decision boundary, we terminate the optimization one step prior to this.
H Computational Costs
All tests were run on a MacBook Pro, Apple M1 Pro, 16 GB. Re-running tests will take less than 1 day.
I User Study
Here we show our entire user study for complete transparency. We used the German Credit dataset, but converted the currency into U.S. dollars since it was given to U.S. citizens to complete.
Intro Brief
Thank you for clicking on this study!
Do no take this study on a mobile phone, the tables and images wont display correctly.
Please don't take this study if you did a similar one recently.
The study will take around 8mins.
You will be paid $12 per hour for your efforts.
Enter ID
Please Enter Your Prolific ID Here
You are going to be shown six situations in which a person either has a loan application approved, or rejected.
You will then be shown two different pieces of information for each situation that a bank clerk could tell the person.
You are then asked to rate how useful each of these are. That is, could the information possibly be useful in any way? Or is it not that useful?
Each situation has 4 "features".
Feature Explanation
Features Used in Decision
The four "features" used to decide if each person has their loan approved or rejected are:
1: Duration: Over how long the applicant wishes to pay back the loan.
2: Amount: How much are they asking to loan from the bank.
3: Savings: How much money does the applicant have saved.
4: Credit Cards: How many credit cards does the applicant have.
These are the only features the bank clerk uses to make decisions.
Click Next
Now, Please Practice On The Next Question