Introduction#
Motivation#
As machine learning systems are increasingly deployed in high-stakes domains — hiring, lending, criminal justice, healthcare — ensuring that these systems do not exhibit discriminatory behavior is a critical requirement. Standard ML training procedures optimize predictive accuracy without regard for fairness, and post-hoc auditing provides no guarantees that a deployed model will satisfy fairness constraints on future data.
Seldonian algorithms [Thomas2019] address this gap by providing high-confidence guarantees that a learned model will satisfy user-specified behavioral constraints. The key insight is that the responsibility for enforcing fairness is shifted from the user (who audits after deployment) to the algorithm designer (who builds safety into the training procedure itself).
Problem Formulation#
Let denote a dataset of i.i.d. samples, and let denote the model returned by a learning algorithm . We define:
Primary objective : the quantity to be maximized (e.g., negative log loss).
Behavioral constraint : a fairness condition that must hold with high probability (e.g., bounded disparity in group-level true positive rates).
Confidence level : the minimum probability with which the constraint must be satisfied.
A Seldonian algorithm solves:
If no solution satisfying the constraint can be found with sufficient confidence, the algorithm returns No Solution Found (NSF) rather than a potentially unsafe model.
Framework Overview#
The Fair-Seldonian framework implements the Quasi-Seldonian Algorithm (QSA), which proceeds in three stages:
Stage |
Description |
|---|---|
1. Data Splitting |
The training data is partitioned into a candidate set and a safety set according to a configurable ratio (default 40/60). |
2. Candidate Selection |
An optimization procedure finds that maximizes subject to a predicted upper bound on computed from . This predicted bound accounts for the statistical uncertainty that will remain when the safety test uses . |
3. Safety Test |
The candidate is evaluated on using a concentration inequality (Hoeffding or Student’s t). If the upper bound on is non-positive, the solution is accepted; otherwise, No Solution Found is returned. |
Constraint Specification#
Behavioral constraints are specified as strings in reverse Polish notation (RPN) and parsed into expression trees for evaluation. The supported primitives are:
Primitive |
Conditions on |
Averaged over |
|---|---|---|
|
group and |
recall: predicted 1 among the group’s positives |
|
group and |
predicted 1 among the group’s negatives |
|
group and |
predicted 0 among the group’s negatives |
|
group and |
predicted 0 among the group’s positives |
|
group only |
predicted 1 and labelled 1, as a fraction of the whole group |
|
group only |
predicted 1 and labelled 0, as a fraction of the whole group |
|
group only |
predicted 0 and labelled 0, as a fraction of the whole group |
|
group only |
predicted 0 and labelled 1, as a fraction of the whole group |
|
group only |
predicted 1, whatever the label; equals |
|
group only |
predicted 0, whatever the label; equals |
Supported operators: +, -, *, /, ^, abs.
The distinction between the three kinds is easy to miss and it matters. A cell
such as TP(g) is a fraction of the whole of group — every row of
the group contributes, and the four cells sum to 1. A rate such as TPR(g)
is a mean over only that group’s positive rows, so it carries a smaller sample
size and a wider interval. Fairness constraints covers how to choose.
Example. The default constraint string:
TP(1) TP(0) - abs 0.25 TP(1) * -
encodes the infix expression:
This requires the gap between the groups’ true-positive cells to be at most 25% of group 1’s cell.
Note
This is not equal opportunity, despite the resemblance. Equal opportunity
compares true-positive rates — TPR(g), conditioned on —
and is available as
equal_opportunity(). The default
constraint compares cells, which is a different quantity computed over a
different set of rows.
Confidence Bound Propagation#
Evaluating requires computing confidence intervals for each
leaf node (e.g., TP(1)) and propagating them through the expression tree
using interval arithmetic. Four concentration inequalities are available, three
of them distribution-free:
Inequality |
Assumption |
Guarantee |
Half-width at n=2000, rate 0.1 |
|---|---|---|---|
|
the sample mean is approximately normal |
asymptotic only |
0.0131 |
|
each term lies in [0, 1] |
distribution-free |
0.0304 |
|
each term lies in [0, 1] |
distribution-free |
0.0225 |
|
each term lies in [0, 1] |
distribution-free |
0.0142 |
Hoeffding’s inequality [Hoeffding1963] is the default. For a bounded random variable with samples:
Empirical Bernstein and betting both adapt to the variance they observe, and are tighter than Hoeffding whenever a group’s rate is far from . Student’s t assumes the sample mean is approximately normal — an appeal to the central limit theorem rather than a finite-sample bound, and what puts the quasi in quasi-Seldonian. Concentration Inequalities derives each and shows where the ordering between them changes.
At each internal node of the expression tree, the confidence intervals of the
children are combined according to the rules of interval arithmetic
[Moore1966] (see fair_seldonian.constraints.bounds). The framework
provides several optimizations to tighten these bounds, described in
Algorithm Variants.