Counterfactual Fairness through Data Preprocessing

1 INTRODUCTION . The rapid popularization of machine learning methods and the growing availability of personal data have enabled decision-makers from various fields such as graduate admission ( Waters & Miikkulainen , 2014 ) , hiring ( Ajunwa et al. , 2016 ) , credit scoring ( Thomas , 2009 ) , and criminal justice ( Brennan et al. , 2009 ) to make data-driven decisions efficiently . However , the community and the authorities have also raised concern that these automatically learned decisions may inherit the historical bias and discrimination from the training data and would cause serious ethical problems when used in practice ( Nature Editorial , 2016 ; Angwin & Larson , 2016 ; Dwoskin , 2015 ; Executive Office of the President et al. , 2016 ) . Consider a training dataset D consisting of sensitive attributes S such as gender and race , nonsensitive attributes A and decisions Y . If the historical decisions Y are not fair across the sensitive groups , a powerful machine learning algorithm will capture this pattern of bias and yield learned decisions Ŷ that mimic the preference of the historical decision-maker , and it is often the case that the more discriminative an algorithm is , the more discriminatory it might be . While researchers agree that methods should be developed to learn fair decisions , opinions vary on the quantitative definition of fairness . In general , researchers use either the observational or counterfactual approaches to formalize the concept of fairness . The observational approaches often describe fairness with metrics of the observable data and predicted decisions ( Hardt et al. , 2016 ; Chouldechova , 2017 ; Yeom & Tschantz , 2018 ) . For example , Demographic Parity ( DP ) or Group Fairness ( Zemel et al. , 2013 ; Khademi et al. , 2019 ) considers the learned decision Ŷ to be fair if it has the same distribution for different sensitive groups , i.e. , P ( Ŷ |S = s ) = P ( Ŷ |S = s′ ) . The Individual Fairness ( IF ) definition ( Dwork et al. , 2012 ) views fairness as treating similar individuals similarly , which means the distance between Ŷ ( si , ai ) and Ŷ ( sj , aj ) should be small if individuals i and j are similar . The other branch of fairness and/or discrimination definitions are built upon the causal framework of Pearl ( 2009a ) , such as direct/indirect discrimination ( Zhang et al. , 2017 ; Nabi & Shpitser , 2018 ) , path-specific effect ( Wu et al. , 2019b ) , counterfactual error rate ( Zhang & Bareinboim , 2018a ) and counterfactual fairness ( Kusner et al. , 2017 ; Wang et al. , 2019 ; Wu et al. , 2019a ) . These definitions often involve the notion of counterfactuals , which means what the attributes or decision would be if an individual were in a different sensitive group . With the help of the potential outcome concept , the measuring of fairness is no longer restricted to the observable quantities ( Kilbertus et al. , 2017 ; Zhang & Bareinboim , 2018b ) . For example , the Equal Opportunity ( EO ) definition Wang et al . ( 2019 ) has the same idea as IF but it can directly compare the actual and counterfactual decisions of the same individual instead of the actual decisions of two similar individuals . The Counterfactual Fairness ( CF ) definition ( Kusner et al. , 2017 ) or equivalently , the Affirmative Action ( AA ) definition ( Wang et al. , 2019 ) goes one step further than EO and derives the counterfactual decisions from the counterfactual non-sensitive attributes . We adopt CF as our definition of fairness and it is formally described in Section 2 . We believe causal reasoning is the key to fair decisions as DeDeo ( 2014 ) pointed out that even the most successful algorithms would fail to make fair judgments due to the lack of causal reasoning ability . For the observational definitions , fair decisions can be learned by solving optimization problems , either adding the fairness condition as a constraint ( Dwork et al. , 2012 ) or directly optimize the fairness metric as an object ( Zemel et al. , 2013 ) . When using the counterfactual definitions , however , an approximation of the causal model or the counterfactuals is often needed since the counterfactuals are unobservable . In the FairLearning algorithm proposed by Kusner et al . ( 2017 ) , the unobserved parts of the graphical causal model are sampled using the Markov chain Monte Carlo method . Then they use only the non-descendants of S to learn the decision , which ensures CF but will have a low prediction accuracy . In Wang et al . ( 2019 ) , the counterfactual of A had S been s′ is imputed as the sum of the counterfactual group mean E ( A|S = s′ ) and the residuals from the original group A− E ( A|S = s ) . As we discuss later , this approach would only work when a strong assumption of the relationship between A and S is satisfied . 1.1 CONTRIBUTIONS . We develop the Fair Learning through dAta Preprocessing ( FLAP ) algorithm to learn counterfactually fair decisions from biased training data . While current literature is vague about the assumptions needed for their algorithms to achieve fairness , we formalize the weak and strong conditions where different data preprocessing procedures should be used to guarantee CF and prove the results under the causal framework of Pearl ( 2009a ) . We show that our algorithm can predict fairer decisions with similar accuracy when compared with other counterfactual fair learning algorithms using three simulated datasets and three real-world applications , including the loan approval data from a fintech company , the adult income data , and the COMPAS recidivism data . On the other hand , the processed data also enable us to detect discrimination in the original decision . We prove that CF is equivalent to the conditional independence of the decisions and the sensitive attributes given the processed non-sensitive attributes under certain conditions . Therefore any wellestablished conditional independence tests can be used to test CF with the processed data . To our knowledge , it is the first time that a formal statistical test for CF is proposed . We illustrate the idea using the Conditional Distance Correlation test ( Wang et al. , 2015 ) in our simulation and test the fairness of the decisions in the loan approval data using a parametric test . 2 CAUSAL MODEL AND COUNTERFACTUAL FAIRNESS . For the discussion below , we consider the sensitive attributes S ∈ S to be categorical , which is a reasonable restriction for the commonly discussed sensitive information such as race and gender . The non-sensitive attributes A ∈ A ⊆ Rd , and the decision Y is binary as admit or not in graduate admission , hire or not in the hiring process , approve or not in loan assessment . To bring the discussion of fairness into the framework of causal inference , we begin by constructing the Structural Causal Model ( SCM ) for the data . As described in Pearl ( 2009b ) , an SCMM consists of a set of exogenous variables U , a set of endogenous variables V , and F , a set of functions that assign value to each endogenous variable given its parents in V and the exogenous variables U . In our case ( Figure 1 ) , we consider V = { S , A , Y , Ŷ } , where { S , A , Y } are the observed data and Ŷ is the prediction of Y we made based on S and A . The only exogenous variable affecting Ŷ is a Uniform ( 0 , 1 ) random variable UŶ so that we can conveniently express the value of Ŷ with a structural equation . We assume that US , UA , and UY , which are the exogenous variables that affect S , A , and Y respectively , are independent of each other . The structural equations on the right side of Figure 1 are described with the functions in F , one for each component in V . Here we express fŶ as an indicator function so that Ŷ is a Bernoulli random variable that takes value one with probability p ( S , A ) . In general , p ( s , a ) could be any function that maps S × A to [ 0 , 1 ] , but we are more interested in such functions that will result in a fair decision , more details of which will be discussed in Section 3 . It can be seen that the subset of exogenous variables { US , UA , UY } characterize everything we should know about a unit . Any two units with the same realization will have the same behavior and result irrespective of the other differences in their identities . Here we give a simplified loan approval model as a running example to help understand the SCM we considered . Example 1 . A bank asks each loan applicant for her/his race S and annual income A to decide to approve the application ( Y = 1 ) or not ( Y = 0 ) . There are two races in the population of the applicants , S = 1 represents the advantageous group , and S = 0 for the disadvantageous one . Let US ∼ Uniform ( 0 , 1 ) , we generate S = 1 { US < 0.7 } . The annual income is log-normally distributed for each race group and its scale and location parameters may depend on race : A = c1 exp { c2 + λaS + c3σSaUA } , where UA is a standard normal random variable , c1 , c3 > 0 , and c2 are constants that affect the median and spread of the population income , λa decides the difference in mean log income between the two race groups , and σa > 0 determines the standard deviation ratio of the log incomes . The decision by the bank can be simulated from a logistic model : Y = 1 { UY < expit ( β0 + βaA+ βsS ) } , where UY ∼ Uniform ( 0 , 1 ) and expit ( u ) = ( 1 + e−u ) −1 . In this example , βs characterizes the direct effect of the sensitive attribute on the decision : when βs > 0 , the applications from the advantageous group are more likely to be approved by the bank when holding the income fixed . On the other hand , λa partly describes the indirect effect because when both λa and βa are positive , the advantageous group will have a higher income than the other group on average and thus be favored by the bank even if βs = 0 . It is worth noting that , apart from the difference in the mean , the difference in higher moments could also cause unfairness indirectly as alluded to in Fuster et al . ( 2018 ) . In general , if there are any differences in the distribution of A across the categories in S , the decision based on A might be unfair . However , the indirect effect caused by the differences in the higher moments of A could be case dependent and thus harder to interpret . In our case , σa > 1 will lead to a higher average income and hence higher approval probability on average for the advantageous group since the income distribution is right-skewed . With the SCM in hand , we are ready to define the causal quantity we are interested in . Since most sensitive attributes , such as gender and race , can not be altered in experiments , we will look into the counterfactuals , namely , what the results Y would be had S been different from the observed facts . This quantity is expressed as Ys ( U ) had S been s for a random unit with exogenous variables U sampled from the population . Define Ms to be the modified SCM from M ( Figure 1 ) with the equation for S replaced with S = s. Then for any realization U = u , the unit level counterfactuals Ys ( u ) can be calculated from Ms . Similarly , we can define Ŷs ( U ) and Ŷs ( u ) as the counterfactual predicted decision and its realization . The counterfactual fairness can then be defined on both the decision and the prediction based on the counterfactual result . Here we denote Y as a placeholder for either Y or Ŷ . Definition 1 . Counterfactual Fairness . Given a new pair of attributes ( s∗ , a∗ ) , a ( predicted ) decision Y is counterfactually fair if for any s′ ∈ S , Ys′ ( U ) | { S = s∗ , A = a∗ } d = Ys∗ ( U ) | { S = s∗ , A = a∗ } . In other words , the conditional distribution of the counterfactual result should not depend on the sensitive attributes . It should be noted that there are two stages in evaluating the conditional counterfactuals . The first is updating the conditional distribution ofU . Take the decision Y from Example 1 , if s∗ = 0 , then US | { S = s∗ , A = a∗ } is from Uniform ( 0.7 , 1 ) and UA| { S = s∗ , A = a∗ } is a constant ( log ( a∗/c1 ) − c2 ) /c3 , but UY | { S = s∗ , A = a∗ } is still a Uniform ( 0 , 1 ) random variable since UY is independent of S and A from the SCM . The next stage is deriving the conditional distribution of the counterfactuals from the structural equations of Ms and the conditional distribution of U . Continuing with our example , Y1 ( U ) | { S = 0 , A = a∗ } would be equal in distribution to fY ( 1 , fA ( 1 , UA ) , UY ) | { S = 0 , A = a∗ } d =fY ( 1 , fA ( 1 , ( log ( a ∗/c1 ) − c2 ) /c3 ) , UY ) d =1 { UY < expit ( β0 + βac1 ( a∗/c1 ) σa exp { λa + ( 1− σa ) c2 } + βs ) } and Y0 ( U ) | { S = 0 , A = a∗ } d = 1 { UY < expit ( β0 + βaa∗ ) } . Thus the bank ’ s decision Y would be counterfactually fair if σa = 1 , λa = 0 and βs = 0 .

Summary: The paper addresses the problem of preprocessing the data in a way that the predictions of a learning task will be counterfactually fair. The counterfactual fairness definition is borrowed from that of (Kusner et al., 2017). The authors propose ortogonaliza tion and marginal distribution mapping so as to achieve counterfactual fairness. They test their proposed approach on synthetic and real data.