\section{Introduction}
Due to an increasing ability to handle massive data with extraordinary model accuracy, machine learning (ML) algorithms have achieved remarkable success in many applications, such as computer vision \cite{KA2014VGG,SLJS2015GOOGLE,HZRS15Res,SVI2016INC} and natural language processing \cite{SVQ2014seq2,VSPU2017Attention,DCL2018BERT,YDY2019XLNET}.
However, empirical studies have also revealed that ML algorithms may incorporate bias from training data into model predictions. 
Due to historical biases, vulnerable groups are often under-represented in available data \cite{JJSL2016, ZWY2017, SEC2019}. 
As a consequence, without fairness considerations,  ML algorithms can be systematically biased against certain groups defined by protected attributes such as race and gender. 


As algorithmic decision-making systems are now widely integrated in high-stakes decision-making processes, such as in healthcare \cite{MQ2017} and criminal prediction \cite{JJSL2016}, 
fair machine learning has grown rapidly over the last few years into a foundational area of trustworthy AI. 
A main task in fair machine learning is to design efficient algorithms satisfying fairness constraints with a small sacrifice in model accuracy. 
This field has made substantial progress in recent years, as many effective approaches have been proposed to mitigate algorithmic bias \cite{ZWKT2013,CKYMR2016,CFDV2017,XWYZW2019,LV2019,CJG2019,DETR2018,CMJW2019,JL2019,CHS2020,ZDC2022}.

An important fundamental benchmark for fair classification is provided by fair Bayes-optimal classifiers, which maximize accuracy subject to fairness  \cite{MW2018,ZDC2022}. 
A representative class of classifiers is group-wise thresholding rules (GWTRs) over the feature-conditional probabilities of the target label, for each protected group (e.g., probability of repaying a loan given income). 
Intuitively, being a GWTR is a minimal requirement for within-group fairness, as it ensures that the most qualified individuals are selected in every group.
 \cite{CSFG2017,MW2018,CCH02019,I2020,SC2021,ZDC2022} have studied fair Bayes-optimal classifiers  under various fairness constraints and proved that,
for many  fairness metrics, the optimal fair classifiers are GWTRs. Moreover, the associated thresholds can be learned efficiently \cite{MW2018,ZDC2022}.


Current literature on Bayes-optimality focuses mainly on the independence- and separation-based fairness measures (e.g., demographic parity, equality of opportunity, equalized odds; see Section \ref{fm} for definitions and a review). 
However, sufficiency-based measures such as predictive parity are less commonly considered, possibly due to the complexity of their constraints. 
Sufficiency-based measures are often applied to assess recidivism prediction instruments \cite{FBC2016,DMB2016,C2017fair}. 
\cite{LSMH2019} shows that a particular sufficiency-based measure, group calibration,
is implicitly favored by unconstrained optimization: 
calibration error is bounded by the excess risk over the unconstrained Bayes-optimal classifier. 
For selective classification, \cite{LBRSP2021} finds that sufficiency-based representation learning leads to fairness. 
Despite these findings, little is known about (1) what the optimal fair classifiers under sufficiency-based measures are, and (2) how to learn them efficiently.
In this paper, we aim to answer these two questions by focusing on predictive parity, which requires that the positive predictive value (probability of a successful outcome given a positive prediction) be equalized among protected groups.
For example, in credit lending, for example,  predictive parity requires that, for individuals who receive the loans, the repayment rates are the same in different protected groups.

We study fair Bayes-optimal classifiers under predictive parity.
Perhaps surprisingly, our theoretical results reveal that  the  \emph{optimal fair classifiers are often, but not always group-wise thresholding rules}, depending on the data distribution. 
We identify a sufficient condition under which all fair Bayes-optimal classifier are GWTRs. 
Without this condition, 
we show that fair Bayes-optimal classifiers may not be a GWTR when the minority group is more qualified than the majority group. 
In these cases, predictive parity may have limitations as a fairness measure, as it can lead to within-group unfairness for the minority group. 
Our findings are a reminder that the improper use of fairness measures may result in severe unintended consequences. 
Careful analysis before applying fairness measures is necessary.


    
We then develop an algorithm, FairBayes-DPP, aiming for predictive parity. 
Our method is a three-stage plug-in method. 
In the first step, we use standard learning algorithms to estimate the group-wise conditional probabilities of the labels. 
In the second step, we check our sufficient condition. If the sufficient condition holds, in the third step
we apply 
a plug-in method 
for estimating the optimal thresholds under fairness for each protected group.
    
  
We summarize our contributions as follows.
\begin{itemize}
    \item We show that Bayes-optimal classifiers satisfying predictive parity may or may not be group-wise thresholding  rules (GWTRs), depending on the data distribution.
    
    \item We identify a sufficient condition under which all fair Bayes-optimal classifiers are GWTRs. 
    We show that, when the sufficient condition is not satisfied, imposing predictive parity while maximizing accuracy may lead to within-group unfairness for the minority group.
    
    \item We propose the  FairBayes-DPP algorithm  for fair classification.  
    We demonstrate that FairBayes-DPP  is computationally efficient, showing a solid performance in our experiments on a number of synthetic and standard empirical datasets.
\end{itemize}
    
    
    
    







\section{Related Literature}
\subsection{Fairness Measures}
\label{fm}

Various fairness metrics have been proposed to measure aspects of disparity in ML.
Group fairness \citep{CFM2009,DHPT2012,HPS2016} targets statistical parity across
 protected groups, while individual fairness \citep{JKMR2016,PKG2019,RBMF2020} aims to provide nondiscriminatory predictions
for similar individuals.  
In general, group fairness measures can be categorized into three categories. 


The first group consists of independence-based measures, which require independence between predictions and protected attributes; this includes demographic parity \cite{KC2012,ZWKT2013} and conditional statistical parity \cite{CSFG2017,I2020}. In  credit lending, independence means that the proportion of approved candidates is the same across different protected groups.
However, as discussed in \cite{HPS2016}, independence-based measures have limitations; 
and applying them often leads to a substantial loss of accuracy.

The second group consists of separation-based measures,
which require conditional independence between predictions and protected attributes, given label information. 
Typical examples in this group are equality of opportunity \cite{HPS2016,ZLM2018} and equalized odds \cite{HPS2016,ZVGGK2017}.  
In  credit lending, separation-based measures require that the individuals  who will  pay back (or default on) their loan 
have an equal probability of
getting the loan, despite their race or gender. 
Compared to independence-based measures, separation-based measures take label information into account, allowing for perfect predictions that equal the label. 
However, these measures can be hard to validate, as the label information is often unknown for some groups. For example, the repayment status is missing for individuals whose loan application is declined.

As a result, measuring predictive bias is more widely applicable. 
This leads to the third class, sufficiency-based measures \cite{PMK2017,C2017fair,LSMH2019}, where the label is required to be conditionally independent of the protected attributes, given the prediction. In credit lending, this requires that among the approved applications, the proportion of individuals who pay back the loan is equal across different groups.
Unlike independence- and separation-based measures that are well studied with solid theoretical benchmarks and efficient algorithms, sufficiency-based measures are less commonly investigated. 
A possible reason is that conditioning on the prediction
leads to a complex constraint, which is thus challenging to study and enforce algorithmically. 



\subsection{Algorithms Aimed at Fairness}
Literature on algorithms for fairness has grown explosively over the past decade.
Existing algorithms for fairness can be categorized broadly into three categories.
The first category is pre-processing algorithms aiming to remove biases from the training data. 
Examples include transformations \citep{FFMS2015,KJ2016,CFDV2017,JL2019}, fair representation learning \citep{ZWKT2013,CKYMR2016,DETR2018,CMJW2019} and fair data generation \citep{XYZ2018,SHC2019,XYfairplus,RKSR2021}. 
The second group is 
in-processing algorithms, which handle fairness constraints during the training process. 
Two common strategies are penalized optimization \citep{GCAM2016,NH2018,CJG2019,CHS2020}  and adversarial training \citep{ZLM2018,CFC2018,XWYZW2019,LV2019}. 
The former incorporates fairness measures as a regularization term into the optimization objective, while the latter tries to minimize
the predictive ability of the model with respect to 
the protected attribute. 

The third group is post-processing algorithms, aiming to remove disparities from the model output. 
The most common post-processing algorithm is the thresholding method \citep{BJA2016,MW2018,I2020,SC2021,ZDC2022}, adjusting thresholds for every protected group to achieve fairness.  In this paper, we propose a post-processing algorithm, FairBayes-DPP, to estimate the fair Bayes-optimal classifier under predictive parity. 


\section{Problem Formulation and Notations}\label{Pre_and _Not}
We consider 
classification problems where two types of feature are observed: the usual feature $X\in\mathcal{X}$, and the  protected feature $A\in\mathcal{A}$. 
For example, in loan applications, $X$ may refer to common features such as 
 education level and income, and $A$ may correspond to the race or gender of a candidate. 
As multiclass protected attributes are often encountered in practice, we allow $\mathcal{A}$ to have any number $K\ge1$ of classes, and let $\mathcal{A}=\{1,2,...,K\}$.
We denote by $Y$ the ground truth label. 
In credit lending, $Y$  may correspond to the status of repayment or defaulting on a loan.
The output $\widehat{Y}$ of the classifier aims to predict $Y$ based on observed features $X,A$.  
We consider randomized classifiers defined as follows:
\begin{definition}[Randomized classifier]
  A randomized classifier is a measurable function\footnote{We assume that, whenever needed, the sets considered are endowed with appropriate sigma-algebras, and all functions considered are measurable with respect to the appropriate sigma-algebras.}
  $f:\mathcal{X}\times\mathcal{A} \to [0,1]$, indicating the probability of predicting $\widehat{Y}=1$ when observing $X=x$ and $A=a$. We denote by $\widehat{Y}_f=\widehat{Y}_f(x)$ the prediction induced by the classifier $f$.
 \end{definition}
Group-wise thresholding rules (GWT rules/classifiers or GWTRs) over conditional probabilities are of special importance.
Consider an appropriate sigma-finite measure $\mu$ on $\mathcal{X}$ (such as the Lebesgue measure for measurable subsets of $\mathbb{R}^d$, $d\ge 1$, or the uniform measure for finite sets), and suppose that 
for all $a\in\mathcal{A}$ and $y\in \mathcal{Y}$,
the features $X$ have a conditional distribution $P_{X|a,y}$
given $A=a,Y=y$
with a density $dP_{X|a,y}$
with respect to $\mu$.
For all\footnote{To be precise, this conditional density is defined for $\mu$-almost every $x\in\mathcal{X}$; however for simplicity we say for all $x\in\mathcal{X}$. We use this convention without further mentioning through the paper.}
$x\in\mathcal{X}$
and $a\in\mathcal{A}$, let $\eta_a(x)=P(Y=1|X=x,A=a)$.  
 \begin{definition}[GWT rule/classifier]
  A classifier $f$ is a GWTR if there are constants $t_a$, $a\in\mathcal{A}$, and functions $\tau_a:\mathcal{X}\to[0,1]$, $a\in\mathcal{A}$,  such that for all $x\in\mathcal{X}$ and $a\in\mathcal{A}$
  \begin{equation}\label{gwtr}
      f(x,a)=I(\eta_a(x)>t_a)+\tau_a(x) I(\eta_a(x)=t_a),
  \end{equation}
 where $I(\cdot)$ is the indicator function.
 \end{definition}


Clearly, GWTRs choose individuals with the highest conditional probability in each group. 
This property is a minimal requirement for within-group fairness.
For example, a GWT recruitment tool ensures that the most qualified candidates are approved in every protected group. 

We consider predictive parity, which aims to ensure the same positive predictive value among protected groups:
  \begin{definition}[Predictive Parity]
  A classifier $f$ satisfies predictive parity if for all $a\in\mathcal{A}$,
   $$P(Y=1 |\widehat{Y}_f  = 1,A = a) =P(Y=1|\widehat{Y}_f  = 1).$$
  \end{definition}
We follow \cite{CHS2020, ZDC2022} to use the difference between positive predictive values to measure the degree of unfairness, defining the Difference in Predictive Parities (DPP) of a classifier $f$ as
$$\text{DPP}(f)=\sum_{a\in\mathcal{A}}|P(Y=1 |\widehat{Y}_f  = 1,A = a) -P(Y=1|\widehat{Y}_f  = 1)|.$$







\section{Fair Bayes-optimal Classifiers under Predictive Parity}
Since predictive parity is commonly considered in scenarios where false positives are particularly harmful \cite{LBRSP2021},
we study cost-sensitive  classification. 
For
a cost parameter $c\in[0,1]$, the cost-sensitive 0-1 risk\footnote{When $c=1/2$, cost-sensitive risk reduces to the usual zero-one risk.} of the classifier $f$ is defined as
$$R_c(f)=c\cdot P(\widehat{Y}_f=1,Y=0)+(1-c)\cdot P(\widehat{Y}_f=0, Y=1).$$
An unconstrained Bayes-optimal classifier for the cost-sensitive risk is any minimizer $f^\star\in \text{argmin}_f R_c(f).$  
A classical result is that all Bayes-optimal classifiers have the form 
$f^\star(x,a)=I(\eta_a(x)>c)+\tau I(\eta_a(x)=c)$, where $\tau\in[0,1]$ is arbitrary \cite{C2001CS, MW2018}. 
Taking  predictive parity into account, a fair Bayes-optimal  classifier is any  minimizer of the cost-sensitive risk among  fair classifiers:
\begin{equation}\label{bao}
    f_{PPV}^\star\in \underset{f: \text{DPP}(f)=0}{\text{argmin}} R_c(f).
\end{equation}



\subsection{GWT Fair Bayes-Optimal Classifiers under Predictive Parity}
We first  identify a sufficient condition under which  all fair Bayes-optimal classifier under predictive parity are GWTRs. 

\begin{condition}[Sufficient condition for Bayes-optimal classifiers to be GWTRs]\label{suff-con} 
\begin{equation*}
\underset{a\in\mathcal{A}}{\min}\,
P(Y=1|\,\eta_a(X)\geq c,A=a)
\geq\underset{a\in\mathcal{A}}{\max}\, P({Y=1}|A=a). \end{equation*}
\end{condition}
The sufficient condition \ref{suff-con} requires that the minimal group-wise positive predictive value 
$P(Y=1|\,\eta_a(X)\geq c,A=a)$
of the unconstrained Bayes-optimal classifier  is lower bounded by the maximal proportion of positive labels $P({Y=1|A=a})$ among groups. 
In other words, the  performances of different groups vary only moderately:  
the average performance of the most qualified class of each group---the points with $x$ such that $\eta_a(x)\geq c$---should be better than the overall performance $P({Y=1|A=a})$ of any of the other groups.  
Condition \ref{suff-con} holds if
$P({Y=1|A=a})\leq c$ for all $a\in\mathcal{A}$, 
because $P(Y=1|\,\eta_a(X)\geq c,A=a)\geq c$. 

This condition is particularly applicable in settings where $c$ is large, such as in credit lending, where false positives are more societally harmful than false negatives.
They are also relevant if $P({Y=1|A=a})$, $a\in\mathcal{A}$ are small, 
such as in online advertising where the probability of clicks is small.
Under this condition, we present our main result.

\begin{theorem}[Main result]\label{thm-GWTR}
Consider the cost-sensitive $0$-$1$ risk with cost parameter $c$. If
Condition \ref{suff-con} holds,
then all fair Bayes-optimal classifiers under predictive parity are GWTRs. 
Thus, for all $f_{PPV}^\star$ from \eqref{bao}, 
there are $(t_a)_{a=1}^{|\mathcal{A}|} \in [0,1]^{|\mathcal{A}|}$ and functions $\tau_a(x):\mathcal{X}\to[0,1]$, $a\in\mathcal{A}$,
such that \eqref{gwtr} holds.

\end{theorem}


Unlike for demographic parity or for equality of opportunity, 
where the fairness constraint is linear with respect to the probability predictions of the classifier $f$ \cite{MW2018}, the DPP constraint is non-linear with respect to $f$. 
As a consequence, previously used theoretical tools such as the Neyman-Pearson argument from hypothesis testing \cite{ZDC2022} are no longer valid in this case. 
Instead, we prove the result using a novel constructive argument. 
When Condition \ref{suff-con} is satisfied, 
for any classifier satisfying predictive parity, which is not a GWTR, we construct a GWTR that satisfies predictive parity and achieves a smaller classification error.
As a result, under Condition \ref{suff-con}, all fair Bayes-optimal classifiers are GWTRs. 

Overall, the proof of Theorem \ref{thm-GWTR} is quite involved, and requires a lot of careful casework and analysis.
The proof rests on three novel lemmas, Lemmas \ref{lem1}, \ref{lem2}, and \ref{lem3},  which establish some fundamental properties of the positive predictive value of group-wise thresholding rules; such as monotonicity properties with respect to the thresholding parameter. 
These tools may be valuable in future work.


\subsection{Fair Bayes-optimal Classifiers under Predictive Parity do not Need to be Thresholding Rules}
Next, we consider the case when the sufficient condition \ref{suff-con} does not hold. 
For simplicity, we consider a binary protected attribute $a\in\{0,1\}$ with 
\begin{equation}\label{unsuff-con}
{P(Y=1|\,\eta_a(x)\geq c,A=1)}<P(Y=1|A=0). \end{equation}

Our result shows that, under condition \eqref{unsuff-con}, there exist class probabilities $p_a$, $a\in\mathcal{A}$, such that no Bayes-optimal classifier under predictive parity is a GWTR.
\begin{theorem}\label{thm-imGWT}
Suppose that condition \eqref{unsuff-con} holds. 
Denote $t_1=\inf\{t: P(Y=1|\,\eta_1(X)\geq t,A=1)>P({Y=1|A=0})\}$. Suppose there exist $\delta_1,\delta_2>0$ such that $P(c+\delta_1<\eta_A(X)<t_1|A=1)=\delta_2>0$. 
Then, for all $p_1>2/(2+\delta_1\delta_2)$, no fair Bayes-optimal classifier under predictive parity is a GWTR.

\end{theorem}

The condition involving the constants $\delta_1,\delta_2>0$ ensures that $\eta_1(X)$ has positive probability to be strictly larger than $c$, which is a technical condition needed in the proof. 
Theorem \ref{thm-imGWT} shows that predictive parity may lead to within-group unfairness, whereby the most qualified individuals are predicted to be unqualified, for a better overall accuracy.
By definition, predictive parity requires that the qualifications of selected individuals are similar across the protected groups. Suppose there exists a highly qualified minority group in which most individuals are qualified. 
Selecting the most qualified individuals in this group leads to a very high standard.
As a result, many qualified individuals in other majority groups may be predicted to be unqualified using this standard, 
leading to accuracy loss. 
Conversely, if we select less qualified individuals in the highly qualified group, the lower standard allows more qualified individuals from the other groups to be selected, and increases accuracy. 



\section{FairBayes-DPP: Adaptive Thresholding for Fair Bayes-optimality}\label{sec-alg}
In this section, we propose the FairBayes-DPP algorithm (Algorithm \ref{alg:pre-par}) for fair Bayes-optimal classification under predictive parity.
As mentioned, the DPP constraint is non-linear with respect to the classifier $f$, and is also highly non-convex with respect to the model parameters, even if both the classifier $f$  and the risk function are convex with respect to these parameters. 
In such cases, 
incorporating fairness constraints as a penalty in the training objective may be hard due to potential harmful local minima. 
Therefore, we consider a different approach, developing a new three-step plug-in method based on Theorem \ref{thm-GWTR}.
Suppose we observe data points $(x_i,a_i,y_i)_{i=1}^n$ drawn independently and identically from a distribution $\mathcal{D}$ over the domain
$\mathcal{X} \times \mathcal{A} \times \mathcal{Y}$. 


\textbf{Step 1.}
In the first step, we apply standard machine learning algorithms to learn the feature- and group-conditional label probabilities $\eta$ based on the whole dataset.
Consider  a loss function $L(\cdot, \cdot)$ and the function class $\mathcal{F}=\{f_\theta: \theta\in\Theta \}$ parametrized by $\theta$. 
The estimator of $\eta$ is obtained by minimizing the empirical risk, $\widehat\eta_a(x):=f_{\widehat\theta}(x,a)$, where
\begin{align}\label{ht}
    \widehat{\theta}&\in \underset{\theta\in\Theta}{\text{argmin}}\frac1{n}\sum_{i=1}^nL(y_{i},f_{\theta}(x_{i},a_i)).
\end{align}
Here we use the cross-entropy loss, as minimizing the empirical 0-1 risk is generally not tractable. 
At the population level,
the minimizers of the risks induced by the 0-1 and cross-entropy losses are both the
true conditional probability function \citep{miller1993loss}.
\begin{algorithm}[tb]
   \caption{FairBayes-DPP}
   \label{alg:pre-par}
\begin{algorithmic}
   \STATE {\bfseries Input:}  Datasets $S=\cup_{a=1}^{|\mathcal{A}|}S_a$ with $S=\{x_{i},a_i,y_{i}\}_{i=1}^{n}$ and $S_a=\{x^{(a)}_{j},y^{(a)}_{j}\}_{j=1}^{n_a}$. Cost parameter $c\in[0,1]$.

   
   \STATE {\textbf{Step 1}:} Estimate $\eta_a(x)$ by $\widehat\eta = f_{\widehat\theta}$, with $\widehat\theta$ from \eqref{ht}
  
           \STATE {\textbf{Step 2}:} Check sufficient condition \ref{suff-con}.
   \STATE  Define, for all $t$,\qquad
 $\widehat{\text{PPV}}_{a}(t)=\frac{{\sum}_{j=1}^{n_a} I(y^{(a)}_j=1,\widehat{\eta}_{a}(x^{(a)}_j)\geq t)}{{\sum}_{j=1}^{n_a}I(\widehat{\eta}_{a}(x^{(a)}_j)\geq t)}$, \qquad $\widehat{P}(Y=1|A=a)=\frac{1}{n_a}\sum\limits_{i=1}^{n_a}y^{(a)}_j$.
    
  \IF{$\min_a\widehat{\text{PPV}}_{a}(c)< \max_a\widehat{P}(Y=1|A=a)$}
  \STATE {We recommend considering other fairness measures.}
  \ELSE
         \STATE {\textbf{Step 3}:} Find the optimal thresholds.
  Let {$t_{\min} = \min\{t: 
 \widehat{\text{PPV}}_{1}(t)\ge \max_a\widehat{P}(Y=1|A=a)
  \}.$}
  \FOR{$t \in \mathcal{T}=[t_{\min}, \max_j\widehat\eta_1(x^{(1)}_{j})]$}
  
    \FOR{$a\in\mathcal{A} \setminus\{1\}$}
    \STATE Find $\widehat{t}_a(t)$ such that   {$\widehat{\text{PPV}}_{a}(\widehat{t}_a(t))\approx\widehat{\text{PPV}}_1(t).$}
    \ENDFOR  
    \STATE Let $
\widehat{f}(x,a,t)
=\tilde{f}\left(x,a;\widehat t_1(t),\widehat t_2(t),...,\widehat t_{|\mathcal{A}|}(t)\right)
=I\left(\widehat\eta_{a}(x)\geq \widehat t_a(t)\right).$
\STATE Let $R_c(t)=\frac1n\sum_{i=1}^n c^{(1-y_i)}(1-c^{y_i})I(y_i\neq \widehat{f}(x_i,a_i,t)).
$
    \ENDFOR 
    \STATE Find $\widehat{t}=\underset{t\in \mathcal{T}_n}{\text{argmin}}R_c(t).$

\STATE {\bfseries Output:}  
$\widehat{f}_{PP}(x,a)=I(\widehat\eta_{a}(x)\geq\widehat{t}_a(\widehat{t}))$
    \ENDIF
    \end{algorithmic}
\end{algorithm}



\textbf{Step 2.}
In the second step, we check the empirical version of Condition \ref{suff-con} for the classifier derived in the first step. 
To be more specific, we divide the data into $|\mathcal{A}|$ parts,
according to the value of $A$: for $a\in\mathcal{A}$, 
$S_a=\{x^{(a)}_{j},y^{(a)}_{j}\}_{j=1}^{n_a}$, where $a^{(a)}_{j}=a$. 
Let, for all $t$ for which it is defined, $$\widehat{\text{PPV}}_{a}(t)=\frac{{\sum}_{j=1}^{n_a} I(y^{(a)}_j=1,\widehat{\eta}_{a}(x^{(a)}_j)\geq t)}{{\sum}_{j=1}^{n_a}I(\widehat{\eta}_{a}(x^{(a)}_j)\geq t)} \qquad \text{ and } \qquad \widehat{P}(Y=1|A=a)=\frac{1}{n_a}\sum\limits_{i=1}^{n_a}y^{(a)}_j.$$
We only divide by nonzero quantities here and below. 
To ensure that the quantities we divide by are nonzero, we restrict to  $t_a\in[0,\max_j(\widehat\eta_a(x^{(a)}_{j}))]$ when evaluating $\widehat{\text{PPV}}_{a}(t_a)$.
We check whether $\min_{a}\, \widehat{\text{PPV}}_{a}(c)\geq\max_a\, \widehat{P}(Y=1|A=a) $.\footnote{One could modify this to allow some slack; and perform a formal statistical hypothesis test of our sufficient condition.}
If this is not satisfied, we recommend considering other fairness measures, as predictive parity may not be appropriate in this case, see the discussion after Theorem \ref{thm-imGWT}. 
 If it is satisfied,
 we then move to step 3 to adjust the thresholds of the classifier aiming for predictive parity. 
 
\textbf{Step 3.} In the last step, we find the optimal thresholds under fairness.
Based on Theorem~\ref{thm-GWTR}, we consider the following  deterministic classifiers:
\begin{equation}\label{classifier1}
\tilde{f}(x,a;t_1,t_2,...,t_{|\mathcal{A}|})=I\left(\widehat\eta_{a}(x)\geq t_a\right),
\end{equation}
where $\widehat{\eta}$ is the estimate of $\eta$ from the first step, and $t_a$, $a\in\mathcal{A}$, are parameters to learn. 

We use the following strategy to estimate $t_a$, $a\in\mathcal{A}$: First, we fix the threshold for the group with $a=1$, say $t$. 
The positive predictive value for this group 
can then be estimated by $\widehat{\text{PPV}}_{1}(t)$.
To achieve predictive parity, we need to find thresholds for the other groups such that the positive group-wise predictive values are the same\footnote{Since a sample mean $n^{-1}\sum_{i=1}^n Z_i$ of iid random variables $Z_i$ has a variability of order $O_P(n^{-1/2})$, even if the true predictive parities are equal, the empirical versions may differ by $O_P(n^{-1/2})$. However, in our case we simply find the values $t_a,t$ for which they are as close as possible.}, i.e., find $t_a$, $a=2,3,\ldots,|\mathcal{A}|$, such that
\begin{equation}\label{thresh-estimate}
\widehat{\text{PPV}}_{a}(t_a)
\approx
\widehat{\text{PPV}}_{1}(t)
, \ \ \ \text{ for } a = 2,3,...,|\mathcal{A}|.
\end{equation}
As proved in Lemma \ref{lem1}, the positive predictive value for each group in the population is non-decreasing with the respective threshold $t_a$. 
As a consequence, we can search over
$t_a$, $a=2,3,\ldots,|\mathcal{A}|$, 
efficiently  via, for instance, the bisection method.\footnote{The empirical PPV is only approximately monotonic, but this does not cause problems.} 
Correspondingly, we consider the following range of $t$: $\mathcal{T}=[t_{\min},\max_j \eta_1(x^{(1)}_{j})]$ with
$$t_{\min} = \min\left\{t: 
\widehat{\text{PPV}}_{1}(t)\ge \max_a\widehat{P}(Y=1|A=a)
\right\}.$$

We denote by $\widehat t_a(t)$, $a=2,3,\ldots,|\mathcal{A}|$, the estimated thresholds given by \eqref{thresh-estimate}, writing $\widehat t_1(t)=t$ for convenience. 
We consider the classifier \eqref{classifier1} with these thresholds:
\begin{equation*
\widehat{f}(x,a,t)
=\tilde{f}\left(x,a;\widehat t_1(t),\widehat t_2(t),...,\widehat t_{|\mathcal{A}|}(t)\right)
=I\left(\widehat\eta_{a}(x)\geq \widehat t_a(t)\right).
\end{equation*}
Finally, we find $t$ that minimizes the cost-sensitive risk on the training data by searching over a grid $\mathcal{T}_n$ within $\mathcal{T}$:
$
\widehat{t}=\underset{t\in \mathcal{T}_n}{\text{argmin}}\left\{\frac1n\sum_{i=1}^n c^{(1-y_i)}(1-c^{y_i})I(y_i\neq \widehat{f}(x_i,a_i,t))\right\}.
$$
Our final estimator of the fair Bayes-optimal classifier is $\widehat{f}_{PP} = \widehat f_{\widehat t}$.
The FairBayes-DPP algorithm is related to the algorithms proposed for other fairness measures in  \cite{ZDC2022}, where a binary protected attribute is considered and closed-form optimal thresholds are derived. 
In contrast, FairBayes-DPP can handle multi-class protected attributes and does not rely on closed-form thresholds.
Similar to the methods from \cite{ZDC2022}, our algorithm enforces fairness 
only in the fast second step, where no gradient-based technique is applied. 
Thus, it is computationally efficient and the non-convexity of fairness constraint is no longer problematic. 
Our experimental results demonstrate that our method removes disparities and preserves accuracy.




\section{Experiments}

\begin{table
\caption{Classification accuracy and DPP of the true fair Bayes-optimal classifier and our estimator trained via logistic regression on a synthetic data example. See Section \ref{synth} for details.}
\label{table_synth}
\vspace{-0.2cm}
\begin{center}
\setlength{\tabcolsep}{5.7pt}
\renewcommand{\arraystretch}{0.95}
\begin{small}
\begin{sc}
\begin{tabular}{cc|cc|cc|cc}
\hline
\multicolumn{4}{c|}{Theoretical Value}  & \multicolumn{4}{c}{Logistic regression} \\\hline
\multicolumn{2}{c|}{Fair}  &\multicolumn{2}{c|}{Unconstrained}  &\multicolumn{2}{c|}{FairBayes-DPP}  &\multicolumn{2}{c}{Unconstrained}   \\\hline
  $p$ & ACC &DPP& ACC & DPP& $\widehat{\text{ACC}}$&$\widehat{\text{DPP}}$& $\widehat{\text{ACC}}$ \\\hline
0.2 & 0.814 & 0.000 & 0.814 & 0.049\,(0.036) & 0.813\,(0.005) & 0.046\,(0.037) & 0.813\,(0.005)\\
0.3 & 0.794 & 0.024 & 0.794 & 0.037\,(0.029) & 0.794\,(0.006) & 0.040\,(0.033) & 0.794\,(0.005)\\
0.4 & 0.781 & 0.050 & 0.781 & 0.035\,(0.029) & 0.781\,(0.006) & 0.054\,(0.029) & 0.782\,(0.005)\\
0.5 & 0.775 & 0.078 & 0.777 & 0.042\,(0.032) & 0.775\,(0.006) & 0.081\,(0.036) & 0.777\,(0.006)\\
0.6 & 0.778 & 0.113 & 0.781 & 0.038\,(0.031) & 0.778\,(0.006) & 0.113\,(0.037) & 0.781\,(0.006)\\\hline
\end{tabular}
\end{sc}
\end{small}
\end{center}
\vspace{-0.4cm}
\end{table}
\subsection{Synthetic Data}
\label{synth}
We first study a synthetic dataset to compare our method with the true Bayes-optimal fair classifier derived analytically using the true data distribution.

\textbf{Statistical model.}
Let $X=(X_1,X_2)\in \mathbb{R}^2$ be a generic feature, $A\in\{0,1\}$ be the protected attribute and $Y\in\{0,1\}$ be the label. 
We generate $A$ and $Y$ according to the probabilities $P(A=1)$, $P(Y=1|A=1)$ and $P(Y=1|A=0)$, specified below.
Conditional on $A=a$ and $Y=y$, $X$ is generated from a bivariate
Gaussian distribution $N((2a-1,2y-1)^\top,2^2I_2)$, where $I_p$ is the $p$-dimensional identity covariance matrix.
In this model,  $\eta_a(x)$ has a closed form, and we use it to find the true fair Bayes-optimal classifier numerically under the Condition \ref{suff-con}. More details about this synthetic model can be found in Section \ref{appendix-synth}.




 \textbf{Experimental setting.}
 We randomly sample $50,000$ training data points  and $5,000$ test data points. 
 In the Gaussian case, the Bayes-optimal classifier is linear in $x$ 
and thus we employ logistic regression  to learn $\eta_1(\cdot)$ and $\eta_0(\cdot)$. 
 We then
 search over a grid with spacings equal to $0.001$ over the range we identified in Section \ref{sec-alg}
for the empirically optimal thresholds under fairness.
 We denote  $\widehat{f}$ and $\widehat{f}_{PPV}$ the estimators of the unconstrained and fair Bayes-optimal classifiers, respectively.

We first evaluate the FairBayes-DPP algorithm under the  Condition \ref{suff-con}. We set the cost parameter $c=0.5$, while $P(A=1)=0.3$ and $P({Y=1|A=0})=0.2$.
It can be calculated that $P(Y=1|\,\eta_0(X)>0.5,A=0)\approx 0.613$, using \eqref{suff-gaussian} in the appendix. 
To consider settings with varied levels of fairness in the population, 
we vary $p=P({Y=1|A=1})$ from $0.2$ to $0.6$, with the DPP of unconstrained Bayes-optimal classifier grows from $0$ to $0.113$. 

Table \ref{table_synth} presents the classification accuracy and DPP of the true fair Bayes-optimal classifier and FairBayes-DPP trained via logistic regression over 100 simulations\footnote{Here, the randomness of the experiment is due to the random generation of the synthetic data.}. 
Our first observation is that, under predictive parity, the accuracy of the true unconstrained and fair Bayes-optimal classifiers is almost identical, indicating  that predictive parity under Condition \ref{suff-con} requires a very small loss of accuracy. 
This finding is consistent with the results in \cite{LSMH2019} that sufficiency-based measures are favored by unconstrained learning. 


Second, our FairBayes-DPP method  closely tracks the behavior of the fair Bayes-optimal classifier, controlling the accuracy metric ACC and unfairness metric DPP on the test data effectively.
When $|P({Y=1|A=1})-P({Y=1|A=0})|$ is small, FairBayes-DPP  performs similarly to the unconstrained classifier. 
However, when the data is biased against protected groups and $|P({Y=1|A=1})-P({Y=1|A=0})|$ is large, 
FairBayes-DPP  mitigates the disparity of the unconstrained classifier effectively, while preserving model accuracy. We further conduct extensive simulations to evaluate  the FairBayes-DPP algorithm with different model and training setups, as shown in the appendix. In particular, we also consider the  multi-class protected attribute case.






\subsection{Empirical Data Analysis}
{\bf Dataset.} We test FairBayes-DPP on two  benchmark  datasets for fair classification: ``Adult'' \cite{Dua2019} and ``COMPAS'' \cite{JJSL2016}. 
For each dataset, we randomly sample (with replacement) 70\%, 50\% and 30\% as the training, validation and test set, respectively. 
To further test the performance of our algorithm on a large-scale dataset, we conduct experiments on the CelebFaces Attributes (CelebA) Dataset \cite{CelebAdata}.


\begin{compactitem}
\item {\it Adult:} The target variable $Y$ is whether the income of an individual is more than \$50,000.  Age, marriage status, education level and other related variables are included in $X$, and the protected attribute $A$ refers to gender. 

\item {\it COMPAS:} In the COMPAS dataset, the target is to predict recidivism. Here $Y$ indicates whether or not a criminal will reoffend, while $X$ includes  prior criminal records, age and an indicator of misdemeanor. 
The protected attribute $A$  is the race of an individual,``white-vs-non-white''.

\item {\it CelebA:} CelebA dataset is a large-scale dataset with more than 200,000 face images, 
each with 40 attributes (including protected attribute ``gender'' and other 39 different attributes for prediction tasks). 
Our goal is to predict the face attributes $Y$ based on the images $X$ and remove bias with respect to gender  $A$ from the output. 
\end{compactitem}

\begin{figure}[t]
    \centering
    \includegraphics[scale=0.36]{both}
        \vspace{-0.2cm}
    \caption{Accuracy and difference in predictive parity on the Adult and  COMPAS datasets.}
    \vspace{-0.3cm}
    \label{fig-ad_co}
\end{figure}

 \textbf{Experimental setting.} 
 As algorithms for predictive parity are rarely considered in the literature, we use unconstrained learning as a baseline for our experiments. 
 For the ``Adult'' and ``COMPAS'' datasets, we adopt the same training setting as in \cite{CHS2020, ZDC2022}. The conditional probabilities are learned via a three-layer fully connected neural network architecture with 32 hidden neurons per layer. 
 For  ``CelebA'', we apply the training setting from \cite{WQK2020}. We learn the conditional probabilities by training a ResNet50 mode; \citep{HZRS15Res}, pretrained on ImageNet \cite{DDSLKL2009}. For all the datasets, 
Over the course of training the model on
the training set, we select the one with best performance on the validation set. 
In addition, we learn the optimal thresholds over the validation set to avoid overfitting.
All experiments use PyTorch. We refer
readers to the Appendix for more training details, including optimizer, learning rates, batch sizes and training epochs. 
We repeat the experiment 100 times for the Adult and  COMPAS datasets and five times for the CelebA dataset.\footnote{For the Adult and  COMPAS datasets, the randomness of the experiment comes from the random selection of the training, validation and test data, as well as the 
stochasticity of the batch selection in the optimization algorithm. 
For the CelebA dataset, the randomness is caused by the stochasticity of the optimization method.}




Figure \ref{fig-ad_co} presents the average performances of FairBayes-DPP and unconstrained learning on the Adult and  COMPAS datasets.
Our method achieves almost the same accuracy as the unconstrained classifier, and has a smaller disparity.  
To better compare our fair classifier with the unconstrained one, we  use the paired $t$-test to compare the DPP of the proposed algorithm ($\text{DPP}_{Fair}$) and of unconstrained learning ($\text{DPP}_{Base}$).  
We consider the following one sided test: 
$$\mathcal{H}_0: \text{DPP}_{fair}=\text{DPP}_{Base} \ \ \ \text{ v.s. }  \ \ \ \mathcal{H}_1:\text{DPP}_{fair}<\text{DPP}_{Base} .$$
The $p$-values of the tests are $3.90\times 10^{-4}$ for the Adult dataset and $3.09\times 10^{-8}$
for the COMPAS dataset. 
In both cases, these results provide evidence 
that our  FairBayes-DPP method  achieves a smaller disparity than unconstrained learning. 







Finally, we test FairBayes-DPP  on the CelebA dataset,
Here, we only consider 27 attributes\footnote{Among the 39 attributes,  12 are heavily skewed  with $ \min(P(Y=1|M),P(Y=1|F))<0.01$ or $\max(P(Y=1|M),P(Y=1|F))>0.99$ (where $M$ represents Male and $F$ represents Female) in the training, validation or test set. They are: 
 ``5 o'Clock Shadow'', ``Bald'', ``Double Chin'', ``Goatee'',  ``Gray Hair'', ``Heavy Makeup'', ``Mustache'', ``No Beard'', ``Rosy Cheeks'', ``Sideburns'', ``Wearing Lipstick'' and ``Wearing Necktie''.} 
 with $0.01\leq P(Y=1|M),P(Y=1|F)\leq 0.99$ in the training, validation, and test sets; to ensure that the training, validation and test sample sizes are large enough for each subgroup.
We further identify one attribute, ``Young'', that violates  Condition \ref{suff-con}. We calculate the per-attribute accuracies and DPPs  on the test set. Table \ref{Table-celeba} presents the results of the first six attributes;  the  remaining results are in the appendix. 
As we can see, even for the large-scale CelebA dataset with high dimensional image features, our algorithm mitigates the gender bias effectively, with almost no loss of accuracy. 






\begin{table
    \caption{Per-attribute accuracy and DPP of the FairBayes-DPP algorithm and unconstrained optimization on the CelebA dataset.}
        \label{Table-celeba}
        \vspace{-0.2cm}
\begin{center}
\setlength{\tabcolsep}{4.8pt}
\renewcommand{\arraystretch}{0.98}
\begin{small}
\begin{sc}
    \begin{tabular}{l|cc|cc}\hline
 \multirow{2}[1]{*}{Attributes}           &      \multicolumn{2}{c|}{Per-attribute Accuracy}&      \multicolumn{2}{c}{Per-attribute DDP}\\\cline{2-5}
                      & FairBayes-DPP& Unconstrained & FairBayes-DPP& Unconstrained \\\hline
 Arched Eyebrows      & 0.838   & 0.838   & 0.028   & 0.105 \\
 Attractive           & 0.825   & 0.827   & 0.080   & 0.157 \\
 Bags Under Eyes      & 0.853   & 0.852   & 0.021   & 0.071 \\
 Bangs                & 0.959   & 0.958   & 0.012   & 0.081 \\
 Big Lips             & 0.706   & 0.718   & 0.026   & 0.123 \\
 Big Nose             & 0.845   & 0.845   & 0.076   & 0.130 \\\hline
  \end{tabular}
  \end{sc}
\end{small}
\end{center}
  \vspace{-0.5cm}
\end{table}





\section{Summary and Discussion}
In this paper, we investigated fair Bayes-optimal classifiers under predictive parity. We proved that when the overall performances of different protected groups vary only moderately, all fair Bayes-optimal classifiers under predictive parity are GWTRs. We further proposed a  post-processing algorithm to estimate the optimal GWTR. The derived post-processing algorithm removes the disparity in unconstrained classifiers effectively, while preserving a similar test accuracy.

However, when our sufficient condition is not satisfied, the fair Bayes-optimal classifier under predictive parity may lead to within-group unfairness for the minority group. In the current literature, many algorithms directly apply penalized/constrained optimization to impose fairness. 
Our negative finding, however, is an important reminder  that careful analysis is required
before employing a fairness measure. 
The improper use of a measure may result in severe unintended consequences.  





\bibliographystyle{plain}
