{'fraction_non_alphanumeric': 0.02242386316228619, 'fraction_numerical': 0.006535947712418301, 'mean_word_length': 5.210060449050086, 'pattern_counts': {'":': 0, '<': 0, '<?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': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Towards a Measure of Individual Fairness for Deep Learning

Deep learning has produced big advances in artificial intelligence, but trained neural networks often reflect and amplify bias in their training data, and thus produce unfair predictions. We propose a novel measure of individual fairness, called prediction sensitivity, that approximates the extent to which a particular prediction is dependent on a protected attribute. We show how to compute prediction sensitivity using standard automatic differentiation capabilities present in modern deep learning frameworks, and present preliminary empirical results suggesting that prediction sensitivity may be effective for measuring bias in individual predictions.


INTRODUCTION
In a recent New York Times article, a facial recognition algorithm incorrectly identified the wrong individual given a blurry image of a shoplifter [23]. The facial recognition system was found to perform noticeably worse when used to identify non-white demographics. A lack of diversity in the data set used to train the system was said to have contributed to the bias in the algorithm. In this particular case, this bias resulted in the wrongful arrest of a man for a crime of which he was innocent. Today, automated Artificial Intelligence systems are pervasive: they are used to automate the processes of hiring candidates [12,21], firing candidates [26] and in recommending consumer products based on our predicted emotions and those of our peer groups [31]. An error or erroneous prediction can therefore lead to the loss of a job, the loss of credit or economic and legal implications that can perpetuate cycles of vulnerability and poverty. On a larger scale, when we look at the total life-cycle of automated artificial intelligence systems, these automated systems will be adopted in some capacity by countries with less economic and political stability. Erroneous individual and group predictions can therefore lead to larger societal issues such as civic unrest and an increased mistrust of governments and larger institutions by citizens of those nations [24]. Unfortunately, numerous examples suggest that automated systems inherit and even amplify the biases already present in society [36]. The goal of fair AI is to better understand the origins of these biases and their impacts on society, and to develop mitigations and recommendations to improve the situation.
Defining Fairness. Fairness is defined as the degree to which judgments can be considered to discriminate against a particular individual or a group [30]. This acknowledges an ideal in which members of all groups are regarded as equal and no one group has dominance or influence over another.
However, Artificial Intelligence tends to reflect and amplify the unfairness we see in society, resulting in automated systems that demonstrate bias in favor of a particular individual or group. Historical events that perpetuated power dynamics (such as colonialism or imperialism) and disrupted the cultural and social economies of marginalized people have directly shaped today's society. We have quantified progress or proof of advocacy for fairness by measuring incremental improvements on these egregious systems of inequity and the devaluation of marginalized groups. Since data is a proxy for this history, unfairness in Artificial Intelligence systems therefore becomes an inevitable automation of these biases.
Measuring fairness turns out to be extremely challenging. Numerous formal metrics have been developed to measure fairness in machine learning systems [4,13,17,20,34,39], but no single metric completely captures our intuitive notions of fairness. Most metrics measure group fairness: they compare the rate of positive outcomes for privileged and unprivileged groups of individuals. As a result, a model that scores highly on a group fairness metric may still make blatantly unfair predictions for particular individuals as long as outcomes are similar on average. Measuring individual fairness [13] remains a challenging problem.
Fairness in Deep Learning. In this paper, we study the problem of fairness in the setting of deep learning. A number of approaches have been proposed to improve group fairness in deep neural networks [7,11,33,35,41,42], many of which yield large improvements in group fairness metrics without significantly affecting accuracy.
Prediction Sensitivity: a measure of individual fairness. In this paper, we propose a new approach designed to help understand fairness properties of individual predictions. Our approach measures the extent to which a prediction is based on the value of a protected attribute which encodes an individual's membership in either a privileged or unprivileged group.
We call this measurement the prediction sensitivity, due to its similarity to the idea of sensitivity in differential privacy [13,14]. We describe how to compute prediction sensitivity efficiently in standard deep learning frameworks via a novel application of automatic differentiation. Finally, we present preliminary empirical results from comparing prediction sensitivity to standard metrics for group fairness, suggesting that prediction sensitivity may be effective for understanding bias in trained models.
Prediction sensitivity is intended as a first step towards understanding individual fairness in deep neural networks. Like all formal metrics for fairness, there are vital aspects of societal bias that are not captured by the definition. An important example of this for prediction sensitivity is the problem of redundant encodings [13]: features in the data which are not marked as protected attributes, but which are correlated with the protected attribute. Prediction sensitivity measures (only) the effect of the protected attribute on the model's prediction, and ignores any effect that correlated attributes might have. As a result, it may be possible to train models with low prediction sensitivity (indicating fair predictions) that nevertheless make unfair predictions by relying on redundant encodings. This and other limitations of prediction sensitivity (detailed in Section 7) are important topics for future work.

CHALLENGES OF DEFINING FAIRNESS
The issue of fairness in Artificial Intelligence models is particularly complex because of the manner in which we create these models. Models are typically trained and learn from data but the process is a black box which is inscrutable and difficult to reproduce. There have been methods which attempt to address the inscrutability of models by measuring causality via identification of potential outcomes. One method used for inferring the causal reasoning of data is the potential outcomes framework or the Rubin causal model (Johansson et al., 2016) [18]. This method identifies the possibilities of potential outcomes of a model by looking at individual features and all possible outcomes. Causal inference makes unit-level causal effects difficult to observe, giving rise to the fundamental problem of causal inference. Feature level analysis also has trade-offs. Whenever features are individually assessed, phenomena such as Simpson's Paradox can become problematic and obscure issues which are attributable to bias [22]. In understanding the complexity of black box models, we have made efforts to simplify or decomplexify models to reason about why they make certain predictions.
Types of Bias. Bias can be defined as a systematic error or judgment. Bias often manifests based on assumptions that are proven to be untrue. These issues of bias can take place due to the data collection process, the data codification process, the feature selection and modelling process and the model prediction process. Human beings have inherent biases. These biases are aggregated and embedded within our data collection and analysis processes. One example of human bias is group attribution bias, whereby we judge a person as part of a monolithic group rather than as an individual,and project those tendencies of the generalized group to all individuals within that group. Implicit biases are an anecdotal extension of our experiences onto the larger group. These experiences are encoded into the data that we collect, the features we use, and the algorithmic predictions of our data. An example of bias that manifests in the data collection process is selection bias, whereby the data collected is not representative of the real world. An example of selection bias includes ethical issues in data collection that involve remuneration for giving access to one's data. In scenarios where remuneration is given, care must be taken so that the most economically disadvantaged persons are not giving away their data solely for the promise of remuneration rather than because they choose to do so. Participation bias (also called non-responsive bias) is another issue with data collection. This means that there are gaps in the data because of non-participation by certain groups of people. An example of participation bias might be a lack of persons willing to take part in a survey because the specificity of details in the survey may encourage doxing and retaliation by another group. Another bias is that of seeing cause in correlation or spuriousness, where a feature is identified as associated with a variable when there is no intrinsic correlation. This bias affects the model prediction process, resulting in wrongful predictions.
Group Fairness versus Individual Fairness. Fairness is often identified by one's relationship to a particular group, where the assumption is that no specific individual is regarded as more unequal than another within the group. This is typically referred to as Equality. More broadly speaking, everyone is treated the same regardless of the specificity of their characteristics; that is, in spite of these characteristics. Allocation is therefore based on the needs of the group rather than the needs of a specific individual. In another definition, each individual's characteristics are individually assessed, and fairness is assessed by these characteristics. Each individual is judged fairly based on their specific needs and requirements, and allocations take the needs of the individual into account. This is typically called Equity.
Measuring Fairness. A number of formal fairness metrics have been developed to measure fairness [13,17,20,34,39]; Barocas et al. [4] provide a comprehensive overview. These metrics are typically used to measure fairness by comparing the rates of positive predictions for members of the privileged and unprivileged group. They are typically defined in terms of a protected attribute, a feature in the data that indicates each individual's membership status in either the privileged or unprivileged group. Two specific metrics we will use in this paper are statistical parity [13] (also called demographic parity) and disparate impact [16]. Both are measures of group fairness.

BACKGROUND
Deep Learning. In this paper, we focus on machine learning models represented by artificial neural networks [19]. A model F is parameterized by a set of weights θ which are optimized during training; we write F (θ, x) to represent a prediction made by the trained model on an example x. Deep learning models are typically trained by optimizing a loss function L using a ground-truth label y for each example. We write the loss for an example x, y as L(F (θ, x), y). During training, the loss is used to update the weights θ so that loss is reduced during the next training epoch.
Automatic Differentiation. Automatic differentiation [5] is a computational method used to evaluate the derivative of a function efficiently. Automatic differentiation is normally used for computing the gradient of the loss with respect to the model's weights: This gradient is a vector containing the partial derivative of the model's output with respect to each of the weights. Automatic differentiation systems in modern deep learning frameworks are specifically designed to efficiently compute gradients for functions with many inputs, and they are usually used to calculate gradients during training.
Fairness in Machine Learning. The bulk of previous work on fairness in machine learning attempts to improve group fairness at training time, often by the introduction of new kinds of regularization [2, 3, 7-11, 15, 20, 27, 28, 32, 33, 35, 37-41]. Many of these approaches are suitable for deep learning, and have been empirically validated using the metrics described above.
Existing approaches focus on notions of group fairness, and are validated using metrics for group fairness. As a result, they can sometimes produce models that give blatantly unfair predictions for specific individuals, even though they score well on group fairness metrics.

PREDICTION SENSITIVITY
We propose prediction sensitivity, which quantifies the extent to which a prediction depends on the protected attribute. We hypothesize that models which rely heavily on the value of the protected attribute are likely to make different predictions for members and non-members of the advantaged group. Prediction sensitivity may therefore be a useful measure of individual fairness for each prediction made by the model.
The name "prediction sensitivity" comes from the connection to the notion of function sensitivity used in differential privacy [14]. Prediction sensitivity can be viewed as an approximation of function sensitivity for neighboring inputs that differ in their protected attribute. However, prediction sensitivity is not an upper bound on function sensitivity, as discussed later in this section. Prediction sensitivity is also related to the individual metric proposed by Dwork et al. [13], but prediction sensitivity can be efficiently computed for artificial neural networks.
Formal Definition. Formally, we assume the existence of a neural network architecture F such that for a vector of trained weights θ and feature vector x, we can make a predictionŷ as follows: For such a model F , we define the prediction sensitivity with respect to attribute a ∈ x as the partial derivative: Computing Prediction Sensitivity. Automatic differentiation libraries are commonly used to compute gradients of the loss during training; the same libraries can be used to efficiently compute prediction sensitivity. Given a loss function L and a training example x, y, for current weights θ , the training process might compute the gradient: ∇ θ (L(F (θ, x), y)) Here, we write ∇ θ to denote the gradient with respect to each weight in θ . Thus the gradient contains partial derivatives of the loss with respect to the weights. Deep learning frameworks like Ten-sorFlow are designed to compute gradients like these via automatic differentiation, but they are also capable of computing other types of gradients. To compute prediction sensitivity for a feature vector x, we want to obtain the partial derivative of the prediction with respect to one feature. Given a trained model consisting of F and θ , we can compute prediction sensitivity for the feature a as: This value can be efficiently computed using existing deep learning frameworks. We have implemented this approach in TensorFlow, and used it to obtain the empirical results in Section 6.
Properties of Prediction Sensitivity. Prediction sensitivity intends to capture the extent to which predictions depend on the protected status of an individual, but it is not always a perfect measurement of this dependence, and care must be taken in applying it. First, a model may predict positive outcomes for the advantaged group at a higher rate without relying on the protected attribute, and prediction sensitivity will not be useful in this case. Section 6 contains our preliminary empirical results suggesting that biased models often do learn to rely on the protected attribute in making predictions.
Second, prediction sensitivity measures sensitivity to changes in the protected attribute at one particular point, and small changes to one or more features could potentially increase or decrease prediction sensitivity significantly (in fact, the amount of this change is potentially unbounded). In most applications, we must assume that prediction sensitivity is fairly smooth-i.e. that small changes in features do not produce large changes in prediction sensitivity-in order for the measure to be useful. We hypothesize that most neural networks result in reasonably smooth prediction sensitivities; we discuss future work on this topic in Section 7.
Third, the scale of prediction sensitivity depends on the model's architecture and the trained weights, in addition to the features of the input example. As a result, it is not possible to compare prediction sensitivities across trained models. A prediction sensitivity of 0.1 may be relatively low for one model, and indicate a prediction that is minimally dependent on the protected attribute (e.g. the prediction sensitivity for the other features may be 10.0); the same prediction sensitivity may be very high for another model. We discuss the impact of this fact in Section 7.

APPLYING PREDICTION SENSITIVITY
Prediction sensitivity is designed to be a measure of individual fairness, but there are several different ways it could be applied to improve fairness in AI systems.
Fairness Monitor. One obvious opportunity for applying prediction sensitivity is as a way to measure the fairness of individual predictions made by a deployed model, and to signal an alarm for predictions that are not fair. A fairness monitor can be implemented by deciding on a prediction sensitivity threshold, calculating the prediction sensitivity for each prediction made, and signaling an alarm for each prediction whose sensitivity is above the threshold. We present a preliminary empirical evaluation of the potential for this approach to improve the fairness of predictions in Section 6.
The fairness monitor idea also has several unresolved challenges. First, it cannot improve predictions-only raise an alarm for bad ones-and it is still unclear how the feedback given by such an alarm could be used to improve the model. Second, it may be challenging to decide on a threshold in practice, especially because we expect that the appropriate setting for the threshold will depend on the training data, model architecture, and training algorithm used. Third, it may be difficult in practice to validate that a particular choice of threshold is the right one-the fairness monitor may result in both false negatives and false positives, and both classes of error may be difficult to identify.
Tracking Statistics. When a useful threshold is difficult to identify, prediction sensitivity could still be useful in measuring statistics about individual fairness of the predictions made by the deployed model. For example, the distribution of prediction sensitivities over many predictions might reveal low sensitivity for most predictions, with a few outliers-suggesting that these outliers should be investigated with the goal of improving the model. It might also reveal changes over time as the data used in making predictions starts to differ from the training data used to build the model.
Evaluating Models. We hypothesize that prediction sensitivity might also be useful for evaluating a trained model empirically to understand how it makes predictions. For example, the distribution of prediction sensitivities over a testing set might represent a useful measure for fairness comparable to metrics like statistical parity and disparate impact. Unlike those metrics, however, prediction sensitivity is a measure of individual fairness, and may therefore reveal additional information that metrics for group fairness cannot (e.g. for models that usually make fair predictions, but are blatantly unfair for some outliers). Our preliminary empirical results in Section 6 provide some support for this idea.

EMPIRICAL EVALUATION
To explore the feasibility of using prediction sensitivity to understand the fairness of a model's predictions, we performed an empirical evaluation using a simple neural network trained on the Adult dataset [1]. The bias in this dataset is well-documented [6]: models trained without mitigations demonstrate bias against unprivileged groups on both gender and race.
Using TensorFlow, We trained a simple neural network consisting of two fully-connected hidden layers to perform the binary classification task of the Adult dataset. We implemented two commonly-used metrics for group fairness: statistical parity [13] and disparate impact [16]. When evaluated on the gender attribute, our model (trained without any mitigations for fairness) yielded a statistical parity value of -0.04 and a disparate impact value of 0.53. Both of these values indicate bias against the unprivileged group.
Distribution of Prediction Sensitivity over Features. Figure 1 summarizes, using box-and-whisker plots, the distribution of prediction sensitivities from the model we trained for 14 features in the Adult dataset's test set. Features like education and occupation, which we might expect to have a large influence on income, indeed tend to have high prediction sensitivity. The gender and race features, which indicate an individual's membership in privileged or unprivileged groups, also have significant prediction sensitivitycontributing to the model's bias. Surprisingly, the relationship feature has the highest average prediction sensitivity-perhaps because this feature acts as a proxy for gender. This is an important issue for future work, discussed more in Section 7.
Effect of the Fairness Monitor. To measure how effective prediction sensitivity would be in building the fairness monitor described in Section 5, we evaluated this approach on the test set of the Adult dataset using two metrics for group fairness. For each example in the test set, we used our trained model to make a prediction, and measured the prediction sensitivity with respect to the "gender" feature. If the prediction sensitivity exceeded a threshold, we discarded the prediction (as a proxy for sounding the alarm described in Section 5); if not, we kept the prediction. Then, we evaluated only the "kept" predictions using a metric for group fairness (statistical parity or disparate impact). We repeated this experiment for various values of the threshold to determine the effect of the threshold's value on the group fairness metrics.
The results appear in Figures 2 (for statistical parity) and 3 (for disparate impact). In both cases, we see that the group fairness metric improves as the threshold for prediction sensitivity goes down. This effect shows that the individual measure of fairness provided by prediction sensitivity may be well-aligned with the group-level measures of fairness already in common use, suggesting that prediction sensitivity may indeed be useful in measuring the fairness of individual predictions made by a model.

DISCUSSION & FUTURE WORK
Limitations of Preliminary Results. Our preliminary results suggest that prediction sensitivity may be a useful measure of individual fairness, but more study is needed to understand it fully. In particular, it is challenging even to define the meaning of false negatives and false positives in the setting of a fairness monitor-doing so would require a "ground truth" about the fairness of a particular prediction, which is impossible to formalize. Our experiments also do not measure the affect of the fairness monitor on accuracy, since discarding predictions is not realistic during deployment anyway. We expect that in any intervention based on prediction sensitivity, a tradeoff will exist between fairness and accuracy, and we plan to investigate this further in the future. Finally, our experiments examined only a single dataset and trained model; we plan to extend our evaluation to additional datasets and a variety of models in future work.
Smoothness of Prediction Sensitivity. As mentioned earlier, prediction sensitivity measures the effect of changes in the protected attribute on the model's prediction at a particular point, but does not say anything about prediction sensitivity at nearby points. For example, prediction sensitivity may be very low for a particular example, but a slightly modified example may result in very high prediction sensitivity. As a result, it may be impossible to set a reasonable threshold for an application like a fairness monitor that avoids blatant false negatives; this effect also means that it is not possible to compare prediction sensitivity values across trained models. In future work, we plan to develop an automated way to analyze the smoothness of prediction sensitivity for a particular trained model. Correlated Attributes. Prediction sensitivity does not address the possibility of non-protected attributes that are correlated with the protected attribute (also called a redundant encoding by Dwork et al. [13]). The model may use such an attribute to make its prediction, and ignore the protected attribute; in this case, the model may result in unfair outcomes for the unprivileged group, even when its prediction sensitivity with respect to the protected attribute is low. This possibility is a direct result of the way prediction sensitivity is defined: it measures one way the model could arrive at an unfair prediction (i.e. by relying on the value of the protected attribute), but ignores other ways that the same outcome could occur (e.g. by relying on a correlated attribute).
Our empirical results suggest that models which make unfair predictions (as measured by group fairness metrics like disparate impact) tend to rely on the protected attribute to do so. However, these results are for a single model trained on a single dataset; further experiments on additional models and datasets are needed. In addition, interventions during training to mitigate bias may have a large effect on the connection between group fairness and prediction sensitivity; we plan to study these as well.

RELATED WORK
As the problem of bias in machine learning becomes more apparent, an increasing amount of research has been devoted to the topic. Mehrabi et al. [30] provide a survey, including broad definitions of bias and fairness use in the field of Artificial Intelligence, and how these definitions lay the groundwork for empirical measures of fairness in the field today. The book by Barocas et al. [4] gives an excellent overview of the field of algorithmic fairness more generally.
The bulk of previous work on fairness in machine learning attempts to improve fairness at training time, often by the introduction of new kinds of regularization [3,8,10,32,[37][38][39]. Recent work in this area for deep learning (much of it leveraging adversarial learning) has demonstrated impressive empirical results, showing that the tradeoff between fairness and accuracy can often be successfully navigated in practice [7,11,33,35,41]. Other approaches are based on pre-processing, and do not require changes to the training process [2,9,27,28,40]. These approaches are suitable for deep learning, but typically do not provide the same level of accuracy as modifications to the training process. Finally, several approaches based on post-processing have been proposed [15,20].
Extensive work has also explored how to measure fairness, and why obtaining fairness in Artificial Intelligence is difficult. A number of different metrics have been proposed [4,13,17,20,34,39], most of them designed to ensure group fairness. Other metrics apply to specific cases; for example, Mansoury et al. [29] describe the importance of aggregate diversity and propose a methods for improving aggregate diversity in recommender systems. Individual fairness has also been studied [13], and has been extended to approaches for cross-cultural fairness that identifies and measures fairness based on subgroups [25]. Zhang et al. [42] shows how current methods of generalizing neural networks are faulty, and suggests a link between generalization and fairness.

CONCLUSION
We have proposed prediction sensitivity, a measure of individual fairness in deep neural networks that may help us understand sources of bias in automated systems based on Artificial Intelligence. We showed how to compute prediction sensitivity efficiently using existing deep learning frameworks, and we presented preliminary empirical results suggesting that prediction sensitivity may be a useful metric in measuring bias. We believe that prediction sensitivity is an important first step towards better understanding individual fairness, and we have identified a number of important areas for future study in that direction.