If you haven’t read the first post on fairness, I suggest you go back and read it because it motivates why we’re talking about fairness for algorithms in the first place. In this post I’ll describe one of the existing mathematical definitions of “fairness,” its origin, and discuss its strengths and shortcomings.

Before jumping in I should remark that nobody has found a definition which is widely agreed as a good definition of fairness in the same way we have for, say, the security of a random number generator. So this post is intended to be exploratory rather than dictating The Facts. Rather, it’s an idea with some good intuitive roots which may or may not stand up to full mathematical scrutiny.

## Statistical parity

Here is one way to define fairness.

Your population is a set and there is some known subset that is a “protected” subset of the population. For discussion we’ll say is people and is people who dye their hair teal. We are afraid that banks give fewer loans to the teals because of hair-colorism, despite teal-haired people being just as creditworthy as the general population on average.

Now we assume that there is some distribution over which represents the probability that any individual will be drawn for evaluation. In other words, some people will just have no reason to apply for a loan (maybe they’re filthy rich, or don’t like homes, cars, or expensive colleges), and so takes that into account. Generally we impose no restrictions on , and the definition of fairness will have to work no matter what is.

Now suppose we have a (possibly randomized) classifier giving labels to . When given a person as input if gets a loan and otherwise. The *bias*, or *statistical imparity,* of on with respect to is the following quantity. In words, it is the difference between the probability that a random individual drawn from is labeled 1 and the probability that a random individual from the complement is labeled 1.

The probability is taken both over the distribution and the random choices made by the algorithm. This is the statistical equivalent of the legal doctrine of adverse impact. It measures the difference that the majority and protected classes get a particular outcome. When that difference is small, the classifier is said to have “statistical parity,” i.e. to conform to this notion of fairness.

**Definition: **A hypothesis is said to have *statistical parity* on with respect to up to bias if .

So if a hypothesis achieves statistical parity, then it treats the general population statistically similarly to the protected class. So if 30% of normal-hair-colored people get loans, statistical parity requires roughly 30% of teals to also get loans.

It’s pretty simple to write a program to compute the bias. First we’ll write a function that computes the bias of a given set of labels. We’ll determine whether a data point is in the protected class by specifying a specific value of a specific index. I.e., we’re assuming the feature selection has already happened by this point.

# labelBias: [[float]], [int], int, obj -> float # compute the signed bias of a set of labels on a given dataset def labelBias(data, labels, protectedIndex, protectedValue): protectedClass = [(x,l) for (x,l) in zip(data, labels) if x[protectedIndex] == protectedValue] elseClass = [(x,l) for (x,l) in zip(data, labels) if x[protectedIndex] != protectedValue] if len(protectedClass) == 0 or len(elseClass) == 0: raise Exception("One of the classes is empty!") else: protectedProb = sum(1 for (x,l) in protectedClass if l == 1) / len(protectedClass) elseProb = sum(1 for (x,l) in elseClass if l == 1) / len(elseClass) return elseProb - protectedProb

Then generalizing this to an input hypothesis is a one-liner.

# signedBias: [[float]], int, obj, h -> float # compute the signed bias of a hypothesis on a given dataset def signedBias(data, h, protectedIndex, protectedValue): return labelBias(pts, [h(x) for x in pts], protectedIndex, protectedValue)

Now we can load the census data from the UCI machine learning repository and compute some biases in the labels. The data points in this dataset correspond to demographic features of people from a census survey, and the labels are +1 if the individual’s salary is at least 50k, and -1 otherwise. I wrote some helpers to load the data from a file (which you can see in this post’s Github repo).

if __name__ == "__main__": from data import adult train, test = adult.load(separatePointsAndLabels=True) # [(test name, (index, value))] tests = [('gender', (1,0)), ('private employment', (2,1)), ('asian race', (33,1)), ('divorced', (12, 1))] for (name, (index, value)) in tests: print("'%s' bias in training data: %.4f" % (name, labelBias(train[0], train[1], index, value)))

(I chose ‘asian race’ instead of just ‘asian’ because there are various ‘country of origin’ features that are for countries in Asia.)

Running this gives the following.

anti-'female' bias in training data: 0.1963 anti-'private employment' bias in training data: 0.0731 anti-'asian race' bias in training data: -0.0256 anti-'divorced' bias in training data: 0.1582

Here a positive value means it’s biased against the quoted thing, a negative value means it’s biased in favor of the quoted thing.

Now let me define a stupidly trivial classifier that predicts 1 if the country of origin is India and zero otherwise. If I do this and compute the gender bias of this classifier on the training data I get the following.

>>> indian = lambda x: x[47] == 1 >>> len([x for x in train[0] if indian(x)]) / len(train[0]) # fraction of Indians 0.0030711587481956942 >>> signedBias(train[0], indian, 1, 0) 0.0030631816119030884

So this says that predicting based on being of Indian origin (which probably has very low accuracy, since many non-Indians make at least $50k) does not bias significantly with respect to gender.

We can generalize statistical parity in various ways, such as using some other specified set in place of , or looking at discrepancies among different sub-populations or with different outcome labels. In fact, the mathematical name for this measurement (which is a measurement of a set of distributions) is called the *total variation distance*. The form we sketched here is a simple case that just works for the binary-label two-class scenario.

Now it is important to note that statistical parity says nothing about the *truth *about the protected class . I mean two things by this. First, you could have some historical data you want to train a classifier on, and usually you’ll be given training labels for the data that tell you whether should be or . In the absence of discrimination, getting high accuracy with respect to the training data is enough. But if there is some historical discrimination against then the training labels are not trustworthy. As a consequence, achieving statistical parity for *necessarily *reduces the accuracy of . In other words, when there is bias in the data accuracy is measured in favor of encoding the bias. Studying fairness from this perspective means you study the tradeoff between high accuracy and low statistical disparity. However, and this is why statistical parity says nothing about whether the individuals behaves differently on (differently compared to the training labels) were the correct individuals to behave differently on. If the labels alone are all we have to work with, and we don’t know the true labels, then we’d need to apply domain-specific knowledge, which is suddenly out of scope of machine learning.

Second, nothing says optimizing for statistical parity is the *correct* thing to do. In other words, it may be that teal-haired people are truly less creditworthy (jokingly, maybe there is a hidden innate characteristic causing both uncreditworthiness and a desire to dye your hair!) and by enforcing statistical parity you are going against a fact of Nature. Though there are serious repercussions for suggesting such things in real life, my point is that statistical parity does not address anything outside the desire for an algorithm to exhibit a certain behavior. The obvious counterargument is that if, as a society, we have decided that teal-hairedness should be protected by law regardless of Nature, then we’re defining statistical parity to be correct. We’re changing our optimization criterion and as algorithm designers we don’t care* *about anything else. We care about what guarantees we can prove about algorithms, and the utility of the results.

The third side of the coin is that if all we care about is statistical parity, then we’ll have a narrow criterion for success that can be gamed by an *actively biased* adversary.

## Statistical parity versus targeted bias

Statistical parity has some known pitfalls. In their paper “Fairness Through Awareness” (Section 3.1 and Appendix A), Dwork, et al. argue convincingly that these are primarily issues of *individual fairness *and targeted discrimination. They give six examples of “evils” including a few that maintain statistical parity while not being fair from the perspective of an individual. Here are my two favorite ones to think about (using teal-haired people and loans again):

**Self-fulfilling prophecy:**The bank intentionally gives a few loans to teal-haired people who are (for unrelated reasons) obviously uncreditworthy, so that in the future they can point to these examples to justify discriminating against teals. This can appear even if the teals are chosen uniformly at random, since the average creditworthiness of a random teal-haired person is lower than a carefully chosen normal-haired person.**Reverse tokenism:**The bank intentionally does*not*give loans to some highly creditworthy normal-haired people, let’s call one Martha, so that when a teal complains that they are denied a loan, the bank can point to Martha and say, “Look how qualified she is, and we didn’t even give her a loan! You’re much less qualified.” Here Martha is the “token” example used to justify discrimination against teals.

I like these two examples for two reasons. First, they illustrate how hard coming up with a good definition is: it’s not clear how to encapsulate both statistical parity and resistance to this kind of targeted discrimination. Second, they highlight that discrimination can both be unintentional and intentional. Since computer scientists tend to work with worst-case guarantees, this makes we think the right definition will be resilient to some level of adversarial discrimination. But again, these two examples are not formalized, and it’s not even clear to what extent existing algorithms suffer from manipulations of these kinds. For instance, many learning algorithms are relatively resilient to changing the desired label of a single point.

In any case, the thing to take away from this discussion is that there is not yet an accepted definition of “fairness,” and there seems to be a disconnect between what it means to be fair for an individual versus a population. There are some other proposals in the literature, and I’ll just mention one: Dwork et al. propose that individual fairness mean that “similar individuals are treated similarly.” I will cover this notion (and what’s know about it) in a future post.

Until then!

“Now it is important to note that statistical parity says nothing about the truth about the protected class S. I mean two things by this. First, you could have some historical data you want to train a classifier h on, and usually you’ll be given training labels for the data that tell you whether h(x) should be 1 or -1. In the absence of discrimination, getting high accuracy with respect to the training data is enough. But if there is some historical discrimination against S then the training labels are not trustworthy. As a consequence, achieving statistical parity for S necessarily reduces the accuracy of h. In other words, when there is bias in the data accuracy is measured in favor of encoding the bias. Studying fairness from this perspective means you study the tradeoff between high accuracy and low statistical disparity.”

Could you clarify what you mean by “accuracy” here? I’m not sure if I understand what you want to say.

LikeLike

In the entire post, accuracy means “the percentage of labels in the data correctly output by h.” If the labels encode some historical bias, then to get rid of that bias (regardless of whether it’s justified) requires a hypothesis to go against what the training data is telling it to do. However, and this is where the above might be unclear, achieving statistical parity also doesn’t mean you’re getting the “right” predictions for the protected class either! You have no way to know if your training data is not trustworthy.

LikeLike

I wonder if this has anything to do with the famous Monty Hall Problem, the data (doors) you see are not equally probable because some door (data) has gone through a filtering process, and there is a false symmetry in the perception of the data distribution.

LikeLike

How can this be modified for the case when teal-haired people are actually not as creditworthy as other people?

LikeLike