The world’s leading publication for data science, AI, and ML professionals.

What is Really “Fair” in Machine Learning?

Evaluation and Representation of Fairness in modern ML

Looking at ways to measure and visualize fairness

Source
Source

(In)Equality In Machine Learning

A s the field of machine learning expands and the power of AI is being used to make crucial decisions, we start to wonder if machine learning algorithms are really "fair." Machine Learning algorithms are affecting decisions where discrimination and bias are present; our goal is to measure the outcome of such decisions and ensure equality during our predictions. Although Machine Learning models may help with human decision-making while saving time, results produced by ML algorithms can also show bias in favor of specific groups. Equality in machine learning is a new field being constantly explored by researchers as the need to measure and maintain fairness is becoming increasingly important.


Machine learning algorithms cannot function without data. Data is the key to decision-making in Machine learning; thus, many biases emerge from the training data. Bias in data is mostly caused by human collection methods and misinformation or little information towards minority groups. While some could argue that changing data-gathering methods can reduce the favor of one group over the other, the truth is, in most scenarios equality during data collection cannot be ensured. Instead, we need to have models produce outputs that are not affected by potential bias factors such as race or gender. Knowing that the data could be unfair is by no means enough, we need to be able to measure and represent relations through these sensitive attributes to our predictions. These relations can be calculated and even visualized through tools and metrics thus better helping us understand inequalities in models and data.

Image by author created using Canva
Image by author created using Canva

Defining the Problem

As mentioned before, unfairness to certain groups is caused by "sensitive attributes" that may separate one category from another such as ethnicity or sex. In a perfect scenario, a model would predict some targets based on features provided without Discrimination to any groups. The simplest solution would be to remove such "sensitive attributes". However, simply taking those features away will not do much. Since most sensitive attributes are very distinctive among people, the model would still be able to infer the removed features based on other information provided. There are certain measurements or statistical properties that the predictions or the data must satisfy to be considered "fair".

Imagine a situation where multiple people are applying for a job with different experiences. Our goal is to predict whether someone will be offered the job based on their features. Here, A will represent the sensitive or protected feature, X will be any other information that tells us about the person applying, Y being the ground truth and Ŷ being our predictions.

We can formulate the problem by estimating the probability distribution of Y given features X and A. Then we can represent our prediction for a certain person as

when the ground truth is 1 concerning feature X and protected attribute A.


Evaluation Methods and Metrics

One of the most widely used criteria for measuring model prediction is the Demographic Parity.

To satisfy this property, Ŷ must be statistically independent of A. Simply, A cannot relate to the prediction of Y in any way no matter the values of the ground truth.

The demographic parity can be further expanded into the Strong Demographic Parity. In the previous case of Demographic Parity, we state that the binary model output must be independent of the sensitive attribute. A binary outcome is determined by a threshold on the continuous output of the model where if the prediction is greater than the threshold, we consider it 1. Demographic Parity can be enforced for a certain threshold but does not ensure it applies for all cases. On the other hand, Strong Demographic Parity imposes statistical independence between A and the continuous output from the model, further ensuring unbiases. In our scenario, without any other features, everyone should have the same chances of being offered a job no matter their sensitive attribute.

Similarly to Demographic Parity, there’s Equality of Opportunity. Equality of Opportunity only constrains equality in the advantaged outcome group. In our situation, it’s being offered the job. Equality of Opportunity allows the prediction to depend on A but only through the ground truth. Note that this method allows for using features that directly relate to the outcome, but does not tolerate using A to represent the result.

The true positive rate should remain the same for all values of A in the advantaged outcome. It’s less strict than the Demographic Parity, which ensures that the probability of our prediction being a certain class remains the same across all values of A no matter if the ground truth. Simply put, with a group of people with the same qualifications, they have the equal opportunity to be offered the job no matter their "sensitive attribute". This has a wider range of applications since most people only care about non-discrimination in the "positive group".

Finally, there’s Predictive Parity. Predictive parity, or sometimes called the outcome test, focuses more on the ground truth of Y. It requires given our prediction y-hat, the ground truth cannot depend on A as opposed to equality of opportunity it’s our predictions Ŷ that cannot relate to A.

This shows that the precision of our model, or the probability of Ŷ being positive and it truly belong to the positive class, should remain the same across all values of A.


A Gentle Intro to CBNs

Now that we’ve established a sense of how Fairness is measured and evaluated through our predictions, we turn our hands to visualizations. A Causal Bayesian network can represent scenarios and illustrate fairness through arrows and diagrams. Back to our situation:

  • For each person, we have features x that tell us about the person in some ways.
  • We also have A, the protected attribute, in our case, it’ll be gender.
  • Our predictions Ŷ will produce a probability between 0 and 1 representing whether the person will be offered a job or not.

Such a situation can be represented using a direct acyclic graph with nodes and edges called Casual Bayesian Network(CBN). In the bayesian network, nodes represent random variables or features relating to the problem while the edge between them shows their statistical dependencies.

As shown in the figure on the right below, A is considered a direct influence on Y if the path directly points to Y. This is considered a casual path. On the other hand(figure to the left), if A does not directly point to Y, it indicates that for A to potentially influence Y, it must go through X. When the influence of the sensitive attribute is represented through other features X, it is considered fair.

CBNs, Image by author using LucidChart
CBNs, Image by author using LucidChart

In this particular figure, the path from A to X represents the probability of X based on A, i.e. p(X|A). The path from X to Y again is the chances of Y being true based on X, p(Y|X). In a situation where there is no casual path from A to X, the joint distribution of the 3 variables is

A may influence Y, but not directly.

When any casual path is established between A and Y, the metrics mentioned above cannot be satisfied. There’s a lot more to CBNs and even using it to quantify unfairness, however, the basics of it are as simple as described above.


Conclusion

In this post, we have discussed various methods to measure fairness and even visualize relations associated with it. Unfairness may be hard or even impossible to eliminate in data, thus we need to be able to discover such inequality and able to decipher its influence on our model predictions.


Related Articles