FAIRGRAD: FAIRNESS AWARE GRADIENT DESCENT

Abstract

We address the problem of group fairness in classification, where the objective is to learn models that do not unjustly discriminate against subgroups of the population. Most existing approaches are limited to simple binary tasks or involve difficult to implement training mechanisms. This reduces their practical applicability. In this paper, we propose FairGrad, a method to enforce fairness based on a reweighting scheme that iteratively learns group specific weights based on whether they are advantaged or not. FairGrad is easy to implement and can accommodate various standard fairness definitions. Furthermore, we show that it is competitive with standard baselines over various datasets including ones used in natural language processing and computer vision.

1. INTRODUCTION

Fair Machine Learning addresses the problem of learning models that are free of any discriminatory behavior against a subset of the population. For instance, consider a company that develops a model to predict whether a person would be a suitable hire based on their biography. A possible source of discrimination here can be if, in the data available to the company, individuals that are part of a subgroup formed based on their gender, ethnicity, or other sensitive attributes, are consistently labelled as unsuitable hires regardless of their true competency due to historical bias. This kind of discrimination can be measured by a fairness notion called Demographic Parity (Calders et al., 2009) . If the data is unbiased, another source of discriminate may stem from the model itself that consistently mislabel the competent individuals of a subgroup as unsuitable hires. This can be measured by a fairness notion called Equality of Opportunity (Hardt et al., 2016) . Several such fairness notions have been proposed in the literature as different problems call for different measures. These notions can be divided into two major paradigms, namely (i) Individual Fairness (Dwork et al., 2012; Kusner et al., 2017) where the idea is to treat similar individuals similarly regardless of the sensitive group they belong to, and (ii) Group Fairness (Calders et al., 2009; Hardt et al., 2016; Zafar et al., 2017a; Denis et al., 2021) where the underlying idea is that different sensitive groups should not be disadvantaged compared to an overall reference population. In this paper, we focus on group fairness in the context of classification. The existing approaches for group fairness in Machine Learning may be divided into three main paradigms. First, pre-processing methods aim at modifying a dataset to remove any intrinsic unfairness that may exist in the examples. The underlying idea is that a model learned on this modified data is more likely to be fair (Dwork et al., 2012; Kamiran & Calders, 2012; Zemel et al., 2013; Feldman et al., 2015; Calmon et al., 2017) . Then, post-processing approaches modify the predictions of an accurate but unfair model so that it becomes fair (Kamiran et al., 2010; Hardt et al., 2016; Woodworth et al., 2017; Iosifidis et al., 2019; Chzhen et al., 2019) . Finally, in-processing methods aim at learning a model that is fair and accurate in a single step (Calders & Verwer, 2010; Kamishima et al., 2012; Goh et al., 2016; Zafar et al., 2017a; b; Donini et al., 2018; Krasanakis et al., 2018; Agarwal et al., 2018; Wu et al., 2019; Cotter et al., 2019; Iosifidis & Ntoutsi, 2019; Jiang & Nachum, 2020; Lohaus et al., 2020; Roh et al., 2020; Ozdayi et al., 2021) . In this paper, we propose a new in-processing approach based on a reweighting scheme that may also be used as a kind of post-processing approach by fine-tuning existing classifiers. Motivation. In-processing approaches can be further divided into several sub-categories (Caton & Haas, 2020) . Common amongst them are methods that relax the fairness constraints under consideration to simplify the learning process (Zafar et al., 2017a; Donini et al., 2018; Wu et al., 2019) . Indeed, standard fairness notions are usually difficult to handle as they are often non-convex and non-differentiable. Unfortunately, these relaxations may be far from the actual fairness measures, leading to sub-optimal models (Lohaus et al., 2020). Similarly, several approaches address the fairness problem by designing specific algorithms and solvers. This is, for example, done by reducing the optimization procedure to a simpler problem (Agarwal et al., 2018) , altering the underlying solver (Cotter et al., 2019) , or using adversarial learning (Raff & Sylvester, 2018) . However, these approaches are often difficult to adapt to existing systems as they may require special training procedures or changes in the model. They are also often limited in the range of problems to which they can be applied (binary classification, two sensitive groups, . . . ). Furthermore, they may come with several hyperparameters that need to be carefully tuned to obtain fair models. The complexity of the existing methods might hinder their deployment in practical settings. Hence, there is a need for simpler methods that are straightforward to integrate in existing training loops.

Contributions.

In this paper, we present FairGrad, a general purpose approach to enforce fairness for gradient descent based methods. We propose to dynamically update the weights of the examples after each gradient descent update to precisely reflect the fairness level of the models obtained at each iteration and guide the optimization process in a relevant direction. Hence, the underlying idea is to use lower weights for examples from advantaged groups than those from disadvantaged groups. Our method is inspired by recent reweighting approaches that also propose to change the importance of each group while learning a model (Krasanakis et al., 2018; Iosifidis & Ntoutsi, 2019; Jiang & Nachum, 2020; Roh et al., 2020; Ozdayi et al., 2021) . We discuss these works in Appendix A. A key advantage of FairGrad is that it is straightforward to incorporate into standard gradient based solvers that support examples reweighing like Stochastic Gradient Descent. Hence, we developed a Python library (provided in the supplementary material) where we augmented standard PyTorch losses to accommodate our approach. From a practitioner point of view, it means that using FairGrad is as simple as replacing their existing loss from PyTorch with our custom loss and passing along some meta data, while the rest of the training loop remains identical. This is illustrated in Figure 1 . It is interesting to note that FairGrad only brings one extra hyper-parameter, the fairness rate, besides the usual optimization ones (learning rates, batch size, . . . ). Another advantage of Fairgrad is that, unlike the existing reweighing based approaches which often focus on specific settings, it is compatible with various group fairness notions, including exact and approximate fairness, can handle both multiple sensitive groups and multiclass problems, and can fine tune existing unfair models. Through extensive experiments, we show that, in addition to its versatility, FairGrad is competitive with several standard baselines in fairness on both standard datasets as well as complex natural language processing and computer vision tasks.

2. PROBLEM SETTING AND NOTATIONS

In the remainder of this paper, we assume that we have access to a feature space X , a finite discrete label space Y, and a set S of values for the sensitive attribute. We further assume that there exists an unknown distribution D ∈ D Z where D Z is the set of all distributions over Z = X × Y × S and



Figure 1: A standard training loop where the PyTorch's loss is replaced by FairGrad's loss.

