SlowGuess/NeurIPS_2023_OCR huggingface dataset:
[34] Florian Tramer, Vaggelis Atlidakis, Roxana Geambasu, Daniel Hsu, Jean-Pierre Hubaux, Mathias Humbert, Ari Juels, and Huang Lin. Fairtest: Discovering unwarranted associations in data-driven applications. In 2017 IEEE European Symposium on Security and Privacy (EuroS&P), pages 401-416. IEEE, 2017.
[35] Berk Ustun, Alexander Spangher, and Yang Liu. Actionable recourse in linear classification. In Proceedings of the conference on fairness, accountability, and transparency, pages 10-19, 2019.
[36] Suresh Venkatasubramanian and Mark Alfano. The philosophical basis of algorithmic recourse. In Proceedings of the 2020 conference on fairness, accountability, and transparency, pages 284-293, 2020.
[37] Julius von Kugelgen, Amir-Hossein Karimi, Umg Bhatt, Isabel Valera, Adrian Weller, and Bernhard Schölkopf. On the fairness of causal algorithmic recourse. In AAAI, pages 9584-9594. AAAI Press, 2022.
[38] Sandra Wachter, Brent Mittelstadt, and Chris Russell. Counterfactual explanations without opening the black box: Automated decisions and the gdpr. Harv. JL & Tech., 31:841, 2017.
[39] Muhammad Bilal Zafar, Isabel Valera, Manuel Gomez Rodriguez, and Krishna P Gummadi. Fairness beyond disparate treatment & disparate impact: Learning classification without disparate mistreatment. In Proceedings of the 26th international conference on world wide web, pages 1171-1180, 2017.
This is the appendix to the main paper, discussing how numerical attributes are handled (Appendix A), describing in detail the experimental setting (Appendix B), presenting the datasets (Appendix C), providing additional results (Appendix D) and discussion (Appendix E), quantitatively comparing the various fairness notions (Appendix F) and describing in detail limitations and usage guidelines of our framework to avoid malicious usage (Appendix G).
A Discussion about Numerical Attributes
FACTS works for datasets and models with numerical or continuous features; in fact it works with any mixture of categorical and numerical features. The core idea is that numerical attributes are binned. These bins are used to define subpopulations, e.g., people in the salary range  $[40K, 50K]$ , and actions, e.g., make salary  $[50K, 60K]$ . So the action "if salary is  $[40K, 50K]$ , make salary  $[50K, 60K]$ " means that all individuals within that salary range are mapped to their counterfactuals where their salaries are increased by  $10K$ .
Binning is necessary when defining subpopulations, as we want to explore the entire feature space and present conclusions in a manner that is easily understandable by humans, e.g., "there is unfairness against females when married=no, salary in  $[40K, 50K]$ ".
Binning is also necessary when considering actions over numerical attributes. As explained, binning of granularity  $10K$  for salary means that we consider actions that change salary by  $\pm 10K$ ,  $\pm 20K$ , etc. We emphasize that because the number of actions/counterfactuals is infinite, all methods that work with model-agnostic counterfactual-based explanations (e.g., FACTS, and [31, 25]) have to explore only a small set of actions.
Our goal is to approximate the effectiveness-cost distribution, which means we should consider as many actions as possible. Therefore, on the one hand, binning for actions should rather be fine-grained, while on the other hand, binning for subpopulations should be moderately coarse-grained so as to draw conclusions that concern many affected individuals.
With that said, the binning granularity for actions and subpopulations can differ. For example consider bins of length  $10K$  for subpopulations and  $5K$  for actions. An action, "if salary is  $[40K, 50K]$ , make salary  $[55K, 60K]$  means that individuals with salary in  $[40K, 45K]$  increase their salary by  $15K$ , and individuals with salary in  $[45K, 50K]$  increase their salary by  $10K$ .
B Experimental Setting
Models To conduct our experiments, we have used the Logistic Regression $^2$  classification model, where we use the default implementation of the python package scikit-learn $^3$ . This model corresponds to the black box one that our framework audits in terms of fairness of recourse.
Train-Test Split For our experiments, all datasets are split into training and test sets with proportions  $70\%$  and  $30\%$ , respectively. Both shuffling of the data and stratification based on the labels were employed. Our results can be reproduced using the random seed value 131313 in the data split function (train_test_split<sup>4</sup> from the python package scikit-learn). FACTS is deployed solely on the test set.
Frequent Itemset Mining The set of subgroups and the set of actions are generated by executing the fp-growth<sup>5</sup> algorithm for frequent itemset mining. We used the implementation in the Python package mlxtend<sup>6</sup>. We deploy fp-growth with support threshold 1%, i.e., we require the return of subgroups and actions with at least 1% frequency in the respective populations. Recall that subgroups are derived from the affected populations  $D_{0}$  and  $D_{1}$  and actions are derived from the unaffected population.
Effectiveness and Budgets As we have stated in Section 2 of our main paper, the metrics Equal Choice for Recourse and Equal Cost of Effectiveness require the definition of a target effectiveness level  $\phi$ , while the metric Equal Effectiveness within Budget requires the definition of a target cost level (or budget)  $c$ .
Regarding the metrics that require the definition of an effectiveness level  $\phi$ , we used two different values arbitrarily, i.e., a relatively low effectiveness level of  $\phi = 30\%$  and a relatively high effectiveness level of  $\phi = 70\%$ .
For the estimation of budget-level values  $c$  we followed a more elaborate procedure. Specifically,
1. Compute the Equal Cost of Effectiveness (micro definition) with a target effectiveness level of  $\phi = 50\%$  to calculate, for all subgroups  $G$ , the minimum cost required to flip the prediction for at least  $50\%$  of both  $G_0$  and  $G_1$ .
2. Gather all such minimum costs of step 1 in an array.
3. Choose budget values as percentiles of this set of cost values. We have chosen the  $30\%$ ,  $60\%$  and  $90\%$  percentiles arbitrarily.
Cost Functions Our implementation allows the user to define any cost function based on their domain knowledge and requirements. For evaluation and demonstration purposes, we implement an indicative set of cost functions, according to which, the cost of a change of a feature value  $v$  to the value  $v'$  is defined as follows:
1. Numerical features:  $|norm(v) - norm(v')|$ , where norm is a function that normalizes values to [0, 1].
2. Categorical features: 1 if  $v \neq v'$ , and 0 otherwise.
3. Ordinal features:  $|pos(v) - pos(v')|$ , where  $pos$  is a function that provides the order for each value.
Additionally to the above costs, the user is able to define a feature-specific weight that indicates the difficulty of changing the given feature through an action. Thus, for each dataset, the cost of actions can be simply determined by specifying the numerical, categorical, and ordinal features, as well as the weights for each feature.
$^{2}$ https://scikit-learn.org/stable/modules/generated/sklearn.linear_model. LogisticRegression.html  
 $^{3}$ https://scikit-learn.org/stable/index.html  
 $^{4}$ https://scikit-learn.org/stable/modules/generated/sklearn.model_selection.train_test_split.html  
 $^{5}$ https://rasbt.github.io/mlxtend/user_guide/frequent-patterns/fpgrowth/  
 $^{6}$ https://github.com/rasbt/mlxtend
Feasibility Apart from the cost of actions, we also take care of some obvious unfeasible actions such as that the age and education features can not be reduced and actions should not lead to unknown or missing values.
Compute resources Experiments were run on commodity hardware (AMD Ryzen 5 5600H processor, 8GB RAM). On the software side, all experiments were run in an isolated conda environment using Python 3.9.16.
C Datasets Description
We have used five datasets in our experimental evaluation; the main paper presented results only on the first. For each dataset, we provide details about the preprocessing procedure, specify feature types, and list the cost feature weights applied.
C.1 Adult
We have generated CSCs in the Adult dataset using two different features as protected attributes, i.e., 'sex', and 'race'. The assessment of bias for each protected attribute is done separately. The results for 'sex' as the protected attribute are presented in the main paper. Before we present our results for race as the protected attribute, we briefly discuss the preprocessing procedures and feature weights used for the adult dataset.
Preprocessing We removed the features 'fnlwgt' and 'education' and any rows with unknown values. The 'hours-per-week' and 'age' features have been discretized into 5 bins each.
Features All features have been treated as categorical, except for 'capital-gain' and 'capital-loss', which are numeric, and 'education-num' and 'hours-per-week', which we treat as ordinal. The feature weights that we used for the cost function are presented in Table 2. We need to remind here that this comprises only an indicative weight assignment to serve our experimentation; the weight below try to capture the notion of how feasible/actionable it is to perform a change to a specific feature.
Table 2: Cost Feature Weights for Adult
feature name	weight value	feature name	weight value
native-country	4	Workclass	2
marital-status	5	hours-per-week	2
relationship	5	capital-gain	1
age	10	capital-loss	1
occupation	4	education-num	3
C.2 COMPAS
We have generated CSCs in the COMPAS dataset for race as the protected attribute. Apart from our results, we provide some brief information regarding preprocessing procedures and the cost feature weights for the COMPAS dataset.
Preprocessing We discard the features 'age' and 'c charge desc'. The 'priors_count' feature has been discretized into 5 bins: [-0.1,1), [1, 5) [5, 10) [10, 15) and [15, 38), while trying to keep the frequencies of each bin approximately equal (the distribution of values is highly asymmetric so this is not possible with the direct use of e.g., pandas . qcut $^9$ ).
Features We treat the features 'juv_fel_count', 'juv_misd_count', 'juv_other_count' as numerical and the rest as categorical. The feature weights used for the cost function are shown in Table 3.
C.3 SSL
We have generated CSCs in the SSL dataset<sup>10</sup> for race as the protected attribute. Before we move to our results, we discuss briefly preprocessing procedures and feature weights applied in the SSL dataset.
$^7$ https://raw.githubusercontent.com/columbia/fairtest/master/data/adult/adult.csv
$^{8}$ https://aif360.readthedocs.io/en/latest/modules/generated/aif360.sklearn.
datasetsfetch_compas.html
$^{9}$ https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.qcut.html
$^{10}$ https://raw.githubusercontent.com/samuel-yeom/fliptest/master/exact-ot/chicago-ssl-clean.csv
Table 3: Cost Feature Weights for COMPAS
feature name	weight value
age_cat	10
juv_fel_count	1
juv_fel_count	1
juv_other_count	1
priors_count	1
c_chargedegree	1
Preprocessing We remove all rows with missing values ('U' or 'X') from the dataset. We also discretize the feature 'PREDICTOR RAT TREND IN CRIMINAL ACTIVITY' into 6 bins. Finally, since the target labels are values between 0 and 500, we 'binarize' them by assuming values above 344 to be positively impacted and below 345 negatively impacted (following the principles used in [3].
Features In this dataset, we treat all features as numerical (apart from the protected race feature). Table 4 presents the feature weights used for the cost function.
Table 4: Cost Feature Weights for SSL
feature name	weight value
PREDICTOR RAT AGE AT LATEST ARREST	10
PREDICTOR RAT VICTIM SHOOTING INCIDENTS	1
PREDICTOR RAT VICTIM BATTERY OR ASSAULT	1
PREDICTOR RAT ARRESTS VIOLENT OFFENSES	1
PREDICTOR RAT GANG AFFILIATION	1
PREDICTOR RAT NARCOTIC ARRESTS	1
PREDICTOR RAT TREND IN CRIMINAL ACTIVITY	1
PREDICTOR RAT UUW ARRESTS	1
C.4 Ad Campaign
We have generated CSCs in the Ad Campaign dataset<sup>11</sup> for gender as the protected attribute.
Preprocessing We decided not to remove missing values, since they represent the vast majority of values for all features. However, we did not allow actions that lead to missing values in the CSCs representation.
Table 5: The assigned weights for each feature used in the calculation of the cost function in the Ad Campaign dataset
feature name	weight value
religion	5
politics	2
parents	3
age	10
income	3
area	2
college_educated	3
homeowner	1
<sup>11</sup>https://developer.ibm.com/exchanges/data/all/bias-in-advertising/
Features In this dataset, we treat all features, apart from the protected one, as categorical. The feature weights used for the cost function are shown in Table 5.
C.5 Credit
We have generated CSCs in the Statlog (German Credit) dataset<sup>12</sup> for sex as the protected attribute.
Preprocessing We performed only minimal preprocessing. This involved adding column names, based on the provided documentation, since they are not automatically included in the dataset. We also simplified the values of the 'sex' feature into 'Male' and 'Female', from their original, more complex form (which originally was included in a coded version of the combination of personal status and sex). Finally, we changed the labels from  $\{1,2\}$  to  $\{0,1\}$ .
Features The features 'duration', 'credit', 'rate', 'residence', 'age', 'cards', and 'liables' are treated as numerical, while the remaining features are regarded as categorical. We assigned the same weight value, specifically 1, for all features in the dataset when calculating the cost function, as depicted in Table 6.
Table 6: The assigned weights for each feature used in the calculation of the cost function in the German Credit dataset
feature name	weight value
status	1
duration	1
hist	1
purpose	1
credit	1
savings	1
empl	1
rate	1
sex	1
others	1
residence	1
property	1
age	1
plans	1
housing	1
cards	1
job	1
liables	1
telephone	1
foreign	1
<sup>12</sup>https://archive.ics.uci.edu/dataset/144/statlog+german+credit+data
This section repeats the experiment described in the main paper, concerning the Adult dataset with 'gender' as the protected attribute (Section 4), in three other cases. Specifically, we provide three subgroups that were ranked first in terms of unfairness according to a metric, highlight why they were marked as unfair by our framework, and summarize their unfairness scores according to the rest of the metrics.
D.1 Results for Adult with race as the protected attribute
We showcase three prevalent subgroups for which the rankings assigned by different fairness definitions truly yield different kinds of information. This is showcased in Table 7. We once again note that the results presented here are for 'race' as a protected attribute, while the corresponding results for 'gender' are presented in Section 4 of the main paper.
Table 7: Example of three unfair subgroups in Adult (protected attribute race)
Subgroup 1	Subgroup 2	Subgroup 3
rank	bias against	unfairness score	rank	bias against	unfairness score	rank	bias against	unfairness score
Equal Effectiveness	Fair	Fair	0.0	3047.0	Non-White	0.115	1682.0	Non-White	0.162
Equal Choice for Recourse (φ = 0.3)	1	Non-White	10.0	10.0	Non-White	1.0	Fair	Fair	0.0
Equal Choice for Recourse (φ = 0.7)	Fair	Fair	0.0	Fair	Fair	0.0	Fair	Fair	0.0
Equal Effectiveness within Budget (c = 1.15)	Fair	Fair	0.0	Fair	Fair	0.0	Fair	Fair	0.0
Equal Effectiveness within Budget (c = 10.0)	303.0	Non-White	0.242	2201.0	Non-White	0.115	4035.0	Non-White	0.071
Equal Effectiveness within Budget (c = 21.0)	Fair	Fair	0.0	2978.0	Non-White	0.115	1663.0	Non-White	0.162
Equal Cost of Effectiveness (φ = 0.3)	18.0	Non-White	0.15	1	Non-White	inf	Fair	Fair	0.0
Equal Cost of Effectiveness (φ = 0.7)	Fair	Fair	0.0	Fair	Fair	0.0	Fair	Fair	0.0
Fair Effectiveness-Cost Trade-Off	909.0	Non-White	0.242	4597.0	Non-White	0.115	2644.0	Non-White	0.162
Equal (Conditional) Mean Recourse	5897.0	White	0.021	5309.0	White	0.047	1	Non-White	inf
In Figure 4 we present the Comparative Subgroup Counterfactual representation for the subgroups of Table 7 that corresponds to the fairness metric for which each subgroup presents the minimum rank.
These results are in line with the findings reported in the main paper (Section 4), on the same dataset (Adult), but on a different protected attribute (race instead of gender). Subgroups ranked first (highly unfair) with respect to a specific definition, are ranked much lower or even considered as fair according to most of the remaining definitions. This serves as an indication of the utility of the different fairness definitions, which is further strengthened by the diversity of the respective CSCs of Table 7. For example, the Subgroup 1 CSC (ranked first Equal Choice for Recourse  $(\phi = 0.3)$ ), demonstrates unfairness by contradicting a plethora of actions for the "White" protected subgroup, as opposed to much fewer actions for the "Non-White" protected subgroup. For Subgroup 2, a much more concise representation is provided, tied to the respective definition (Equal Cost of Effectiveness  $(\phi = 0.3)$ ): no recourses are identified for the desired percentage of the "Non-White" unfavored population, as opposed to the "White" unfavored population.
D.2 Results for COMPAS
We present some ranking statistics for three interesting subgroups for all fairness definitions (Table 8). The Comparative Subgroup Counterfactuals for the same three subgroups are shown in Figure 5.
Table 8: Example of three unfair subgroups in COMPAS
Subgroup 1	Subgroup 2	Subgroup 3
rank	bias against	unfairness score	rank	bias against	unfairness score	rank	bias against	unfairness score
Equal Effectiveness	Fair	Fair	0.0	116.0	African-American	0.151	209.0	African-American	0.071
Equal Choice for Recourse (φ = 0.3)	Fair	Fair	0.0	3.0	African-American	1.0	Fair	Fair	0.0
Equal Choice for Recourse (φ = 0.7)	1	African-American	3.0	Fair	Fair	0.0	Fair	Fair	0.0
Equal Effectiveness within Budget (c = 1)	66.0	African-American	0.167	79.0	African-American	0.151	185.0	African-American	0.071
Equal Effectiveness within Budget (c = 10)	84.0	African-American	0.167	108.0	African-American	0.151	220.0	African-American	0.071
Equal Cost of Effectiveness (φ = 0.3)	Fair	Fair	0.0	1	African-American	inf	Fair	Fair	0.0
Equal Cost of Effectiveness (φ = 0.7)	Fair	Fair	0.0	Fair	Fair	0.0	Fair	Fair	0.0
Fair Effectiveness-Cost Trade-Off	3.0	African-American	0.5	214.0	African-American	0.151	376.0	African-American	0.071
Equal (Conditional) Mean Recourse	59.0	African-American	1.667	Fair	Fair	0.0	1	African-American	inf
D.3 Results for SSL
In Table 9 we present a summary of the ranking statistics for three interesting subgroups. and their respective Comparative Subgroup Counterfactuals in Figure 6.
Subgroup 2  
If hours-per-week = FullTime, native-country = United-States, occupation = Adm-clerical, relationship = Married:  
Protected Subgroup = 'Non-White', 1.66% covered  
No recourses for this subgroup.  
Protected Subgroup = 'White', 1.66% covered  
Make hours-per-week = BrainDrain, occupation = Exec-managerial with effectiveness 70.00%.  
Bias against 'Non-White' due to Equal Cost of Effectiveness (threshold = 0.3). Unfairness score = inf.
Subgroup 3 If hours-per-week  $=$  PartTime,marital-status  $=$  Divorced, native-country  $\equiv$  United-States: Protected Subgroup  $=$  'Non-White',  $1.15\%$  covered Make marital-status=Married-civ-spouse with effectiveness  $0.00\%$  . Make hours-per-week=MidTime,marital-status=Married-civ-spouse with effectiveness  $0.00\%$  . Make hours-per-week=FullTime,marital-status=Married-civ-spouse with effectiveness  $0.00\%$  . Make hours-per-week=OverTime,marital-status=Married-civ-spouse with effectiveness  $0.00\%$  . Make hours-per-week=OverTime,marital-status=Never-married with effectiveness  $0.00\%$  . Make hours-per-week=BrainDrain,marital-status=Married-civ-spouse with effectiveness  $0.00\%$  - Protected Subgroup  $=$  'White',  $1.66\%$  covered Make marital-status=Married-civ-spouse with effectiveness  $1.01\%$  . Make hours-per-week=MidTime,marital-status=Married-civ-spouse with effectiveness  $1.01\%$  . Make hours-per-week=FullTime,marital-status=Married-civ-spouse with effectiveness  $7.07\%$  . Make hours-per-week=OverTime,marital-status=Married-civ-spouse with effectiveness  $7.07\%$  . Make hours-per-week=OverTime,marital-status=Never-married with effectiveness  $15.15\%$  . Make hours-per-week=BrainDrain,marital-status=Married-civ-spouse with effectiveness  $16.16\%$  Bias against Non-White' due to Equal Conditional Mean Recourse.Unfairness score  $=$  inf.
Figure 4: Example of three Comparative Subgroup Counterfactuals in Adult (protected attribute race); ref. Table 7
D.4 Results for Ad Campaign
In Table 10 we present, as we did for the other datasets, the ranking results for 3 interesting subgroups, while in Figure 7, we show the respective Comparative Subgroup Counterfactuals for these subgroups.
Subgroup 1 If age_cat = 25 - 45, c_chargedegree = M, juv_misd_count = 0, priors_count = (10.0, 15.0]: Protected Subgroup = 'Caucasian', 1.03% covered Make c charge degree  $=$  F, priors_count  $= (-0.1$  , 1.0] with effectiveness  $100.00\%$  . Make priors_count  $= (-0.1$  , 1.0] with effectiveness  $100.00\%$  . Make priors_count  $= (1.0$  , 5.0] with effectiveness  $100.00\%$  . Make age_cat  $=$  Greater than 45, priors_count  $= (-0.1$  , 1.0] with effectiveness  $100.00\%$  . Make age_cat  $=$  Greater than 45, c charge degree  $=$  F, priors_count  $= (-0.1$  , 1.0] with effectiveness  $100.00\%$  . Make age_cat  $=$  Greater than 45, c charge degree  $=$  F, priors_count  $= (1.0$  , 5.0] with effectiveness  $100.00\%$  . Make age_cat  $=$  Greater than 45, priors_count  $= (1.0$  , 5.0] with effectiveness  $100.00\%$  . Protected Subgroup = 'African-American', 1.16% covered Make priors_count  $= (-0.1$  , 1.0] with effectiveness  $83.33\%$  . Make age_cat  $=$  Greater than 45, priors_count  $= (-0.1$  , 1.0] with effectiveness  $100.00\%$  . Make age_cat  $=$  Greater than 45, c charge degree  $=$  F, priors_count  $= (-0.1$  , 1.0] with effectiveness  $100.00\%$  . Make age_cat  $=\$  Greater than 45, priors_count  $= (1.0$  , 5.0] with effectiveness  $83.33\%$  . Bias against African-American due to Equal Choice for Recourse (threshold = 0.7). Unfairness score = 3.
Subgroup 2 If c charge degree  $= \mathbf{M}$  ,juv_other_count  $= 1$  .. Protected Subgroup  $=$  Caucasian,  $3.59\%$  covered Make juv_other_count  $= 0$  with effectiveness  $42.86\%$  - Protected Subgroup  $=$  African-American,  $3.48\%$  covered No recourses for this subgroup. Bias against African-American due to Equal Cost of Effectiveness (threshold  $= 0.3$  ).Unfairness score  $= \inf$
Subgroup 3 If age_cat = Greater than 45, c_chargedegree = F, juv_fel_count = 0, juv_misd_count = 0, juv_other_count = 0, sex = Male: Protected Subgroup = 'Caucasian',  $7.18\%$  covered Make c charge degree  $\equiv$  M with effectiveness  $7.14\%$  . Protected Subgroup = 'African-American',  $6.00\%$  covered Make c charge degree  $\equiv$  M with effectiveness  $0.00\%$  Bias against African-American due to Equal Conditional Mean Recourse. Unfairness score  $= \mathrm{inf}$
Figure 5: Example of three Comparative Subgroup Counterfactuals in COMPAS; ref. Table 8