AI Fairness 360 (AIF360) is an open-source Python toolkit for detecting, explaining and mitigating bias in datasets and machine learning models. Among AI frameworks & tools, it occupies the governance end of the stack: it does not train models itself but sits around the training pipeline of libraries such as scikit-learn, TensorFlow or PyTorch and asks whether the outcomes differ unfairly between groups of people.
IBM Research released the toolkit in 2018 and later contributed it to the LF AI & Data Foundation, where it is maintained as a community project. In artificial intelligence practice, AIF360 is best known for collecting more than 70 fairness metrics and about a dozen bias mitigation algorithms behind one consistent interface, which makes it a common reference implementation for fairness research and audits.
How AI Fairness 360 is organized
AIF360 is built around three core abstractions: datasets that know which attributes are protected, metrics that quantify disparity, and algorithms that change data, training or predictions to reduce it. A user declares a protected attribute such as sex, race or age band, and then names the privileged and unprivileged groups, for example applicants aged 25 or older versus younger applicants.
The central data structure is the BinaryLabelDataset, which wraps a pandas DataFrame together with the favorable label, the protected attributes and optional instance weights. Bundled loaders for the Adult, German credit, COMPAS and Bank marketing datasets make experiments reproducible, although these benchmarks carry their own historical biases and should not be treated as neutral ground truth.
The following table summarizes the main modules and what each one is used for.
| Module | Purpose | Typical classes |
|---|---|---|
| aif360.datasets | Holds data with protected attributes and labels | BinaryLabelDataset, StandardDataset |
| aif360.metrics | Computes dataset and classifier fairness metrics | BinaryLabelDatasetMetric, ClassificationMetric |
| aif360.algorithms | Applies pre-, in- and post-processing mitigation | Reweighing, AdversarialDebiasing |
| aif360.explainers | Turns metric values into readable statements | MetricTextExplainer |
| aif360.sklearn | Offers a scikit-learn compatible interface | Estimators and metric functions |
An R package wraps the same Python core through reticulate, so analysts working in R can call the metrics and algorithms without rewriting their pipelines. The scikit-learn compatible API is the newer and more idiomatic route, because it accepts ordinary DataFrames with the protected attribute stored in the index.
Fairness metrics computed by AIF360
AIF360 separates dataset metrics, which describe bias in labels before any model exists, from classification metrics, which compare model predictions with true labels for each group. Most metrics express a difference or a ratio between the unprivileged and the privileged group, so the ideal value is either zero or one.
The table lists the metrics that appear most often in audits, with their ideal values and the threshold conventions practitioners commonly apply.
| Metric | What it compares | Ideal value | Common tolerance |
|---|---|---|---|
| Statistical parity difference | Favorable outcome rates between groups | 0 | Between -0.1 and 0.1 |
| Disparate impact | Ratio of favorable outcome rates | 1 | 0.8 to 1.25 |
| Equal opportunity difference | True positive rates between groups | 0 | Between -0.1 and 0.1 |
| Average odds difference | Mean of TPR and FPR gaps | 0 | Between -0.1 and 0.1 |
| Theil index | Inequality of individual benefit | 0 | Lower is better |
The 0.8 lower bound for disparate impact echoes the four-fifths rule used in United States employment guidance, but it is a screening heuristic rather than a legal verdict. The ranges of plus or minus 0.1 are conventions from the toolkit tutorials, and acceptable thresholds depend on the domain, the base rates and the applicable regulation.
Several group criteria are mathematically incompatible when base rates differ between groups: a classifier cannot generally satisfy calibration, equal false positive rates and equal false negative rates at the same time. AIF360 does not resolve this tension; it makes the trade-off visible so that people can choose the criterion that matches the harm they want to prevent.
Bias mitigation algorithms in AIF360
AIF360 groups its mitigation methods by the point in the pipeline where they intervene. Pre-processing changes the training data, in-processing changes the learning objective, and post-processing changes the predictions of an already trained model.
The following overview helps to choose a stage according to what the team is allowed to modify.
| Stage | Representative algorithms | What must be accessible | Main trade-off |
|---|---|---|---|
| Pre-processing | Reweighing, Disparate Impact Remover, Learning Fair Representations, Optimized Preprocessing | Training data | May distort feature relationships |
| In-processing | Adversarial Debiasing, Prejudice Remover, Meta Fair Classifier, Exponentiated Gradient Reduction, GerryFair | Training code and objective | Higher complexity and tuning cost |
| Post-processing | Equalized Odds Postprocessing, Calibrated Equalized Odds, Reject Option Classification | Model scores and group labels | Uses the protected attribute at prediction time |
Reweighing is often the first method tried because it leaves features and labels untouched and only assigns instance weights that equalize the joint distribution of group and label. Adversarial Debiasing trains a predictor together with an adversary that tries to infer the protected attribute from the predictions, penalizing the predictor whenever the adversary succeeds.
Post-processing methods such as Reject Option Classification adjust decisions near the threshold, where the model is least certain. They are attractive for models that cannot be retrained, but they require the protected attribute when scoring, which some legal frameworks restrict.
AIF360 compared with related fairness tools
AIF360 is the broadest catalog of fairness methods in one Python library, while neighboring tools trade breadth for a narrower and more streamlined workflow. The closest alternative is Fairlearn, which began at Microsoft and focuses on reductions-based mitigation and interactive assessment.
| Tool | Primary focus | Strength | Limitation |
|---|---|---|---|
| AIF360 | Metrics plus pre-, in- and post-processing | Widest algorithm coverage | Older class-based API, uneven maintenance |
| Fairlearn | Assessment and reductions methods | Clean scikit-learn integration | Fewer pre-processing methods |
| What-If Tool | Visual model probing | Interactive counterfactual exploration | Limited automated mitigation |
| Model cards and audits | Documentation and governance | Communicates intended use and risk | No computation by themselves |
In practice teams often combine tools: Fairlearn or the AIF360 scikit-learn interface for day-to-day metrics, a specific AIF360 algorithm when a paper or a regulator names it, and experiment trackers such as MLflow to record fairness metrics alongside accuracy for every model version.
Limitations and common mistakes
AIF360 measures group-level statistical fairness, which is only one part of responsible deployment. It cannot judge whether the label itself is a fair target, whether the protected attribute was recorded accurately, or whether a system should be built at all.
- Fairness through unawareness fails: dropping the protected column does not remove bias, because proxies such as postal code or school carry the same information.
- Single-metric optimization misleads: improving statistical parity can worsen equal opportunity, so reports should show several metrics together.
- Small groups produce unstable numbers: metrics on a few dozen records need confidence intervals or bootstrapping before any conclusion.
- Intersectional bias stays hidden when groups are defined by one attribute; combinations such as age and sex must be declared explicitly.
- Dependency drift affects some in-processing methods that rely on older TensorFlow versions, so environments should be pinned.
The most serious error is treating a passing metric as proof of fairness. AIF360 output is evidence for a documented review that also involves domain experts, affected stakeholders and legal counsel.
In simple terms
AI Fairness 360 is a free software kit that checks whether a computer model treats different groups of people unequally. It counts, for example, how often women and men are approved by a loan model and reports the gap as a number.
If the gap is too large, the kit offers repair methods. Some adjust the training data, some change how the model learns, and some correct the final decisions. The kit measures and repairs, but people still decide what fair means for their situation.
A practical example
A data science team at a regional lender trains a gradient-boosted credit model on 40,000 past applications. Before release, the team loads the data into a BinaryLabelDataset with age as the protected attribute and applicants under 25 as the unprivileged group. The test set shows a disparate impact of 0.71 and an equal opportunity difference of -0.14, meaning creditworthy young applicants are approved noticeably less often.
The team applies Reweighing to the training data, retrains the model and recomputes the metrics. Disparate impact rises to 0.88 and the equal opportunity difference shrinks to -0.05, while the area under the curve falls from 0.81 to 0.80. The compliance officer accepts this small accuracy cost for a clear fairness gain, and the metric report becomes part of the model documentation reviewed every quarter.