Why Put Fairness Into Model Fitting?
A fairness audit can identify a disparity in a fitted model. One response is to change how the model is fitted so that the chosen disparity is limited while predictive performance remains an explicit objective. This does not make a model universally fair: it makes a particular fairness definition part of a particular fitting procedure.
The first decision is therefore not a software setting. It is a definition: which quantity should be constrained, for which groups, and to what tolerance? A constraint on average predicted probabilities is not the same as a constraint on error rates or on the number of people selected after applying a cutoff. The chosen quantity determines both what the fit can guarantee and what its results mean.
Specify the Model, Objective, and Constraint
Consider a binary outcome \(Y_i\in\{0,1\}\), predictors \(x_i\), and a group label \(G_i\in\{A,B\}\). A logistic regression model assigns observation \(i\) the probability \(p_i=\Pr(Y_i=1\mid x_i)=1/(1+\exp(-x_i^\mathsf{T}\beta))\). Here \(\beta\) is the vector of model coefficients. For a fitting sample, define the group-average predicted probabilities as \(\bar p_A=n_A^{-1}\sum_{i:G_i=A}p_i\) and \(\bar p_B=n_B^{-1}\sum_{i:G_i=B}p_i\), where \(n_A\) and \(n_B\) are the sample sizes in the groups.
One possible fitting objective is the average Bernoulli log loss, \(-n^{-1}\sum_i\{y_i\log(p_i)+(1-y_i)\log(1-p_i)\}\). A score-parity constraint could require \(|\bar p_A-\bar p_B|\leq\epsilon\), for a prespecified tolerance \(\epsilon\geq0\). This constrains average predicted probabilities, not the actual outcomes, and not necessarily the rates of positive decisions after thresholding the probabilities.
This formulation makes three choices visible: the model family (logistic regression), the predictive objective (log loss), and the fairness requirement (a bound on the difference in group-average scores). A different objective or fairness quantity defines a different fitting problem. If regularization is also used, its penalty must be stated as part of the objective; fairness and regularization are distinct terms with distinct purposes.
Why the Log-Loss Objective Has This Form
The justification follows from the Bernoulli likelihood. Assume that, conditional on the predictors, observations have independent Bernoulli outcomes with model probabilities \(p_i\). The probability of the observed outcome \(y_i\) is \(p_i^{y_i}(1-p_i)^{1-y_i}\). Independence means the likelihood for the full sample is the product of these terms. Taking the negative logarithm changes the product into a sum:
Dividing by \(n\) changes the scale but not which unconstrained coefficient vector minimizes the loss. The fitting problem then minimizes this predictive loss only over coefficient vectors that satisfy the fairness restriction. The likelihood interpretation depends on the stated Bernoulli model and independence assumption; log loss can also be used as a predictive scoring rule, but this likelihood derivation does not establish that the model is correctly specified.
For a smooth score constraint, the average score changes with the model parameters. For example, the derivative of \(p_i\) with respect to \(\beta\) in logistic regression is \(p_i(1-p_i)x_i\). Thus the derivative of the group-average probability is the average of these terms within that group. This gives an optimizer information about how changing coefficients changes the constrained quantity. The absolute value can be written as two inequalities: \(\bar p_A-\bar p_B\leq\epsilon\) and \(\bar p_B-\bar p_A\leq\epsilon\).
State whether the constraint concerns average scores, selection rates, an error rate, or another specified quantity. Do not use the word “fairness” as if it named a single metric.
Specify the loss to minimize, such as Bernoulli log loss for a binary outcome. State any additional model restrictions or penalties separately.
Choose \(\epsilon\) in advance, then find a model minimizing the objective among models that meet the constraint. If no such model is feasible, the chosen model class and tolerance cannot be used together as specified.
Report predictive performance and the constrained fairness quantity, with uncertainty and the population or sample to which each result refers.
Worked Examples
Worked Example: Check a Score-Parity Constraint
A hypothetical insurer fits candidate binary models to eight records: four in each of two groups. In each group, the outcomes in record order are \(1,1,0,0\). Candidate U predicts probabilities \((0.90,0.80,0.40,0.30)\) for group A and \((0.70,0.60,0.20,0.10)\) for group B. Candidate C predicts \((0.75,0.65,0.35,0.25)\) for each group. The stated fitting requirement is that the absolute difference in group-average predicted probabilities be no more than \(0.05\). Check feasibility and compare average log loss. The method is to calculate the specified group means and then the Bernoulli log loss; the common mistake avoided is treating a small loss as proof that the fairness constraint is met.
Constraint for candidate U. Group A's mean is \((0.90+0.80+0.40+0.30)/4=2.40/4=0.60\). Group B's mean is \((0.70+0.60+0.20+0.10)/4=1.60/4=0.40\). The absolute difference is \(|0.60-0.40|=0.20\), which exceeds \(0.05\). Candidate U is infeasible.
Constraint for candidate C. Each group's mean is \((0.75+0.65+0.35+0.25)/4=2.00/4=0.50\). The absolute difference is \(|0.50-0.50|=0\), so candidate C is feasible.
Predictive loss for U. For a positive outcome the contribution is \(-\log(p_i)\); for a negative outcome it is \(-\log(1-p_i)\). In group A the four contributions are \(-\log(0.90)=0.10536\), \(-\log(0.80)=0.22314\), \(-\log(0.60)=0.51083\), and \(-\log(0.70)=0.35667\). Their sum is \(1.19600\). Group B's contributions are \(-\log(0.70)=0.35667\), \(-\log(0.60)=0.51083\), \(-\log(0.80)=0.22314\), and \(-\log(0.90)=0.10536\), also summing to \(1.19600\). The overall average loss is \((1.19600+1.19600)/8=0.29900\).
Predictive loss for C. In each group the contributions are \(-\log(0.75)=0.28768\), \(-\log(0.65)=0.43078\), \(-\log(0.65)=0.43078\), and \(-\log(0.75)=0.28768\). Each group sums to \(1.43692\), so the overall average loss is \(2(1.43692)/8=0.35923\). Rounded to four decimal places, U's loss is \(0.2990\) and C's is \(0.3592\). U has lower loss but violates the requirement; among these two candidates, C is the feasible one. A fitting algorithm would search the model class for the lowest-loss feasible fit, not simply select the lowest-loss candidate overall.
Worked Example: Interpret a Fairness Penalty
Suppose the same two candidate fits are compared using the soft objective \(J=L+\lambda D^2\), where \(L\) is average log loss, \(D=|\bar p_A-\bar p_B|\), and \(\lambda=2\). This method ranks models by a predictive loss plus a penalty for score disparity. The common mistake avoided is assuming that a penalty is a hard guarantee: a finite penalty makes disparity costly, but does not itself prohibit a model with disparity.
For U, the preceding calculations give \(L=0.29900\) and \(D=0.20\). Therefore \(D^2=0.04\), the penalty is \(2(0.04)=0.08\), and \(J=0.29900+0.08=0.37900\).
For C, \(L=0.35923\) and \(D=0\). Its penalty is \(2(0)^2=0\), so \(J=0.35923\). Since \(0.35923<0.37900\), C has the lower penalized objective among these two candidates.
The value of \(\lambda\) controls the relative cost assigned to disparity; it is not the same as the hard tolerance \(\epsilon\). For example, if \(\lambda=1\), U's objective would be \(0.29900+0.04=0.33900\), which is less than C's \(0.35923\). A penalty-based fit might then select U despite its nonzero disparity. The units and scale of the loss and disparity affect how \(\lambda\) behaves, so it should be chosen and assessed deliberately rather than interpreted as a universal fairness setting.
Worked Example: A Score Constraint Is Not a Thresholded-Decision Constraint
A hypothetical program assigns a positive decision when a predicted probability is at least \(0.50\). Two records in group A receive scores \(0.49,0.49\), and two in group B receive \(0.51,0.51\). A fitting team checks only the score-parity requirement \(|\bar p_A-\bar p_B|\leq0.03\). Determine whether that requirement is met and calculate the positive-decision rate in each group. The method is to compute group means and then apply the stated cutoff record by record; the common mistake avoided is treating average-score parity as a guarantee about decisions.
Group A's mean score is \((0.49+0.49)/2=0.49\); group B's is \((0.51+0.51)/2=0.51\). Their absolute difference is \(0.02\), which is no more than \(0.03\), so the stated score constraint is met. At the \(0.50\) cutoff, neither A record receives a positive decision, giving a rate of \(0/2=0\). Both B records receive a positive decision, giving a rate of \(2/2=1\). The difference in decision rates is \(1-0=1\), despite the score constraint being satisfied. Therefore the specified constraint cannot be reported as a guarantee of parity in thresholded decisions.
What the Constraint Changes—and What It Does Not
A constraint narrows the set of models the optimizer may choose. If the unconstrained minimum-loss model satisfies the requirement, imposing it may leave the solution unchanged. If it does not, a constrained fit can have greater predictive loss because the best-fitting model without the restriction may no longer be available. The size of that cost is an empirical result, not a general theorem that every fairness constraint must reduce performance.
Interpretation also changes. A coefficient vector from a constrained fit is the best fit under the specified restriction, not necessarily the unconstrained association between predictors and the outcome. If the sensitive group variable or its proxies are related to predictors, limiting group differences may alter several coefficients. A coefficient should therefore be interpreted in the context of the complete constrained fitting procedure, rather than as if it came from an otherwise ordinary fit.
The constraint is usually computed on a fitting sample. Sampling variation, small group sizes, changes in the population, or differences between the development and use populations can make the corresponding population quantity differ from the sample value. A constraint that holds in the fitting data is not, by itself, evidence that it will hold for future decisions. The relevant group definition, sample, tolerance, and uncertainty should be made clear when reporting results.
- Name the metric exactly. “Difference in mean predicted probability” and “difference in positive-decision rate” describe different quantities.
- Distinguish hard and soft requirements. A bound defines which fits are feasible; a finite penalty trades disparity against loss and need not make disparity zero.
- Check the deployed rule. If probabilities are later converted to decisions, evaluate the quantity that the decision process actually uses. A score constraint alone does not establish a decision-rate constraint.
- Report the tradeoff. State the predictive objective, chosen constraint, tolerance or penalty, and resulting values. Do not describe a model as simply “fair” without specifying the criterion.
Check Your Understanding
For each problem, identify the quantity being checked and show the relevant calculation before comparing with the stated requirement.
- A fitting constraint requires the absolute difference in average predicted probabilities to be at most \(0.10\). Group A has mean score \(0.62\) and group B has mean score \(0.54\). Is the fit feasible? (Answer: Yes; the difference is \(0.08\).)
- At a specified cutoff, 18 of 30 records in group A and 12 of 20 records in group B receive positive decisions. What is the difference in positive-decision rates? (Answer: \(0.60-0.60=0\).)
- A penalized objective is \(J=L+3D^2\). A candidate has \(L=0.24\) and \(D=0.10\). Calculate \(J\). (Answer: \(0.24+3(0.10)^2=0.27\).)
- A score constraint requires \(|\bar p_A-\bar p_B|\leq0.05\). The fitted group means are \(0.71\) and \(0.65\). Does the fit meet the constraint, and by how much does it exceed the tolerance if not? (Answer: No; the difference is \(0.06\), exceeding the tolerance by \(0.01\).)
- With a positive decision at scores of at least \(0.50\), group A has scores \(0.40,0.60\), and group B has scores \(0.45,0.55\). Calculate both average scores and both positive-decision rates. (Answer: Both average scores are \(0.50\); both decision rates are \(1/2=0.50\).)