Skip to main content

equal-odds

PyPI publishing status PyPI version OSI license Python compatibility

Fast postprocessing of any score-based predictor to meet fairness criteria.

The equal-odds package can achieve strict or relaxed fairness constraint fulfillment, which can be useful to compare ML models at equal fairness levels.

Installing

Install package from PyPI:

pip install equal-odds

Or, for development, you can clone the repo and install from local sources:

git clone https://github.com/AndreFCruz/equal-odds.git
pip install ./equal-odds

Getting started

# Given any trained model that outputs real-valued scores
fair_clf = RelaxedEqualOdds(
    predictor=lambda X: model.predict_proba(X)[:, -1],   # for sklearn API
    # predictor=model,  # use this for a callable model
    tolerance=0.05,     # fairness constraint tolerance
)

# Fit the fairness adjustment on some data
# This will find the optimal _fair classifier_
fair_clf.fit(X=X, y=y, group=group)

# Now you can use `fair_clf` as any other classifier
# You have to provide group information to compute fair predictions
y_pred_test = fair_clf(X=X_test, group=group_test)

How it works

Given a callable score-based predictor (i.e., y_pred = predictor(X)), and some (X, Y, S) data to fit, RelaxedEqualOdds will:

  1. Compute group-specific ROC curves and their convex hulls;
  2. Compute the r-relaxed optimal solution for the chosen fairness criterion (using cvxpy);
  3. Find the set of group-specific binary classifiers that match the optimal solution found.
    • each group-specific classifier is made up of (possibly randomized) group-specific thresholds over the given predictor;
    • if a group's ROC point is in the interior of its ROC curve, partial randomization of its predictions may be necessary.

Implementation road-map

We welcome community contributions for cvxpy implementations of other fairness constraints.

Currently implemented fairness constraints:

Metadata

Release files for equal-odds 0.0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for equal-odds 0.0.7
File Size Uploaded
equal-odds-0.0.7.tar.gz 18.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for equal-odds 0.0.7
File Interpreter ABI Platform
equal_odds-0.0.7-py3-none-any.whl Python 3 none any Details

Total release size: 36.2 kB

Release files / equal-odds-0.0.7.tar.gz

Download URL equal-odds-0.0.7.tar.gz
Size 18.0 kB
Tags Source
SHA-256 checksum
How to use checksums
f66a1b2f583271f05a8ef5ca35f1fd27960fa94f47daaa5c0457c549f421d949
BLAKE2b-256 checksum
How to use checksums
a5d929f4d16ec6861429264298c9f308062c6896a6c72dce81c64328013b04af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release files / equal_odds-0.0.7-py3-none-any.whl

Download URL equal_odds-0.0.7-py3-none-any.whl
Size 18.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c5ac6913e9a1eb360c6bd54c1ae6c657e2c8281485ba60094fc2ad5376ef0461
BLAKE2b-256 checksum
How to use checksums
c9cefa7565e3200796145567762cb631539aef14d4000dcec319b5ea5e212685
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release history Release notifications | RSS feed

This release

0.0.7 This release

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

0.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page