SlowGuess/NeurIPS_2023_OCR huggingface dataset:
Zhiqun Zuo<sup>1</sup> Mohammad Mahdi Khalili<sup>1,2</sup> Xueru Zhang<sup>1</sup> zuo.167@osu.edu khalili.17@osu.edu zhang.12807@osu.edu
$^{1}$ CSE Department, The Ohio State University, Columbus, OH 43210  $^{2}$ Yahoo Research, New York, NY, 10003
The use of machine learning models in high-stake applications (e.g., healthcare, lending, college admission) has raised growing concerns due to potential biases against protected social groups. Various fairness notions and methods have been proposed to mitigate such biases. In this work, we focus on Counterfactual Fairness (CF), a fairness notion that is dependent on an underlying causal graph and first proposed by Kusner et al. [26]; it requires that the outcome an individual perceives is the same in the real world as it would be in a "counterfactual" world, in which the individual belongs to another social group. Learning fair models satisfying CF can be challenging. It was shown in [26] that a sufficient condition for satisfying CF is to not use features that are descendants of sensitive attributes in the causal graph. This implies a simple method that learns CF models only using non-descendants of sensitive attributes while eliminating all descendants. Although several subsequent works proposed methods that use all features for training CF models, there is no theoretical guarantee that they can satisfy CF. In contrast, this work proposes a new algorithm that trains models using all the available features. We theoretically and empirically show that models trained with this method can satisfy  $\mathrm{CF}^1$ .
While machine learning (ML) has had significant impacts on human-involved applications (e.g., lending, hiring, healthcare, criminal justice, college admission), it also poses significant risks, particularly regarding unfairness against protected social groups. For example, it has been shown that computer-aided clinical diagnostic systems can exhibit discrimination against people of color [9]; face recognition surveillance technology used by police may have racial bias [1]; a decision support tool COMPAS used for predicting the recidivism risk of defendants is biased against African Americans [5]. Various fairness notions have been proposed to mathematically measure the biases in ML based on observational data. Examples include: i) unawareness which prohibits the use of sensitive attribute in model training process; ii) parity-based fairness that requires certain statistical measures to be equalized across different groups, e.g., equalized odds [20], equal opportunity [20], statistical parity [13], predictive parity [20]; iii) preference-based fairness that is inspired by the fair-division and envy-freeness literature in economics, it ensures that given the choice between various decision outcomes, every group of users would collectively prefer its perceived outcomes, regardless of the (dis)parity compared to the other groups [43, 12].
However, the fairness notions mentioned above do not take into account the causal structure and relations among different features/variables. Recently, Kusner et al. [26] proposed a fairness notion called Counterfactual Fairness (CF) based on the causal model and counterfactual inference; it
The code repository for this work can be found in https://github.com/osu-srml/CF_Representation_Learning
requires that the ML outcome received by an individual should be the same in the real world as it would be in a counterfactual world, in which the individual belongs to a different social group. To satisfy CF, [26] shows that it is sufficient to make predictions only using the features that are non-descendants of the sensitive attribute node in the causal graph. However, this approach may discard crucial data, as descendants of sensitive attribute may contain useful information that is critical for prediction and downstream tasks. In this work, we show that using only non-descendants is not a necessary condition for achieving CF. In particular, we propose a novel method for generating counterfactually fair representations using all available features (including both descendants and non-descendants of sensitive attribute). The idea is to first generate counterfactual samples of each data point based on the causal structure, and the fair representations can be generated subsequently by applying a symmetric function to both factual (i.e., original data) and counterfactual samples. We can theoretically show that ML models (or any other downstream tasks) trained with counterfactually fair representations can satisfy perfect CF. Experiments on real data further validate our theorem.
It is worth noting that several subsequent studies of [26] also proposed methods to learn CF models using all available features, e.g., [14, 36, 24, 10, 2]. However, these methods are empirical and there is no theoretical guarantee that these methods can satisfy (perfect) CF. In Appendix A, we introduce more related work and discuss the differences with ours. Our main contributions are as follows:
- We propose a novel and efficient method for generating counterfactualy fair representations. We theoretically show that ML models trained with such representations can achieve perfect/exact CF.
- We extend our method to path-dependent counterfactual fairness [26]. That is, for any unfair path in a causal graph, we can generate representations that mitigate the impact of sensitive attributes on the prediction along the unfair path.
- We conduct extensive experiments (across different causal models, datasets, and fairness definitions) to compare our method with existing methods. Empirical results show that 1) our method outperforms the method of only using non-descendants of sensitive attributes; 2) existing heuristic methods for training ML model under CF fall short of achieving perfect CF fairness.
Consider a supervised learning problem where the training dataset consists of triples  $V = (X, A, Y)$ , where random vector  $X = [X_1, \dots, X_d]^\top \in \mathcal{X}$  are observable features,  $A \in \mathcal{A}$  is the sensitive attribute (e.g., race, gender) indicating the group membership, and  $Y \in \mathcal{Y} \subseteq \mathbb{R}$  is the label/output. Similar to [31], we associate the observable  $V = (X, A, Y)$  with a causal model  $\mathcal{M} = (U, V, F)$ , where  $U$  is a set of unobserved (exogenous) random variables that are factors not caused by any variable in  $V$ , and  $F = \{f_1, f_2, \dots, f_d, f_{d+1}, f_{d+2}\}$  is a set of functions (a.k.a. structural equations [4]) with one for each variable in  $V$ . WLOG, let
$$
X _ {i} = f _ {i} \left(p a _ {i}, U _ {p a _ {i}}\right), i \in \{1, \dots , d \}; A = f _ {d + 1} \left(p a _ {d + 1}, U _ {p a _ {d + 1}}\right); Y = f _ {d + 2} \left(p a _ {d + 2}, U _ {p a _ {d + 2}}\right),
$$
where  $pa_{i}$  and  $U_{pa_{i}}$  are the sets of observable and unobservable variables that are the parents of  $X_{i}$ .  $pa_{d + 1}$  and  $pa_{d + 2}$  (resp.  $U_{pa_{d + 1}}$  and  $U_{pa_{d + 2}}$ ) are the observable (resp. unobservable) variables that are parents of  $A$  and  $Y$ , respectively. Assume  $(U, V)$  can be represented as a directed acyclic graph.
Our goal is to learn a predictor  $\hat{Y} = g_w(R)$  parameterized by weight vector  $w\in \mathbb{R}^{d_w}$  from training data. Here  $R = h(X,A;\mathcal{M})$  is a representation generated using  $(X,A)$  and causal model  $\mathcal{M}$ . Define loss function  $l:\mathcal{V}\times \mathbb{R}\to \mathbb{R}$  where  $l(Y,g_w(R))$  is the loss associated with  $g_{w}$  in estimating  $Y$  using representation  $R$ . We denote the expected loss with respect to the joint probability distribution of  $(R,Y)$  by  $L(w)\coloneqq \mathbb{E}\{l(Y,g_w(R))\}$ . Throughout the paper, we use small letters to denote the realizations of random variables, e.g.,  $(x,a,y)$  is a realization of  $(X,A,Y)$ .
2.1 Background: Intervention and Counterfactual Inference
Given structural equations and the distribution of unobservable variables  $U$ , we can calculate the distribution of any observed variable  $V_{i} \in V$  and even study the impact of intervening certain observed variables on other variables. Specifically, the intervention on variable  $V_{i}$  can be done by simply replacing structural equation  $V_{i} = f_{i}(pa_{i},U_{pa_{i}})$  with equation  $V_{i} = v$  for some  $v$ . To study the impact of intervening  $V_{i}$ , we can use new structural equations to find resulting distributions of other observable variables and see how they may differ as  $v$  changes.
The specification of structural equations  $F$  further allows us to compute counterfactual quantities, i.e., computing the value of  $Y$  if  $Z$  had taken value  $z$  for two observable variables  $Z, Y$ . Because the value of any observable variable is fully determined by unobserved variables  $U$  and structural equations, the counterfactual value of  $Y$  for a given  $U = u$  can be computed by replacing structural equations for  $Z$  as  $Z = z$ . Such counterfactual value is typically denoted as  $Y_{Z \leftarrow z}(u)$ .
The goal of counterfactual inference is to compute the probabilities  $\operatorname*{Pr}\{Y_{Z\leftarrow z}(U)|O = o\}$  for some observable variables  $O$ . It can be used to infer "the value of  $Y$  if  $Z$  had taken value  $z$  in the presence of evidence  $O = o$ ". Based on [16],  $\operatorname*{Pr}\{Y_{Z\leftarrow z}(U)|O = o\}$  can be computed in three steps: (i) abduction that finds posterior distribution of  $U$  given  $O = o$  for a given prior on  $U$ ; (ii) action that performs intervention  $Z = z$  by replacing structural equations of  $Z$ ; (iii) prediction that computes the distribution of  $Y$  using new structural equations and the posterior  $\operatorname*{Pr}\{U|O = o\}$
2.2 Counterfactual Fairness
Without fairness consideration, simply learning a predictor by minimizing the expected loss, i.e.,  $\arg \min_{w} L(w)$ , may exhibit biases against certain social groups. One way to tackle unfairness issue is to enforce a certain fairness constraint when learning the predictor. In this work, we consider counterfactual fairness as formally defined below.
Definition 1 (Counterfactual Fairness (CF) [26]). We say a predictor  $\hat{Y} = g_w(R)$  satisfies CF if the following holds for every  $(x, a)$ :
$$
\operatorname * {P r} \{\hat {Y} _ {A \leftarrow a} (U) = y | X = x, A = a \} = \operatorname * {P r} \{\hat {Y} _ {A \leftarrow a ^ {\prime}} (U) = y | X = x, A = a \}, \forall y \in \mathcal {Y}, a ^ {\prime} \in \mathcal {A}.
$$
This notion suggests that any intervention on sensitive attribute  $A$  should not change the distribution  $\hat{Y}$  given that  $U$  follows distribution  $\operatorname*{Pr}_{\mathcal{M}}\{U|X = x, A = a\}^2$ . In other words, adjusting  $A$  should not affect the distribution of  $\hat{Y}$  if we keep other factors that are not causally dependent on  $A$  constant. Learning a fair predictor satisfying CF can be challenging. As shown in [26], a sufficient condition for satisfying CF is to not use features that are descendant of  $A$ . In other words, given training dataset  $D = \{x^{(i)}, a^{(i)}, y^{(i)}\}_{i=1}^n$ , it suffices to minimize the following empirical risk to satisfy CF:
$$
\arg \min  _ {w} \frac {1}{n} \sum_ {i = 1} ^ {n} \mathbb {E} \left\{l \left(y ^ {(i)}, g _ {w} \left(U ^ {(i)}, x _ {\not A} ^ {(i)}\right)\right) | X = x ^ {(i)}, A = a ^ {(i)} \right\},
$$
where  $x_{\neq A}^{(i)}$  are non-descendant features of  $A$  corresponding to  $i$ -th sample, and the expectation is with respect to the random variable  $U^{(i)} \sim \operatorname{Pr}_{\mathcal{M}}\{U|X = x^{(i)}, A = a^{(i)}\}$ .
Although removing the descendants of  $A$  from the input is a simple method to address the unfairness issue, it comes at the cost of losing important information. In some examples (e.g., the ones provided in [26]), it is possible that all (or most of) the features are descendants of  $A$  and need to be eliminated when training the predictor. We thus ask:
Can we train a predictor that satisfies perfect CF using all the available features as input?
Although several recently proposed methods try to train CF predictors using all the available features (including both non-descendants and descendants of  $A$ ) [14, 36], there is no guarantee that they can satisfy CF. In contrast, our work aims to propose a theoretically-certified algorithm that finds counterfactually fair predictors using all the available features.
In this section, we introduce our algorithm for training a supervised model under CF. Our method consists of three steps: (i) counterfactual samples generation; (ii) counterfactually fair representation generation; and (iii) fair model training. We present each step in detail as follows.
1. Counterfactual samples generation. We first introduce the definition of counterfactual samples and then present the method for generating them. They will be used for generating CF representations.
2Sometimes, we use subscript  $\mathcal{M}$  to emphasize that the distribution is calculated based on causal model  $\mathcal{M}$  which we assume is known.
Definition 2 (Counterfactual Sample). Consider  $i$ -th data point in training dataset with feature vector  $x^{(i)}$  and sensitive attribute  $a^{(i)}$ . Let  $u^{(i)}$  be the unobservable variable associated with  $(x^{(i)}, a^{(i)})$  sampled from distribution  $\operatorname{Pr}_{\mathcal{M}}\{U | X = x^{(i)}, A = a^{(i)}\}$  under causal model  $\mathcal{M} = (V, U, F)$ . Then,  $(\check{x}^{(i)}, \check{a}^{(i)})$  is a counterfactual sample with respect to  $(x^{(i)}, a^{(i)})$  if  $\check{a}^{(i)} \neq a^{(i)}$  and  $\check{x}^{(i)}$  is generated using structural equations  $F$ , unobservable variable  $U = u^{(i)}$ , and intervention  $A = \check{a}^{(i)}$ .<sup>3</sup>
Equivalently, we can represent the counterfactual feature  $\check{x}^{(i)} = \check{X}_{A\leftarrow \check{a}^{(i)}}^{(i)}(u^{(i)})$ . Next, we use an example to clarify the generation process of counterfactual sample.
Example 1 (Law School Success [26]). Consider a group of students, each has observable features grade-point average (GPA) before entering college  $X_G$  and entrance exam score (LSAT)  $X_L$ . Let first-year average grade in college (FYA) be label  $Y$  to be predicted and let race  $Q$  and sex  $S$  be the sensitive attributes. Suppose there are three unobservable variables  $U_G, U_L, U_F$  representing errors and the relations between these variables can be characterized by the following structural equations:
$$
X _ {G} = G P A = b _ {G} + w _ {G} ^ {Q} Q + w _ {G} ^ {S} S + U _ {G},
$$
$$
{X _ {L}} = {L S A T = b _ {L} + w _ {L} ^ {Q} Q + w _ {L} ^ {S} S + U _ {L},}
$$
$$
Y = F Y A = b _ {F} + w _ {F} ^ {Q} Q + w _ {F} ^ {S} S + U _ {F},
$$
where  $(b_{G}, b_{L}, b_{F}, w_{G}^{Q}, w_{G}^{S}, w_{L}^{Q}, w_{L}^{S}, w_{F}^{R}, w_{F}^{S})$  are the parameters of the causal model, which we assume are given<sup>4</sup>. Consider one student with  $x^{(0)} = (x_{G}^{(0)}, x_{L}^{(0)})$  and  $a^{(0)} = (q^{(0)}, s^{(0)})$ . To generate its counterfactual sample, we first compute the underlying unobservable variables  $(u_{G}^{(0)}, u_{L}^{(0)})$ :
$$
\left(u _ {G} ^ {(0)}, u _ {L} ^ {(0)}\right) = \left(x _ {G} ^ {(0)} - b _ {G} - w _ {G} ^ {Q} q ^ {(0)} - w _ {G} ^ {S} s ^ {(0)}, x _ {L} ^ {(0)} - b _ {L} - w _ {L} ^ {Q} q ^ {(0)} - w _ {L} ^ {S} s ^ {(0)}\right).
$$
Then, for any  $(\check{q},\check{s})\in \mathcal{A} - \{(q^{(0)},s^{(0)})\}$ , the corresponding counterfactual features can be generated:
$$
\check {x} _ {G} ^ {(0)} = b _ {G} + w _ {G} ^ {Q} \check {q} + w _ {G} ^ {S} \check {s} + u _ {G} ^ {(0)} = x _ {G} ^ {(0)} + w _ {G} ^ {Q} (\check {q} - q ^ {(0)}) + w _ {G} ^ {S} (\check {s} - s ^ {(0)})
$$
$$
\check {x} _ {L} ^ {(0)} = b _ {L} + w _ {L} ^ {Q} \check {q} + w _ {L} ^ {S} \check {s} + u _ {L} ^ {(0)} = x _ {L} ^ {(0)} + w _ {L} ^ {Q} (\check {q} - q ^ {(0)}) + w _ {L} ^ {S} (\check {s} - s ^ {(0)})
$$
In the above example, finding unobservable variables is straightforward due to the additive error model (i.e., each observable variable  $V_{i}$  is equal to  $f_{i}(pa_{i}) + U_{i}$ ). For other causal models that are non-additive, we can leverage techniques such as Variational Auto Encoder (VAE) to first learn distribution  $\operatorname*{Pr}_{\mathcal{M}}\{U|X = x,A = a\}$  and then sample from this distribution, see e.g., [21, 24, 30, 37].
2. Counterfactually fair representation generation. Next, we introduce how to generate counterfactualy fair representation  $R = h(X,A;\mathcal{M},s)$  using counterfactual samples generated above.
The complete procedure is given in Algorithm 1. The idea is to first apply a symmetric function  $s(\cdot)$  to both factual feature  $x$  and counterfactual features  $\{\tilde{x}^{[j]}\}_{j=1}^{|A|-1}$ . This output can be leveraged to generate CF representation. The symmetry of the function is formally defined below.
Definition 3. A function  $s:\mathcal{X}^{|A|}\to \mathbb{R}$  is symmetric if the output is the same for any permutation of inputs.
Algorithm 1 CF Representation Generation  $h(x, a; \mathcal{M}, s)$
Input: Causal model  $\mathcal{M}$ , observable features  $(x, a)$ , symmetric function  $s$
1: Sample  $u$  from distribution  $\operatorname{Pr}_{\mathcal{M}}\{U|X = x, A = a\}$
2: Use  $u$  and causal model  $\mathcal{M}$  to generate  $|\mathcal{A}| - 1$  counterfactual samples  $\{(\check{x}^{[1]},\check{a}^{[1]}),\ldots ,(\check{x}^{[|\mathcal{A}| - 1]},\check{a}^{[|\mathcal{A}| - 1]})\}$  where  $\check{a}^{[j]}\in \mathcal{A} - \{a\}$ .
3: Use symmetric function  $s(.)$  to generate representation
$$
R = \left[ s \left(x, \check {x} ^ {[ 1 ]}, \dots , \check {x} ^ {\left[ | \mathcal {A} | - 1 \right]}\right), u \right]
$$
Output: counterfactually fair representation  $R$
One example of symmetric function is
the average over all inputs, e.g.,  $s(x, \check{x}^{[1]}, \ldots, \check{x}^{[|A| - 1]}) = \frac{(x + \check{x}^{[1]} + \ldots + \check{x}^{[|A| - 1]})}{|A|}$ .
3. Fair model training. Given CF representation  $R = h(X, A; \mathcal{M}, s)$  generated by Algorithm 1, we can use it directly to learn a predictor that satisfies CF. Indeed, we can show that any predictor learned based on CF representation satisfies perfect CF, as stated in Theorem 1 below.
<sup>3</sup>If  $A$  is non-binary, we can generate  $|\mathcal{A}| - 1$  counterfactual samples for each  $\check{a}\in \mathcal{A} - \{a\}$  . We can use  $\check{x}^{[j]}$  to represent  $j$  -th counterfactual sample corresponding to  $x$  and the  $j$  -th element in  $\mathcal{A} - \{a\}$
4The parameters of a causal model can be found using observational data and by the maximum likelihood estimation. As a result, we can assume that the parameters of the causal model are given.
Theorem 1. If representation is generated based on  $h(x, a; \mathcal{M}, s)$  in Algorithm 1, then the predictor  $g_w(h(x, a; \mathcal{M}, s))$  satisfies perfect CF for all  $w \in \mathbb{R}^{d_w}$ .
Because  $g_{w}(h(x,a;\mathcal{M},s))$  satisfies CF for all parameter  $w$ , we can find the optimal predictor directly by solving an unconstrained optimization:
$$
w ^ {*} = \arg \min _ {w} \frac {1}{n} \sum_ {i = 1} ^ {n} l \left(y ^ {(i)}, g _ {w} (h (x ^ {(i)}, a ^ {(i)}; \mathcal {M}, s)\right)
$$
Under Theorem 1, it is guaranteed that the optimal predictor  $g_{w^*}$  satisfies counterfactual fairness.
Inference. After learning the optimal CF predictor  $g_{w^*}$ , we can use it to make fair predictions about new data. At the inference phase, for a given example  $(x, a)$ , we first generate its CF representation using Algorithm 1 and find the prediction  $\hat{y}$  using  $g_{w^*}$ . That is,  $\hat{y} = g_{w^*}(h(x, a; \mathcal{M}, s))$ .
Discussion. Compared to [26], our method leverages all available features and can attain much better performance without sacrificing fairness. We will further validate this in experiments (Section 5). As mentioned earlier, there are existing methods that also use all features to train predictors under CF constraint. For instance, the method proposed in [24] also generates the counterfactual sample for each training data and it trains model using both factual and counterfactual samples; [14] learns CF predictor by adding a penalty term to the learning objective function, where the penalty term is calculated based on the counterfactual samples. While these two methods also leverage counterfactual samples to reduce bias, they cannot satisfy perfect CF and there is no theoretical guarantee.
4 Path-dependent Counterfactual Fairness
In this section, we consider a variant notion of CF called Path-dependent Counterfactual Fairness (PCF). We will show how the proposed method can be adapted to train predictors under PCF. Let  $\mathcal{G}$  be the graph associated with causal model  $\mathcal{M}$ , and  $\mathcal{P}_{\mathcal{G}_A}$  be the set of all unfair directed paths from sensitive attribute  $A$  to output  $Y$ . Further, we define  $X_{\mathcal{P}_{\mathcal{G}_A}^c}$  as the features that are not present in any unfair path in  $\mathcal{P}_{\mathcal{G}_A}$  and  $X_{\mathcal{P}_{\mathcal{G}_A}}$  as the features along the unfair paths. Path-dependent Counterfactual Fairness is defined as follows.
Definition 4 (Path-dependent Counterfactual Fairness (PCF) [26]). We say  $\hat{Y} = g_w(R)$  satisfies PCF with respect to path set  $\mathcal{P}_{\mathcal{G}_A}$  if the following holds for every  $(x,a): \forall y \in \mathcal{V}, a' \in \mathcal{A}$
$$
\operatorname * {P r} \{\hat {Y} _ {A \leftarrow a, X _ {\mathcal {P} _ {\mathcal {G} _ {A}} ^ {\mathrm {c}}} \leftarrow x _ {\mathcal {P} _ {\mathcal {G} _ {A}} ^ {\mathrm {c}}} (U) = y | X = x, A = a \} = \operatorname * {P r} \{\hat {Y} _ {A \leftarrow a ^ {\prime}, X _ {\mathcal {P} _ {\mathcal {G} _ {A}} ^ {\mathrm {c}}} \leftarrow x _ {\mathcal {P} _ {\mathcal {G} _ {A}} ^ {\mathrm {c}}} (U) = y | X = x, A = a \}
$$
This notion suggests that if we fix attributes  $X_{\mathcal{P}_{\mathcal{G}_A}^c}$  and let  $U$  follows posterior distribution  $\operatorname*{Pr}_{\mathcal{M}}\{U|X = x,A = a\}$ , then variable  $A$  should not affect the predictor along unfair path(s) in  $\mathcal{P}_{\mathcal{G}_A}$ . Note that PCF reduces to CF if  $X_{\mathcal{P}_{\mathcal{G}_A}^c} = \emptyset$ . We want to emphasize that path-specific counterfactual fairness defined in [7] is different from Definition 4. Path-specific counterfactual fairness [7] considers a baseline value  $a^\prime$  for  $A$ , and requires  $A = a^{\prime}$  propagate
Algorithm 2 PCF Representation Generation  $h(x,a;\mathcal{M},s,X_{\mathcal{P}_{\mathcal{G}_A}^c})$
Input: Causal model  $\mathcal{M}$ , Set of variables  $X_{\mathcal{P}_{\mathcal{G}_A}^c}$  that are not along unfair paths,  $(x,a)$ , symmetric function  $s$
1: Sample  $u$  from distribution  $\operatorname{Pr}_{\mathcal{M}}\{U|X = x, A = a\}$
2: Apply intervention  $X_{\mathcal{P}_{\mathcal{G}_A}^c} = x_{\mathcal{P}_{\mathcal{G}_A}^c}$  to get a new model  $\mathcal{M}'$
3: Use  $u$  and causal model  $\tilde{\mathcal{M}}'$  to generate  $|\mathcal{A}| - 1$  counterfactual features  $\{(\tilde{x}_{\mathcal{P}_{\mathcal{G}_A}}^{[1]},\tilde{a}^{[1]}),\ldots ,(\tilde{x}_{\mathcal{P}_{\mathcal{G}_A}^c}^{[|A| - 1]},\tilde{a}^{[|A| - 1]})\}$ , where  $\check{a}^{[j]} \in \mathcal{A} - \{a\}$ .
4: Use symmetric function  $s(.)$  to generate representation
$$
R = \left[ x _ {\mathcal {P} _ {\mathcal {G} _ {A}} ^ {\mathrm {c}}}, s (x _ {\mathcal {P} _ {\mathcal {G} _ {A}}}, \check {x} _ {\mathcal {P} _ {\mathcal {G} _ {A}}} ^ {[ 1 ]}, \dots , \check {x} _ {\mathcal {P} _ {\mathcal {G} _ {A}}} ^ {[ | \mathcal {A} | - 1 ]}), u \right]
$$
Output: path-dependent counterfactually fair representation  $R$
through unfair paths, and the true value of  $A$  propagates through other paths. In contrast, in path-dependent CF, there is no baseline value for  $A$ , and  $A$  should not cause  $Y$  through unfair paths.
In this section, we describe how our proposed method could be adapted to the path-dependent case. Before describing the algorithm formally, we present an example.