fairlearn
A Python package to assess and improve fairness of machine learning models.
What it is and what it does
Fairlearn is a Python package for assessing and mitigating fairness in AI systems, focusing on harms that occur when models treat different groups of people unequally. It operationalizes fairness through a group fairness approach, asking which groups are at risk for experiencing harms—either allocation harms (when opportunities or resources are withheld) or quality-of-service harms (when a system works differently for different people). The package provides two main components: metrics for identifying which groups are negatively impacted by a model and comparing models across fairness and accuracy trade-offs, and mitigation algorithms that reduce unfairness across various AI tasks and fairness definitions.
The package depends on standard data science libraries (numpy, pandas, scikit-learn, scipy) and narwhals, and supports Python 3.10 through 3.13. It is actively maintained with a release history dating back to 2018, and the repository shows recent activity. The package acknowledges that fairness is fundamentally a sociotechnical challenge—quantitative metrics alone cannot capture all aspects like justice or due process, and not all fairness metrics can be satisfied simultaneously. Its role is to enable practitioners to assess different mitigation strategies and make trade-offs appropriate to their specific scenario.
Use it for:
- Assess hiring or lending models to detect whether they systematically disadvantage protected groups before deployment
- Measure and compare fairness metrics across multiple candidate models to inform model selection decisions
- Apply post-processing mitigation algorithms to adjust model predictions to satisfy fairness constraints like demographic parity
- Evaluate quality-of-service fairness to ensure a recommendation or classification system works equally well across demographic groups
- Generate fairness reports for stakeholders to document which groups experience harms and what trade-offs were made
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Fairlearn assesses and mitigates fairness issues in machine learning models by providing metrics to identify which groups are negatively impacted and algorithms to reduce unfairness across various AI tasks.
Yes. Fairlearn is actively maintained, has low install friction, carries a permissive license, and addresses a real need in responsible AI development. It is appropriate for teams building production ML systems that must account for fairness across demographic groups. The package is mature enough for practical use (Alpha status reflects ongoing development, not instability) and has substantial adoption. Install it if fairness assessment or mitigation is part of your model development workflow.
Install
fairlearn on PyPI
pip
pip install fairlearnuv
uv add fairlearnpoetry
poetry add fairlearnInstalling fairlearn
Before you install
Low install friction with a pure Python wheel and five well-established dependencies (numpy, pandas, scikit-learn, scipy, narwhals). Active maintenance with a release 68 days ago and ongoing repository activity.
License in practice
Permissive license allows unrestricted use, modification, and distribution in commercial and private projects without copyleft obligations.
Quickstart
pip install fairlearn
from fairlearn.metrics import MetricFrame
from fairlearn.postprocessing import ThresholdOptimizer
import pandas as pd
# Assess fairness across groups
metric_frame = MetricFrame(metrics={...}, y_true=y, y_pred=y_pred, groups=groups)
# Mitigate unfairness
mitigator = ThresholdOptimizer(estimator=model, constraints='demographic_parity')
mitigator.fit(X_train, y_train, sensitive_features=sensitive_train)
Verify before relying
- Whether narwhals is used as a dataframe abstraction layer or for a specific feature
- Specific fairness constraint types and mitigation algorithms available beyond the description
- Performance characteristics when applied to large datasets or high-dimensional sensitive features
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 5 — narwhals, numpy, pandas, scikit-learn, scipy |
| Maintenance | actively maintained — 68 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 209,288/month — #9,516 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: fairlearn-0.14.0-py3-none-any.whl
Tags
More Artificial Intelligence packages
LiteLLM provides a unified Python interface to…
permissive · top 100 on PyPI
huggingface-hubClient library and CLI tool for downloading,…
permissive · top 100 on PyPI
langchainLangChain provides a framework for building…
permissive · top 1,000 on PyPI
hf-xethf-xet provides chunk-based deduplication and…
permissive · top 1,000 on PyPI
tokenizersTokenizers converts raw text into token…
permissive · top 1,000 on PyPI
transformersTransformers provides a unified framework for…
permissive · top 1,000 on PyPI
empirical-calibrationComputes empirical calibration weights to…
permissive · top 15,000 on PyPI
arthur-clientPython SDK for integrating machine learning…
permissive · top 15,000 on PyPI
tslearntslearn provides machine learning algorithms…
permissive · top 15,000 on PyPI
pyannote-metricsEvaluates and analyzes speaker diarization…
unclear · top 5,000 on PyPI
pyiqaPyIQA provides a PyTorch-based toolbox for…
noncommercial · top 15,000 on PyPI
moocoreProvides fast implementations of core…
copyleft · top 5,000 on PyPI
imagededupFinds exact and near-duplicate images in…
permissive · top 15,000 on PyPI
riverRiver provides online machine learning…
permissive · top 15,000 on PyPI
learnosity-sdkLearnosity SDK provides Python bindings to…
permissive · top 15,000 on PyPI
psmpyPsmPy implements propensity score matching for…
permissive · top 5,000 on PyPI