{'fraction_non_alphanumeric': 0.027329925285096344, 'fraction_numerical': 0.004260060296238039, 'mean_word_length': 5.1453886427708415, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 1, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
On the relation between accuracy and fairness in binary classification

Our study revisits the problem of accuracy-fairness tradeoff in binary classification. We argue that comparison of non-discriminatory classifiers needs to account for different rates of positive predictions, otherwise conclusions about performance may be misleading, because accuracy and discrimination of naive baselines on the same dataset vary with different rates of positive predictions. We provide methodological recommendations for sound comparison of non-discriminatory classifiers, and present a brief theoretical and empirical analysis of tradeoffs between accuracy and non-discrimination.


Introduction
Discrimination-aware machine learning is an emerging research area, which studies how to make predictive models free from discrimination, when historical data, on which they are built, may be biased, incomplete, or even contain past discriminatory decisions. Research assumes that the protected grounds, against which discrimination is forbidden, are given by legislation. The goal for machine learning is to develop algorithmic techniques for incorporating those non-discriminatory constraints into predictive models.
A number of studies in discrimination-aware machine learning and data mining (Pedreschi et al., 2009;Kamiran et al., 2010;Calders & Verwer, 2010) focus on achieving equal acceptance rates (proportions of positive decisions) for favored and protected groups of individuals in binary classification. Forcing acceptance rates to be equal without taking into account other characteristics of individuals can be seen as an affirmative action, which introduces positive discrimination promoting the protected community. This may be desired for legal and political reasons.
We revisit this popular scenario of discrimination aware The 2 nd Workshop on Fairness, Accountability, and Transparency in Machine Learning, Lille, France. Copyright 2015 by the author. machine learning, and identify some pitfalls to avoid when comparing the performance of such classifiers, that is, a comparison may be misleading if the proportions of positive predictions of the classifiers are different. We provide methodological recommendations for sound comparison, and present a brief theoretical and empirical analysis of tradeoffs between accuracy and non-discrimination.

Problem setting and assumptions
Given a dataset that contains discrimination the goal is to build a classifier that would be as accurate as possible, and obey non-discrimination constraints. For example, a model could decide upon granting a loan given demographic information and financial standing, and considering ethnicity of an applicant (native, foreign) as the protected ground. We assume that the values of the target variable (labels) in the historical dataset are objectively correct, e.g. whether the loan has been repaid or not. For discrimination to happen the target variable needs to be polar, that is, one outcome (accept) should be preferred over the other (reject).
Let X denote a set of input variables (e.g. salary, assets), s denote the protected characteristic (e.g. ethnicity: native (w) or foreign (b)), and y denote the target variable (e.g. loan decision: accept (+) or reject (−)). A classifier maps X to y, that is,ŷ = f (X). Even though s is not among the input variables, some variables in X may be correlated with s (e.g. social security payment history may be shorter for foreigners, because they have arrived recently), and, as a result, classifier f may capture the protected characteristics, and induce indirect discrimination in decision making.
Let discrimination be measured as the difference in rates of acceptance: d = p(+|w) − p(+|b). Suppose that discrimination in the historical dataset is d 0 = δ, the desired discrimination in the classifier output is d ⋆ , the proportion of favored individuals in the data is p(w) = α, the prior probability of acceptance in the data is p(+) = π 0 , and the rate of acceptance in the classifier output is p f (+) = π.
Many classifiers produce probability scores (such as Naive Bayes or logistic regression). Typically, a probability score can be computed for non-probabilistic classifiers as well (such as kNN, SVM, decision trees). Individuals scoring above a threshold, which by default is typically 0.5, will get a positive decision. Considering available resources a decision maker can choose a different threshold. Suppose that the objective is to keep discrimination at the desired level d ⋆ (typically zero), and at the same time maximize the prediction accuracy. Effectively, by choosing the threshold a decision maker chooses the acceptance rate π.

Accuracy and fairness
The performance of discrimination-aware classifiers is typically compared by plotting discrimination vs. accuracy. An attempt to remove discrimination can easily produce classifiers with different acceptance rates π from those in the original dataset, especially when using off-the-shelve classifier implementations (e.g. WEKA 1 ), which simply round the numerical probability scores without any constraints on the positive output rates.
Our main message is that evaluation of nondiscriminatory classifiers must take into account rates of acceptance, otherwise classifier performance is not comparable, because changing the acceptance rate changes baseline accuracy and baseline discrimination.
A small experiment with a benchmark dataset (Adult from UCI 2 repository) illustrates the situation. The target variable describes whether a person has high income or low. The protected characteristic (gender) is not among the inputs. We randomly split the dataset into two halves: training and testing. We train a logistic regression (similar results have been obtained with Naive Bayes and decision tree J48) on a train set, output class probability scores for the test set, and vary the classification threshold from 0 to 1, which changes the acceptance rate π. We also plot the accuracy of a random classifier that does not use any inputs, but randomly decides upon the outcome given the probability of acceptance π. Figure 1 presents the results.
From the left plot we see that the more extreme the acceptance rate is (either all reject, or all accept), the closer the performance of an intelligent classifier (logistic regres-sion) is to that of a random classifier, which assigns labels at random. Therefore, better observed accuracy does not necessarily mean better classification ability, if the acceptance rates of the two classifiers are different. In order to be able to compare such classifiers we could normalize the accuracy with respect to π. Therefore, we suggest using for comparison a normalized accuracy, such as Cohen's Kappa (Cohen, 1960), which indicates by how much a classifier in question is better than a random classifier: where A is the accuracy of the classifier in question, and R is the accuracy of a random classifier, in our case where 1 means the ideal accuracy, and 0 indicates a random result 3 .
In the right plot we see how discrimination varies with different acceptance rates. There is no discrimination if everybody is accepted, or nobody is accepted, and the closer the acceptance rate π gets to these extremes, the smaller is d. This is not due to a better fairness of the classifier, because the classifier is exactly the same, and its output is the same, just the classification threshold varies. We would like to assess the fairness of the classifier, therefore, similarly to the accuracy, we need to normalize the result with respect to π.
We propose to normalize d by the maximum possible d max at each π. Discrimination would be at its maximum if a classifier ranks candidates in such a way that first everyone from the favored community is accepted, and only then candidates from the protected community start to be accepted 4 . In such a case the maximum discrimination is where α is the proportion of the favored community individuals in the data, and π is the acceptance rate.
We propose to normalize the discrimination measure by the maximum possible discrimination.
where d max given in Eq.
(2) is the maximum possible discrimination at a given acceptance rate. The maximum value of δ is 1, which means the worst possible discrimination, where the favored community has a complete priority, δ = 0 means no discrimination where people from the favored and protected communities fully mix in the queue. δ can be negative, indicating a reverse discrimination.
Figure 2 plots normalized accuracy κ and normalized discrimination δ of the logistic regression in our experiment. Large part of discrimination appears to be flat and closely in line with the discrimination in the data. The results now make sense, since the classifier in the experiment does not have any mechanisms for discrimination removal. At the extreme ends, where everybody is accepted, or everybody is rejected, intuitively, there is no discrimination, and the normalized measure correctly shows no discrimination.

Baselines and tradeoffs
It has been observed (Kamiran et al., 2010) that, assuming the labels in data are correct, discrimination removal comes at a cost -it reduces prediction accuracy. The authors have found given no constraints on the acceptance rates, that the maximum possible accuracy decreases linearly with reducing difference in rates of acceptance. We revisit the problem of accuracy-fairness tradeoff to see if the normalized measures would show similar relations.
An oracle is a fictional baseline classifier that has the maximum possible intelligence (as if it knows the true labels), and strives to satisfy non-discrimination constraints. A random classifier is the opposite, it does not use any intelligence. For each individual a random classifier makes a random prediction with the probability of acceptance π.
Suppose, a decision maker aims at removing all discrimination such that d ⋆ = 0 and δ ⋆ = 0. As suggested in (Kamiran et al., 2010), the oracle would either reduce the acceptance rate for the favored community (if α ≤ 0.5), or increase the acceptance rate for the protected community (if α > 0.5). The resulting decrease in classification accuracy would be linearly proportional to the discrimination in the data We find that if the rate of acceptance is to be fixed, that is π = π 0 , then the normalized accuracy of the oracle decreases linearly with decrease in normalized discrimination If the rate of acceptance does not need to be fixed, the optimal strategy is still the same -either to reduce acceptance for the favored community ("decrease males"), or to increase acceptance for the protected community ("increase females"), but the choice now depends not only on α, but also on π 0 and δ ⋆ . We do not have a closed form solution at the moment, but Figure 3 presents simulated results of the oracle classifier on the benchmark dataset (Adult). "Change both" is the solution where the acceptance rate is kept the same as in the original data. These experiments show the maximum possible accuracy, given the discrimination constraints. We can see that when using the normalized measures for accuracy and discrimination the upper bounds remain linear.

Interesting cases
We wrap up our study with an experiment to illustrate the difference between the raw and normalized measures when comparing non-discriminatory classifiers.
The experiment compares the performance of three classifiers (logistic regression, Naive Bayes and decision tree J48 from WEKA) trained using three different strategies: including the protected characteristic among classifier inputs, excluding the protected characteristic from classifier inputs, and excluding the protected characteristic from classifier inputs plus massaging the labels of the training data.
Massaging is perhaps the simplest discrimination removal strategy, it has been introduced in (Kamiran & Calders, 2009). Training labels are converted from binary to numeric using a ranker function, we use a logistic regression fit on the same training data. A number of lowest ranked males who have a positive label are changed to negative, and the same number of highest ranked females, who have a negative label, are changed to positive such that the positive rate remains the same as in the original data, but the discrimination is zero. Then a classifier is learned on this modified training data. Testing data is not modified. Table 1 presents the results measured on the testing data.
We can make several interesting observations. First, all classifiers tend to output lower acceptance rates than that in the original data. At the same time, if the protected characteristic is used, the discrimination measure d may show a decrease in the nominal discrimination as compared to the original data, but the normalized discrimination δ by all three classifiers is even higher than in the data. Apparently, a classifier learned on discriminatory data without any protective measures amplifies discrimination.
Removing the protected characteristic (no s) indicates little improvement in discrimination. This is due to, so called, redlining effect. A number of features in the data are correlated with the protected characteristic, therefore, discrimination is still captured, and, in cases of logistic regression and decision tree, is still higher than in the original dataset.
Interestingly, massaging strategy outputs higher acceptance rates than removing the protected characteristic. The acceptance rates of massaging are closer to the positive rates in the original data, and discrimination is lower, as expected. This suggests, that when discrimination is present in the training data, but usage of the protected characteristic is not allowed, classifiers tend to decrease the acceptance rate, which may show better nominal discrimination figures, but the real underlying discrimination (measured by normalized δ) remains.
Finally, Figure 4 presents normalized accuracies and discriminations at different acceptance rates. Overall we can see that massaging does remove some of discrimination, but at many acceptance rates the removal is not very precise, and sometimes even overshoots introducing a reverse  discrimination. This calls for a revision of the massaging, and possibly other discrimination removal techniques, taking into consideration possibility of different acceptance rates and normalized measures of discrimination.

Conclusion
Evaluation of non-discriminatory classifiers needs to take into account positive output rates, otherwise the comparison may be misleading and conclusions about comparative performance may be invalid.
We have introduced a normalization factor for discrimination measure, considering the maximum possible discrimination at a given acceptance rate. The maximum discrimination is present when the protected individuals start to be accepted only after everybody from the favored community is accepted.
Acceptance rates may be constrained by resources, and not freely available to choose for decision makes. If the acceptance rate in the data and in the classifier outputs is fixed, then classifiers are comparable in terms of A and d, otherwise they need to be compared in terms of κ and δ.