{'fraction_non_alphanumeric': 0.03724197342699049, 'fraction_numerical': 0.009376760213379279, 'mean_word_length': 4.237202845740066, 'pattern_counts': {'":': 0, '<': 1, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Assessing Classifier Fairness with Collider Bias

The increasing application of machine learning techniques in everyday decision-making processes has brought concerns about the fairness of algorithmic decision-making. This paper concerns the problem of collider bias which produces spurious associations in fairness assessment and develops theorems to guide fairness assessment avoiding the collider bias. We consider a real-world application of auditing a trained classifier by an audit agency. We propose an unbiased assessment algorithm by utilising the developed theorems to reduce collider biases in the assessment. Experiments and simulations show the proposed algorithm reduces collider biases significantly in the assessment and is promising in auditing trained classifiers.


Introduction
There are increasing concerns over the fairness of decision making algorithms with the wide use of machine learning in various applications, such as job hiring, credit scoring and home loan since discrimination can be inadvertently introduced into machine learning models. To prevent unfairness in a model from spreading in society, audit techniques are needed for the independent authority to audit machine learning models. Figure 1 shows an audit process. An audit agency accesses a model of a company and has its own audit cases for assessing the fairness of the model. The audit agency does not have access to the training data set but has the regulatory policy. In this paper, we use a causal graph to represent the regulatory policy. The company may use additional variables that are not specified in the regulatory policy to build its models to improve prediction accuracy.
Situation test has been used in the U.S. to detect discrimination in recruitment [1], which is a controlled experiment approach for analysing employers' decisions on job applicants' characteristics, as illustrated with the following examples. Pairs of research assistants are sent to apply for the same job, and each pair of the pretended applicants have the same qualifications and experience related to the job but have different values for their protected variable, such as male/female or young/old. Discrimination is detected if the favourable decisions are unequal between groups with different protected values.
The above described situation test can be simulated in an audit process, and we call it Naive Situation Test (NST) in this paper. We feed two inputs representing two individuals whose variable values are identical except their protected values to a machine learning model. If the model provides different decisions, NST will detect the model as discriminatory. NST may produce an incorrect detection. We use the following example to show this. Consider a classifier f () used by a company to determine employees' salaries as salary = f (race, education, suburb). Some predicted outcomes by the model are shown in Table 1. Based on NST, the black people are not discriminated against since with the same education and suburb, both white and black people are predicted to have the same salary. However, Suburb is an irrelevant variable for determining the Salary. Without considering the Suburb, with the same level of Education, 2/3 white people receive a salary higher than 50K while only 1/3 black people receive a salary of 50K or higher. Hence, black people are discriminated against by the model. The incorrect detection by NST is caused by collider bias. We use a causal graph, formally defined in Section 2, to explain the collider bias. Causal relationships of variables in the above example are shown using the causal graph in Figure 2 where a directed edge represents a causal relationship. The suburb is a collider since two edges "collide" at it. Conditioning on a collider, an association is formed between the two variables but it is spurious [5]. In the example, the spurious association cancels the association due to the causal relationship between Race and Salary and hides the true discrimination. Collider bias is related to the selection bias [11]. In a classifier, conditioning on a variable is equivalent to selecting sub-populations using the values of the variable. If the variable is a collider, a selection bias in each sub-population is resulted. We call this bias collider bias in this paper.
There is no existing alternative method to NST to audit classifiers. Most methods, to be reviewed in the related work, need to access the training data set and suffer from collider bias. A causal-based situation test (CST) [30] does not suffer from collider bias, but needs to access the training data set too. The audit cases used by an audit agency are only a small number of individual cases which do not represent the population. Collecting a representative sample of the population needs a significant resource. Therefore, a data-based audit method is not applicable. We make the following contributions in this paper.
-We study collider bias in fairness assessment and present theorems to avoid collider bias. Our theoretical results give a principled guidance on which variables can be used for fairness assessment and also for building fair classifiers. -We investigate the problem of auditing machine learning models and propose an Unbiased Situation Test (UST) algorithm for auditing without accessing training data or an unbiased sample of the population. Experiments show that UST can effectively reduce collider bias.

Background
We present the necessary background of causal inference. We use upper case letters to represent variables and bold-faced upper case letters to denote sets of variables. The values of variables are represented using lower case letters.
. . , V p } is the set of nodes and E is the set of edges between the nodes, i.e. E ⊆ V × V. A path π is a sequence of distinct nodes such that every pair of successive nodes are adjacent in G. A path π is a directed path if all edges along the path are directed edges. A path between (V i , V j ) is a backdoor path with respect to X i if it has an arrow into V i . Given a path π, V k is a collider node on π if there are two edges incident is a parent of V j and we use P a(V j ) to denote the set of all parents of V j . In a directed path π, V i is an ancestor of V j and V j is a descendant of V i if all arrows point to V j .
A DAG (Directed Acyclic Graph) is a directed graph without directed cycles. With the following assumptions, a DAG links to a distribution.
Definition 1 (Markov condition [19]). Given a DAG G = (V, E) and P (V), the joint probability distribution of V, G satisfies the Markov condition if for ∀V i ∈ V, V i is probabilistically independent of all non-descendants of V i , given the parents of V i .
When the Markov condition holds, P (V) can be factorized into: Definition 2 (Faithfulness [24]). A DAG G = (V, E) is faithful to P (V) iff every independence presenting in P (V) is entailed by G which fulfills the Markov condition. A distribution P (V) is faithful to a DAG G iff there exists DAG G which is faithful to P (V).
With the above two assumptions, we can read the independencies between variables in P (V ) from a DAG using the following defined d-separation criterion.
Definition 3 (d-separation [19]). A path π in a DAG is said to be d-separated (or blocked) by a set of nodes Z iff (1) π contains a chain V i → V k → V j and a fork V i ← V k → V j node such that the middle node V k is in Z, or (2) π contains a collider V k such that V k is not in Z and no descendant of V k is in Z.
To conduct causal inference with DAGs, we make the following assumptions.
Definition 4 (Causal sufficiency [24]). A data set satisfies causal sufficiency if for every pair of variables (V i , V j ) in V, all their common causes are also in V.
With a DAG, if we interpret a node's parent as its direct cause, the DAG is known as a causal DAG. We can learn a causal DAG from data when the assumptions of causal sufficiency, faithfulness and Markov condition are satisfied.
An intervention, which forces a variable to take a value, can be represented by a do operator. For example, do(X = 1) means X is intervened to take value 1. P (y | do(X = 1)) is an interventional probability. Let us understand do in an ideal experiment.
Definition 5 (Direct effect [19]). The direct effect of X on Y is P (y | do(X = x), do(V \XY = v)) where V \XY means all other variables except X and Y .
In order to study the relationship between X on Y , all other variable are controlled in the ideal experiment. To infer interventional probabilities (by reducing them to normal conditional probabilities) with a causal DAG, the following set of rules of do-calculus [19] are necessary. They are used in the proofs of our theorems.
For a DAG G and a subset of nodes X in G, G X represents the DAG obtained by deleting from G all arrows pointing to nodes in X, and G X denotes the DAG by deleting from G all arrows emitting from nodes in X.
Theorem 1 (Rules of do-Calculus [19]). Let X, Y, Z, W be arbitrary disjoint sets of variables in a causal DAG G. The following rules hold, where x, y, z, w are the shorthands of X = x, Y = y, Z = z and W = w respectively. Rule 1. (Insertion/deletion of observations): is the nodes in Z that are not ancestors of any node in W in G X .

Problem Definition
A classifier (prediction model) has been built by a company/organisation from a training data set which contains a binary protected variable A, a binary decision outcome Y , and a set of relevant variables of Y , X, since variables independent of Y are not used for predicting Y . An agency wants to audit the model using some cases. We make the following assumptions about the audit.
Assumption 1 1. The regulatory policy has specified the causal relationships among the factors and Y , and uses a causal DAG to indicate. The factors are ancestral variables of Y including all direct causes of Y . 2. The audit agency has no access to the model training data or an unbiased sample of the population. The agency however has access to the distributional statistics from some sources, such as government census data. 3. The company or organisation has used all the legitimate factors to comply with the regulatory policy. However, some other variables are also used by the model to enhance the prediction performance.
In the theorem development, we assume that there is a DAG that is consistent with the regulatory policy. In the algorithm, we do not need the complete DAG, but ancestral variables of Y and colliders in the descendant nodes of Y .
We first define the criterion for auditing. We use Controlled Direct Effect (CDE) [20] to measure fairness. CDE is extended from conditioning on do(prote cted) to conditioning on do(all other variables) as in Definition 5 to simulate an ideal experiment. The alternative definitions are path specific causal effect [4,25,32] and counterfactual fairness [13], we will discuss why the alternatives have not been used after Definition 5.
The protected variables in this paper include redline variables, which are the descendants of protected variables. The redline variables are recognised as a proxy of protected variables and may cause some discrimination [12]. Some companies or organisations build the models under the concept of fairness through awareness [7], which means the classifier functions may not use the protected variables as input. In this case, the redline variables will be considered as the protected variables.
Definition 6 (Fairness score). Given a causal DAG G representing the regulatory policy, A, X, and Y as described above. The fairness score is of an individual (or a subgroup) The rationale of the above definition is that we conduct a controlled experiment by intervening the protected variable, and controlling all other variables to x i . The decision for x i is fair if the intervention does not change the outcome.
Unlike previous works [7,8,10,16], our definition of fairness score is based on the CDE which uses intervention. Thus the spurious association between A and Y caused by conditioning on colliders will be avoided. We do not use counterfactual fairness [13] in our fairness definition since it needs stronger assumptions and poses a practical challenge. To estimate counterfactual outcomes, there is a need for knowing the full causal model and latent background knowledge. Both are not available in our problem setting. Some other definitions [4,25,32] make use of path specific causal effect. Their solutions also need counterfactual reasoning and they do not fit our problem setting.
Definition 7 (Problem definition). Given G, A and X as described above, and classierŶ = f (A, X). The audit is to determine if a prediction on an individual (X = x i ) is fair, i.e. |CDE(x i )| < τ where τ is a threshold determined by the regulatory policy and Y in CDE(x i ) is replaced byŶ .

Estimating CDE
For the sake of fairness audit, the protected variable A is assumed to be a parent node of Y so we can use CDE for the audit. The results in this section are true in general, not just for auditing classifiers.
). This is achieved by repeatedly using Rule 3 of Theorem 1. We show this by an example where C ∈ C, where the incoming edges to A and to C have been removed.
Secondly, we consider P (y | do(A = a), do(Q = q)) only. Based on the Markov condition 1, Y is independent of all its non-descendant nodes given its parents. Therefore, P (y | do(A = a), do(Q = q)) = P (y | do(A = a), do(P a (Y ) = pa)).
Thirdly, we will prove P (y|do(A = a), do(P a (Y ) = pa)) = P (y | A = a, P a (Y ) = pa). This can be achieved by repeatedly applying Rule 2 of Theorem 1.
Now, we get, Theorem 2 removes the descendant nodes of Y from the conditioning set in the conditional probabilities for CDE estimation, and this removes possible collider bias. Furthermore, it gives a succinct set of variables for estimating CDE.
For example, in Figure 3(a), P (y | do(a), do(x 1 , x 2 , x 3 , x 4 )) = P (y | a, x 1 , x 2 ) based on Theorem 2, where we use x i for X i = x i . The CDE is determined by conditional probabilities on A, X 1 and X 2 . Since X 3 is not used in the conditioning set, there will be no collider bias. Theorem 2 is based on the causal sufficiency assumption, which assumes that there are no unobserved common causes in the data set. In real-world applications, unobserved variables are unavoidable. When there are unobserved variables, how do we estimate CDE?Let us consider two types of unobserved variables. The first type of unobserved common causes are in between a parent node and Y . In this case, an edge emitting from a unobserved common cause goes into the parent node, and the parent node may form a collider with another incoming edge from another observed or unobserved variable (see the following for an example in Figure 3 (c)). This will invalidate the result of Theorem 2. The following Corollary will fix this. The second type of unobserved common causes are between other nodes apart from the parent nodes and Y . The proof in the following corollary will show that they do not invalidate the result of Theorem 2. Proof. Direct causes of Y will be parent nodes of Y in any DAG even when the unobserved common causes are included, i.e. the causal sufficiency is unsatisfied. Since P a (Y ) = Ca(Y ) and there is not an unobserved variable in between a direct cause and Y , P (y | do(A = a), do(X = x)) = P (y | A = a, Ca(Y ) = ca) can be derived following the same procedure in Theorem 2.
Since other variables apart from P a (Y ) are not used in reducing P (y | do(A = a), do(X = x)), the unobserved common casues between these variables are irrelevant to the deduction and do not affect the above conclusion.
Corollary 1 indicates that discrimination detection is sound when the audit agency knows all the direct causes of Y and uses them as the conditioning set when calculating CDE. For example, in Figure 3(b), P (y | do(a), do(x 1 , x 2 , x 3 , U 1 )) = P (y | a, x 1 , x 2 ) based on Corollary 1. Unobserved ancestral variables of Y are blocked off from Y by X 1 and X 2 , and they do not affect the probability of Y . The unobservable variables can be in the descendant nodes of Y too, but they do not affect the CDE estimation since they will not be used anyway.
We will further explain why direct causes are necessary for Corollary 1. Let Figure 3(c) be a true DAG with two unobserved variables U 1 and U 2 . X 2 is not a direct cause of Y . Since U 1 and U 2 are unobserved, X 2 is perceived as a parent of Y in the observed data. If X 2 is used to estimate CDE, the estimation will be biased since the back door path (Y, U 1 , U 2 , X 1 , A) is opened when X 2 is conditioned on. In this case, X 1 is necessary to block the path. When both X 1 and X 2 are included, the CDE estimation is unbiased. Sometimes, we need redundancy to prevent such a biased estimation.
Both Theorem 2 and Corollary 1 give a succinct conditioning set for CDE estimation. In fact, a superset of the direct causes works as long as the superset does not contain descendant nodes of Y . In a DAG, ancestral nodes represent the direct causes and indirect causes of Y . Proof. Let B = Ca (Y ) ∪ R, and R includes indirect causes of Y . Following Corollary 1, P (y | do(A = a), do(X = x)) = P (y | A = a, Ca (Y ) = ca). Based on the Markov condition 1, Y is independent of R given A ∪ Ca (Y ). Hence, P (y | A = a, Ca (Y ) = ca) = P (y | A = a, B).
Corollary 2 allows some redundancy in the conditioning set comparing to Corollary 1. In practice, the redundancy gives a flexibility for users to determine the direct causes of Y . Sometimes, a direct cause and an indirect cause are difficult to distinguish, and Corollary 2 indicates that including both does not bias the CDE estimation. For example, in Figure 3(d), P (y | do(a), do(x 1 , x 2 , x 3 , x 4 )) = P (y | a, x 1 , x 2 ) = P (y | a, x 1 , x 2 , x 4 ) based on Corollary 2 if X 1 and X 2 are all direct causes of Y . Let us assume that Figure 3(d) is the true DAG, but a government agency has a DAG as Figure 3(e) since they do not know which one of X 1 and X 4 is the direct cause of Y . A CDE estimation based on the imprecise DAG in Figure 3(e), i.e. P (y | do(a), do(x 1 , x 2 , x 3 , x 4 )) = P (y | a, x 1 , x 2 , x 4 ) is also unbiased.

Implementing Unbiased Situation Test
We summarise the discussion and propose the following unbiased situation test.
Definition 8 (Unbiased Situation Test (UST)). UST exams whether a classifierŶ = f () is fair for a given case x i by calculating CDE( where B is the set of direct causes and some (or all) indirect causes of Y . The test case x i is discriminated if |CDE(x i )| ≥ τ , where τ is a threshold specified by the regulatory policy.

Algorithm 1 Unbiased Situation Test (UST)
Input: Classifier f (), X = B ∪ C as defined in the text. P (C = c i ). Test cases DT est. The threshold τ . Output: L, a list of discriminated cases in DT est.
1: for each ri ∈ DT est do 2: Let r i be the record by flipping the value of A in ri 3: Let P (Ŷ = 1 | ri) = f (ri) and P (Ŷ = 1 | r i ) = f (r i ) 4: Obtain To conduct UST as in Definition 8, one problem is that an audit agency cannot obtain the conditional probability P (Ŷ = 1 | A = a, B = b i ) directly since it does not access the training data set or a unbiased sample of the population. Instead, it can have P (Ŷ = 1 | A = a, B = b i , C = c i ) from the classifier f (). Therefore, the following marginalisation is used: whereŷ denotesŶ = 1, and probability P (c i ) can be obtained from some sources, such as government census data. The algorithm for UST is presented in Algorithm 1.
The complexity for UST algorithm is O(n), where n is the size of D T est , i.e. linear to the number of test records.

Experiments
In this section, we first demonstrate UST algorithm can correct the spurious associations generated by collider. Then, we simulate the audit process by using real-world data set. We only compare UST with NST in population-level sampling since other situation test methods, such as, CST [30], k-NN based situation test [16] need to access training data set which is unavailable in our problem. We also demonstrate that data-based audit method fails in unrepresentative sampling but UST works. Finally, we apply the UST algorithm to compare fairness for different models and guide the audit agency to choose the model. The experimental settings and details can be found in the Appendix.

Correcting collider biases
We construct synthetic data sets including a collider as discussed in the Appendix. UST has significantly reduced biases in CDE estimation. Bias is used to measure the error between an estimated CDE and the true CDE. Biases of including and not including a collider are shown in Table 2. The later is the UST method which corrects biases of a collider in data by directly using Corollary 2.  6.2 Simulating an audit process using Adult data set The Adult data set from UCI Machine Learning Repository [2] is used to simulate audit process as shown in Figure 4. We use the Adult data set as the population for generating the ground truths. A company has a sample (50%) as the private data to build a model. The red dashed line represents the information that the audit agency has access to. The ground truths are generated from the population and all causes of Y . Race is the protected variable and Salary is the outcome. Other variables are Education level, Marriage statues, Work hour, Work class, and they all determine the salary. We simulate a Suburb variable as a collider. The accuracy of a classifier is significantly higher when the Suburb is used than not as shown in Table 3. The accuracy improvement is due to the spurious associations.

Comparing the audit performance of NST and UST
We apply UST to audit a few well-known classifiers built from sample data set. NST (introduced in the introduction) is used for the comparison since it is the only method for assessing the fairness of a classifier without accessing the training data set.
We use precision and recall for the comparison. The ground truth for each audit case is calculated by using the population and the causes of Y . Audit cases are k% records randomly selected from the population. For each k, we resample audit cases 10 times and report the average precision and recall.
UST outperforms NST in both precision and recall as shown in Table 4. With the increasing number of audit cases, the deviations of both methods decrease. From the gaps between the precision and recall of NST and UST, we see that the collider bias deteriorates the detection performance of NST significantly.

Data based audit may be biased
Removing the collider from the data can be used as an alternative method to UST. However, a data-based audit (DBA) relies on the representativeness of the audit cases for the population. The representativeness is difficult to be ensured because individuals who receive unfair treatments likely require the authority to audit their results. An audit agency does not have a resource to collect a representative sample for auditing.
We simulate the unrepresentative audit cases by over (under) sampling discriminatory cases in the population. In the Adult data set, about 15% of the individuals are discriminatory and this ratio is the baseline. We vary discriminatory ratios in k = 1% audit cases.
The performance of DBA deteriorates significantly when a discriminatory ratio deviates from the baseline as shown in Table 5. Note that all discrimination detection methods based on data have the same limitation. In contrast, UST maintains similar performance.

Rank models based on fairness
We show that UST can be used for comparing the fairness of different models. We first discuss the metrics for the comparison. After discrimination detection on a model using audit cases with ground truths, we obtain True Positive (TF), False Positive (FP), True Negative (TN), and False Negative (FN).
FN indicates the cases that are unfair but are corrected to be fair by the model. They are favourable for fair predictions, and we use correction rate, CR = F N T P +F N , to represent the proportion of true unfair cases being corrected by a model. In contrast, FP represents that the cases that are fair become unfair after model predictions. These cases are called reversed discrimination and are unfavourite for predictions. We use the reversion rate, RR = F P F P +T N , to represent the proportion of fair cases being reversed by a model. We wish the revision rate is as small as possible. The correction rate and reversion rate of four classifiers are shown in Table 6. Random Forest is the fairest model based on the two measures. Random Forest has corrected 35.24% of unfair cases, and only reversed 1.07% of fair cases to unfair. Note that, their prediction accuracies are very similar, but their correction rate and reversion rate are different. This assessment shows that some errors made by a model are better than others in terms of the fairness of a model.

Related Works
The work belongs to discrimination detection. Detection methods are divided into the group, and individual-based. Another division of the methods is association or causal based.
At the group level, a number of metrics have been defined to detect discrimination. Demographic parity, a well-known fairness measurement, is defined by [7,27]. Other measurements including equalised odds [10], predictive rate parity [26]. However, these group-based fairness does not necessarily mean individual fairness. Many algorithms focus on detecting discrimination at the individual level. Authors in [22] use existing inequality indices from economics to measure individual level fairness. Speicher et al. [15] propose an individual level discrimination detector, which is used to prioritise data samples and aims to improve the subgroup fairness measure of disparate impact.
Under the causal framework, Li et al. [14] use the (conditional) average causal effect to quantify fairness for (sub)group level discrimination detection. Counterfactual fairness [13] is an attractive definition of individual level fairness measurements by causality. It means that a decision is fair towards an individual if it is the same in both the actual world and a counterfactual world (when a value of a protected variable is changed). However, it needs strong assumptions. authors in [18,28,31] use nature direct effect and nature indirect effect to quantify fairness. The path-specific causal effect [4,25,32] have been used to quantify fairness when the regulatory policy recognises some causal paths involving a protected variable fair. Nature direct (indirect) effect and path-specific causal effect all need counterfactual reasoning and are difficult to implement in practice since the strong assumptions are related to counterfactual reasoning.
Situation test related work has been discussed in the introduction and hence is omitted here. The above-mentioned related work only introduces some influential contributions. For more related work, please refer to the literature review [3,6,17,29].

Conclusions
In this paper, we have discussed collider bias in fairness assessment. We have presented theoretical results based on the graphical causal model to avoid collider biases in fairness assessment. The results are useful for discrimination detection and also for feature selection for building fair classifiers. We have proposed an Unbiased Situation Test (UST) algorithm for the fairness assessment of a classifier without accessing the training data set or a sample of the population. Experimental results show that UST effectively reduces collider biases and can be used to assess the fairness of a classifier without accessing to data. The UST is promising for an audit agency to audit machine learning models by private companies and organisations.

Synthetic data sets
We construct synthetic data sets by Tetrad [21]. We use a causal graph shown in Figure 5 with 7 variables, including a protected variable A, an outcome variable Y , other observed variables, X 1 , X 2 , X 3 , X 4 , and a collider variable C.
We use the simulation function from Tetrad package to randomly generate 5 data sets with 50,000 records. The use of 50,000 records is to ensure the faithfulness between the generated data and the causal graph. We employ the PC algorithm [23,24] to learn causal structure from synthetic data sets (setting parameter α = 0.05). Every learnt causal graph is equivalent to the original causal graph under Markov Condition. The above process are shown in Figure  6.   The Adult data set from UCI Machine Learning Repository [2] records 14 variables such as individual information, occupation information and education background on 48842 instances along with their salary. In this experiment, we only consider whether there is discrimination on race.

Adult data set
We keep variables which are causes of salary, and remove records with non white/black, and with missing values. After data preprocessing, there are 46447 instances with 6 variables in the final data set. The distribution of the variables is shown in Table 7. We use the same causal graph generated by [18] in this experiment and assume it represents the regulations. Marriage statues, Education level, Work class, Work hour are legitimate variables to determine salary. The causal graph is drawn in Figure 7. In this causal graph, Work class and Work hour are shown in one variable since their relationships with other attributes are the same. Fig. 7. The causal graph for adult data set. The black lines show the original causal graph which is the same with [18]. Work class and Work hour are shown as one variable to simplify the graph. The black dash lines link to the synthetic collider.
We assume that suburb information is an effect of Salary and Race. The company makes use of Suburb to improve the performance of the classifier. The collider is represented by black dash line in Figure 7.
We follow the same procedure in [9] to generate the suburb for the adult data set. The generation rules are shown in Table 8. The distribution of collider is shown in Table 9.