Fairlearn
Last reviewed
Apr 30, 2026
Sources
24 citations
Review status
Source-backed
Revision
v1 · 3,993 words
Improve this article
Add missing citations, update stale details, or suggest a clearer explanation.
Last reviewed
Apr 30, 2026
Sources
24 citations
Review status
Source-backed
Revision
v1 · 3,993 words
Add missing citations, update stale details, or suggest a clearer explanation.
Fairlearn is an open-source Python toolkit for assessing and improving the fairness of machine-learning models with respect to sensitive attributes such as race, gender, or age. The library combines a disaggregated evaluation framework, several bias-mitigation algorithms, and a set of benchmark datasets, all designed to plug into the scikit-learn fit/predict/transform API. The project was started in May 2018 by Microsoft Research as a small implementation accompanying the Agarwal et al. ICML paper A Reductions Approach to Fair Classification, expanded into a broader toolkit during 2019 and 2020, and moved to independent community governance in 2021. It is released under the MIT licence and lives at fairlearn/fairlearn on GitHub, with a documentation site at fairlearn.org.
Alongside AIF360, Fairlearn is one of the two most widely cited open-source toolkits for algorithmic fairness. Its central technical contribution is a clean implementation of the reductions framework for fair classification, in which a fairness-constrained learning problem is reduced to a sequence of standard cost-sensitive classification problems that any black-box classifier can solve. This reductions approach gave Fairlearn its name and remains the design idea that distinguishes the library from competing toolkits that focus more on cataloguing methods than on a single coherent framework.
Fairlearn began in May 2018 as a small Python package open-sourced by Miroslav Dudík at Microsoft Research to accompany "A Reductions Approach to Fair Classification" by Agarwal, Beygelzimer, Dudík, Langford, and Wallach, presented at the 35th International Conference on Machine Learning (ICML 2018) in Stockholm. The first release was narrow: a single ExponentiatedGradient reduction wrapping any binary classifier under demographic parity or equalised odds. It was essentially a reference implementation that let readers reproduce the paper's experiments.
During the second half of 2019 and into 2020 the project was expanded by Microsoft Research and Azure Machine Learning teams. The major additions: a metrics module built around MetricFrame, a ThresholdOptimizer postprocessing algorithm implementing Hardt-Price-Srebro (2016), a second reductions algorithm GridSearch based on Agarwal-Dudík-Wu (ICML 2019, "Fair Regression: Quantitative Definitions and Reduction-Based Algorithms"), and a Jupyter dashboard widget (later deprecated in favour of the Responsible AI Toolbox).
The state of the project at the end of this period was documented in Bird, Dudík, Edgar, Horn, Lutz, Milan, Sameki, Wallach, and Walker (2020), "Fairlearn: A toolkit for assessing and improving fairness in AI", Microsoft Research Technical Report MSR-TR-2020-32, May 2020. That whitepaper covers the API up through version 0.4.x and is still cited as the canonical Fairlearn reference.
In 2021 the project moved from Microsoft to neutral governance. The GitHub organisation fairlearn was created, the repository was migrated from microsoft/fairlearn to fairlearn/fairlearn, and a steering committee structure was set up under a separate fairlearn/governance repository. Microsoft remained a funder of maintainer work alongside Eindhoven University of Technology and Hugging Face.
In 2023, Hilde Weerts, Miroslav Dudík, Richard Edgar, Adrin Jalali, Roman Lutz, and Michael Madaio published "Fairlearn: Assessing and Improving Fairness of AI Systems" in the Journal of Machine Learning Research (volume 24, paper 257). It serves as an updated reference after the governance transition, documenting the adversarial mitigation, CorrelationRemover preprocessing, and the modern MetricFrame-based assessment workflow. As of 2025 the library is at version 0.13.0 (released 19 October 2025).
| Year | Milestone |
|---|---|
| 2018 (May) | First release as a small reductions package, accompanying Agarwal et al. ICML 2018 |
| 2019 | Expanded to include metrics, GridSearch, and ThresholdOptimizer; Azure ML team contributions |
| 2020 (May) | Bird et al. Microsoft Research Technical Report MSR-TR-2020-32 published |
| 2020 | Visualisation dashboard widget added (later deprecated) |
| 2021 | Project transitioned to community governance under fairlearn GitHub organisation |
| 2022 | MetricFrame-centric API stabilised; deprecation of legacy classes |
| 2023 | Weerts et al. paper published in Journal of Machine Learning Research |
| 2024 to 2025 | Continued releases adding datasets, adversarial mitigation, new metrics |
The Fairlearn documentation is unusually explicit about what the library is and is not. The maintainers state that fairness is a sociotechnical problem and cannot be reduced to a metric you compute and a constraint you enforce, because what counts as fair depends on social context and on whose harm matters. The library is positioned as a tool that helps a human decide where to look, not an automated debiaser.
The project favours harm-based language over the words bias and debiasing. The 2020 whitepaper distinguishes between allocation harms, in which a model affects who gets a resource or opportunity (a loan, a job interview, parole), and quality-of-service harms, in which a model performs differently for different groups (a speech recogniser with higher word-error rate on Black speakers, for example). A third principle, present in the code rather than the marketing material, is scikit-learn compatibility: almost every Fairlearn class follows the scikit-learn estimator interface, so a fairness-constrained classifier drops into an existing pipeline alongside StandardScaler, OneHotEncoder, and GridSearchCV with no special glue.
Fairlearn is organised as a single Python package, fairlearn, with a small set of submodules.
fairlearn.metrics.MetricFrame is the centrepiece of the assessment side of the library. It takes one or more performance metrics (any scikit-learn metric or custom callable), the true labels, the predicted labels, and a sensitive feature vector, and returns a pandas DataFrame of metric values disaggregated by group. The same object computes summary statistics across groups including difference, ratio, group_min, and group_max. Because MetricFrame accepts arbitrary metrics, it is also the recommended way to compute custom or domain-specific fairness measures. The metrics module also exposes scalar wrappers like demographic_parity_difference, demographic_parity_ratio, equalized_odds_difference, and equalized_odds_ratio.
fairlearn.reductions contains the in-processing mitigation algorithms based on the reductions framework. The two core classes are ExponentiatedGradient, an iterative algorithm that approximately solves a saddle-point problem over Lagrange multipliers and re-weights training samples each iteration; and GridSearch, which sweeps a grid of Lagrange multipliers and trains one classifier per grid point, returning a list of trade-off solutions. The implementation supports demographic parity, equalised odds, TPR parity, FPR parity, error rate parity, and bounded group loss. Both classes wrap any scikit-learn-compatible classifier or regressor as the base estimator, with the user providing a Moment object from fairlearn.reductions that defines the fairness constraint mathematically.
fairlearn.postprocessing.ThresholdOptimizer implements the Hardt-Price-Srebro 2016 method. Given an existing scored classifier and the sensitive attribute on held-out data, it computes a per-group decision threshold (or a randomised mixture of thresholds) such that the resulting classifier satisfies the chosen fairness constraint while remaining optimal for accuracy. It supports demographic parity, equalised odds, true positive rate parity, and false positive rate parity. The class is the right tool when retraining is expensive or impossible: it operates on classifier scores rather than the model itself.
fairlearn.preprocessing.CorrelationRemover is the only preprocessing method in the library. It removes linear correlation between sensitive features and non-sensitive features, leaving a transformed feature matrix any standard learner can use. Unlike AIF360, Fairlearn does not implement many preprocessing methods; users who need richer preprocessing are encouraged to combine Fairlearn metrics with AIF360 preprocessing transforms. fairlearn.adversarial.AdversarialFairnessClassifier and AdversarialFairnessRegressor, added in later releases, implement adversarial debiasing in which a predictor and an adversary are trained jointly so the adversary cannot recover the sensitive attribute from the predictor's outputs. This is a PyTorch-backed in-processing method that fits with deep-learning pipelines.
fairlearn.datasets provides loader functions for benchmark datasets used in the fairness literature.
| Function | Dataset | Task | Sensitive features | Notes |
|---|---|---|---|---|
fetch_adult | Adult / Census Income | Binary classification | Sex, race | UCI; income > 50,000 USD; most cited fairness benchmark |
fetch_diabetes_hospital | Diabetes 130-Hospitals | Binary classification | Race, gender | 1999 to 2008 hospital admissions; readmission |
fetch_acs_income | ACSIncome | Regression | Race, sex | Folktables 2018 ACS, 1.6M records |
fetch_bank_marketing | UCI Bank Marketing | Binary classification | Age | Portuguese telemarketing campaign |
fetch_credit_card | UCI credit card default | Binary classification | Sex, age | Taiwan 2005 |
The ACSIncome loader, contributed in the 0.7 series, is based on Ding et al. (2021)'s Folktables data, designed in response to the limitations of the original Adult dataset.
Fairlearn is built on numpy, pandas, and scikit-learn. The reductions and postprocessing classes accept any object with fit and predict methods, so PyTorch and TensorFlow models can be used as base estimators if wrapped in a thin scikit-learn-compatible class. The library has no deep-learning-specific module beyond the adversarial mitigation, and most usage in practice is on tabular data.
Fairlearn exposes a focused, curated set of fairness metrics. Unlike AIF360 (more than seventy metrics, many redundant), Fairlearn keeps the core set small and relies on MetricFrame for everything else.
| Metric | What it measures | Origin |
|---|---|---|
| Demographic parity difference | Maximum difference in selection rate between groups | Calders & Verwer 2010; Dwork et al. 2012 |
| Demographic parity ratio | Ratio of minimum to maximum selection rate; comparable to the four-fifths rule for disparate impact | US EEOC Uniform Guidelines, 1978 |
| Equalised odds difference | Maximum of TPR difference and FPR difference between groups | Hardt, Price, Srebro 2016 |
| Equalised odds ratio | Minimum-to-maximum ratio of TPR and FPR across groups | Hardt, Price, Srebro 2016 |
| Equal opportunity (TPR parity) | Equality of true positive rates across groups | Hardt, Price, Srebro 2016 |
| False positive rate parity | Equality of false positive rates across groups | Hardt, Price, Srebro 2016 |
| Selection rate | Fraction of positive predictions per group | Definitional |
| Disaggregated sklearn metrics | Accuracy, precision, recall, F1, MAE, MSE, etc., by group | Computed via MetricFrame |
| Worst-case accuracy | Lowest accuracy among any group | Hashimoto et al. 2018 |
A distinguishing feature is that Fairlearn does not ship a single canonical fairness metric and instead encourages the user to choose. The user guide walks through Chouldechova (2017) and Kleinberg, Mullainathan, & Raghavan (2017), the canonical incompatibility of fairness metrics papers, to make clear that picking a metric is a value judgement. Fairlearn also supports fairness metrics for regression, including bounded group loss, which asks that prediction error within any sensitive group stay below a chosen level.
Fairlearn organises mitigation algorithms by where they intervene in the pipeline, the taxonomy made standard by Friedler et al. (2019). The library is less encyclopaedic than AIF360 and contains a smaller, curated set of methods, with reductions as the design centre.
| Category | Algorithm | Original paper | Supported constraints |
|---|---|---|---|
| Preprocessing | CorrelationRemover | Fairlearn user guide | Linear correlation removal between sensitive and non-sensitive features |
| In-processing (reductions) | ExponentiatedGradient | Agarwal, Beygelzimer, Dudík, Langford, Wallach 2018 | DemographicParity, EqualizedOdds, TPR/FPR parity, ErrorRateParity, BoundedGroupLoss |
| In-processing (reductions) | GridSearch | Agarwal et al. 2018 §3.4; Agarwal, Dudík, Wu 2019 (regression) | Same as ExponentiatedGradient |
| In-processing (adversarial) | AdversarialFairnessClassifier, AdversarialFairnessRegressor | Zhang, Lemoine, Mitchell 2018 | Demographic parity (via adversary loss) |
| Postprocessing | ThresholdOptimizer | Hardt, Price, Srebro 2016 | DemographicParity, EqualizedOdds, TPR/FPR parity |
The reductions framework is Fairlearn's central technical contribution. The starting observation, due to Agarwal et al. (2018), is that any fairness constraint that can be written as a linear inequality on the conditional moments of a classifier (demographic parity, equalised odds, equal opportunity, or any conjunction) defines a constrained empirical risk minimisation problem. Its Lagrangian dual can be expressed as a saddle-point game between the classifier and a vector of Lagrange multipliers, and the inner minimisation, for any fixed multiplier vector, is a standard cost-sensitive classification problem with sample weights derived from the multipliers. So any black-box cost-sensitive classifier can be plugged in as an oracle to solve the fair-classification problem without modification.
ExponentiatedGradient implements this with the no-regret online learning algorithm of Freund and Schapire, which converges to the optimal classifier in O(1/sqrt(T)) iterations. GridSearch is a simpler alternative that enumerates a grid of multiplier values, trains one classifier per grid point, and returns the Pareto frontier of accuracy-fairness trade-offs.
The practical advantages are significant. The user can swap in any base learner without changing the fairness algorithm. The same code path supports any fairness constraint cast as linear inequalities on conditional moments, which covers most of the group-fairness literature. The output is a randomised classifier (a distribution over deterministic classifiers), necessary in general because deterministic classifiers cannot always satisfy demographic parity or equalised odds exactly. The algorithm also comes with theoretical guarantees on convergence and suboptimality. The extension to fair regression in Agarwal, Dudík, and Wu (2019) replaces binary outcomes with real-valued ones under Lipschitz-continuous losses, a capability AIF360 does not have natively.
ThresholdOptimizerThe Hardt-Price-Srebro (2016) postprocessing method takes a fully trained classifier that produces real-valued scores and learns a per-group decision rule to satisfy a fairness constraint. For demographic parity it picks per-group thresholds so the positive-prediction rate is equal across groups. For equalised odds it can pick a randomised mixture of two thresholds per group, because deterministic thresholds cannot match both TPR and FPR exactly except by coincidence. The optimisation is convex (a linear program per group) and the implementation is fast, which is why ThresholdOptimizer is often the first thing practitioners try.
Fairlearn is one of several open-source fairness toolkits that emerged in the 2018 to 2020 window. The libraries differ in licence, language, focus, and design philosophy, and many production teams use more than one.
| Toolkit | Organisation | Year | Language | Licence | Focus | Mitigation |
|---|---|---|---|---|---|---|
| Fairlearn | Microsoft, then community | 2018 (May) | Python | MIT | Reductions + sklearn-style assessment | 5 classes (1 pre, 3 in, 1 post) |
| AI Fairness 360 (AIF360) | IBM, then LF AI & Data | 2018 (Sept) | Python, R | Apache 2.0 | Encyclopaedic catalogue | 13+ across pre, in, post |
| AI Explainability 360 (AIX360) | IBM, LF AI & Data | 2019 | Python | Apache 2.0 | Sister project for explainability | None (explanation only) |
| Aequitas | University of Chicago CDSPP | 2018 | Python, CLI | MIT | Bias audit reports | None (audit only) |
| TF Fairness Indicators | Google, TensorFlow team | 2019 (Dec) | Python (TFX) | Apache 2.0 | Slice-based fairness for TF models | None (evaluation only) |
| What-If Tool | Google PAIR | 2018 | Python (TensorBoard) | Apache 2.0 | Interactive what-if exploration | None |
| Themis-ML | Niels Bantilan (academic) | 2017 | Python | MIT | Predates AIF360 and Fairlearn | A few preprocessing methods |
| OxonFair | University of Oxford | 2024 | Python | MIT | Flexible postprocessing | Postprocessing-focused |
Fairlearn and AIF360 are the most direct rivals because both cover metrics and mitigation across pre, in, and post-processing.
| Aspect | Fairlearn | AIF360 |
|---|---|---|
| Number of mitigation algorithms | Smaller, more curated | Encyclopaedic catalogue |
| In-processing approach | Reductions framework as core abstraction | Diverse stand-alone algorithms |
| Regression support | Yes (GridSearch with BoundedGroupLoss; ACSIncome) | Limited |
| More than two sensitive groups | Supported throughout | Most methods assume binary protected attribute |
| Language bindings | Python only | Python and R |
| API style | scikit-learn-style fit/predict/transform | sklearn-style for aif360.sklearn, otherwise its own |
Lee and Singh (2021) compared the user experience of these toolkits with practitioners and found Fairlearn easier to use for newcomers, while AIF360 had broader algorithmic coverage. A common combined pattern is to use AIF360 preprocessing (Reweighing, LearningFairRepresentations) on raw data, then Fairlearn's MetricFrame and ThresholdOptimizer on the predictions.
The scikit-learn-compatible API is the dominant aspect of working with Fairlearn day to day. A typical training loop looks like this:
from fairlearn.reductions import ExponentiatedGradient, DemographicParity
from sklearn.linear_model import LogisticRegression
base = LogisticRegression(solver='liblinear')
mitigator = ExponentiatedGradient(base, constraints=DemographicParity())
mitigator.fit(X_train, y_train, sensitive_features=A_train)
y_pred = mitigator.predict(X_test)
The only fairness-specific arguments are constraints and sensitive_features. The same shape works for GridSearch, ThresholdOptimizer, and CorrelationRemover. MetricFrame follows pandas conventions and integrates with notebooks and existing reporting code. Visualisation helpers built on matplotlib and seaborn ship with the library.
On the Microsoft side, Fairlearn is integrated into the Azure Machine Learning Responsible AI dashboard (as one of four pillars alongside interpretability, error analysis, and counterfactuals) and into the open-source Responsible AI Toolbox at microsoft/responsible-ai-toolbox. The deprecated Fairlearn dashboard widget was effectively absorbed into the Toolbox, leaving the core library focused on algorithms. Documentation at fairlearn.org includes a long-form user guide, API reference, and Jupyter notebook examples. The user guide spends as much space on fairness concepts (Chouldechova's impossibility result, allocation versus quality-of-service harms, intersectional fairness) as on API details.
Fairlearn is cited in academic ML fairness courses, including Berkeley's CS 294 and Carnegie Mellon's machine learning fairness course, alongside AIF360. The library is used inside Microsoft as part of Responsible AI requirements for high-impact ML systems and is a technical component of Azure Machine Learning's Responsible AI offering for enterprise customers.
The GitHub repository has more than 2,200 stars and 500 forks, with over 1,000 commits and an active maintainer team. The PyPI package is downloaded several hundred thousand times per month. The library has been integrated into MLflow examples for fairness logging and into Hugging Face's evaluate library for fairness metrics. Fairlearn has been referenced in technical annexes of model risk management documents and in submissions discussing fairness requirements under the EU AI Act, the New York City automated employment decision tool law, and the Colorado AI Act. The library provides measurements and interventions a compliance team can incorporate into a wider audit process; it does not provide regulatory compliance by itself.
Several limitations follow from the field rather than from the library specifically. Chouldechova (2017) and Kleinberg, Mullainathan, & Raghavan (2017) proved that calibration, equal false-positive rates, and equal false-negative rates cannot all be satisfied simultaneously when base rates differ across groups, except in degenerate cases. Fairlearn implements the metrics on either side of the trade-off but does not pretend the conflict can be resolved.
Fairlearn's mitigation algorithms target group fairness criteria (demographic parity, equalised odds, and similar). The library does not natively implement individual fairness (Dwork et al. 2012) or counterfactual fairness (Kusner et al. 2017). Most metrics and all mitigation algorithms require the sensitive attribute to be observed in the data, which may be legally restricted (under GDPR rules for race or health data) or unavailable. Fairness through unawareness, which omits the sensitive attribute from the model, is known to be insufficient because protected attributes can be reconstructed from correlated features.
ExponentiatedGradient trains the base classifier many times (often 50 to 200 iterations), which is slow if the base classifier is itself expensive; GridSearch is faster but explores a coarser frontier, and ThresholdOptimizer is cheapest. While MetricFrame supports intersectional disaggregation, the in-processing mitigation algorithms typically treat the sensitive feature as a single categorical variable, so rich intersectional fairness in the sense of Kearns et al. (2018)'s GerryFair classifier is not part of Fairlearn. Although the adversarial mitigation classes work with PyTorch backbones, the bulk of Fairlearn's tooling is tabular; image and text fairness, especially in large pretrained models, is largely outside the scope of the library.
Releases in 2024 and 2025 have continued at one or two minor versions per year. The 0.10 and 0.11 releases added more Moment classes for the reductions framework, including better support for non-binary sensitive features, and stabilised the adversarial fairness classes. The 0.12 and 0.13 releases (through October 2025) tightened scikit-learn 1.5+ compatibility and improved typing. A 0.14 development branch is in progress with proposed assessment-API changes and a preprocessing refresh.
The project's positioning has shifted from "the Microsoft fairness library" toward "the community fairness library that Microsoft funds". Maintainer funding now comes from Microsoft, Eindhoven University of Technology, and Hugging Face. In the broader landscape, OxonFair (Oxford, 2024) added flexible postprocessing, AIF360 added MDSS bias scanning and intersectional metrics, and Hugging Face's evaluate library now exposes Fairlearn and AIF360 metrics. The trend is to combine fairness measurement with model documentation (Datasheets for Datasets, Model Cards), interpretability, and privacy in a unified responsible-AI workflow.
Alongside AI Fairness 360 (AIF360), Fairlearn is one of the two leading open-source toolkits that took the academic fairness literature out of conferences and into mainstream Python machine-learning practice. Either is a reasonable default for a team adding fairness checks to a production system. Fairlearn also brought the reductions approach into widespread practice. The Agarwal et al. 2018 paper would still be cited without the library, but it would not be running in compliance pipelines at banks or in Azure Machine Learning. The library demonstrated that fairness mitigation can be a small, modular component that integrates cleanly with standard ML pipelines, a design choice that has shaped how subsequent fairness toolkits including OxonFair and the Hugging Face evaluate fairness modules have positioned themselves.