A new post-processing fairness algorithm that operates on the output probabilities of a binary classifier
Project description
Downstream Fairness
We implement the algorithm presented in Geometric Repair for Fair Classification at Any Decision Threshold.
The algorithm looks at the scores, labels, and sensitive attribute in a dataset, and determines a set of adjustments.
The original set of adjustments allow one to adjust the prediction probabilities of a binary classifier, and perturb
them (by adding the appropriate adjustment to a prediction probability), so that you can achieve demographic parity
.
To achieve other fairness definitions, such as equalized odds and equal opportunity, our algorithm provides a lambda
value. This lambda
value is multiplied to each entry of the set of adjustments, and then those can be added to
predictions. Here is a good way to think about it:
prediction_probability + adjustment_value # achieves demographic parity
prediction_probability + lambda_val * adjustment_value # achieves some fairness definition attached to the lambda value
Quickstart
First, please make sure to download our package. You can either do this from this repo via:
pip install -e .
or you can install it directly via pip
:
pip install downstream_fairness
To get started, we recommend just running our get_bias_mitigator
, so you can get a dictionary of lambda values and
an adjustment table. To go more in-depth, we recommend going through our demo notebook.
from downstream_fairness.process import get_bias_mitigator
# Gets the adjustment table and lambdas
table, lambdas = get_bias_mitigator(YOUR_DATA,
sens_col=YOUR_SENSITIVE_ATTRIBUTE_COLUMN_NAME,
score_col=YOUR_PREDICTION_PROBABILTIY_COLUMN,
label_col=YOUR_LABEL_COLUMN)
# Adjusts the prediction probabilities on the fly
adjusted_scores = get_adusted_scores(table,
DATA_YOU_WANT_ADJUSTED,
YOUR_SENSITIVE_ATTRIBUTE_COLUMN_NAME,
YOUR_PREDICTION_PROBABILTIY_COLUMN,
lambdas[THE_METRIC_YOU_WANT])
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file downstream_fairness-0.1.1.tar.gz
.
File metadata
- Download URL: downstream_fairness-0.1.1.tar.gz
- Upload date:
- Size: 14.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 75ac1d907dfcf002576eacccdbb1845643ed76171fcf6af2cb04c5736f080bdb |
|
MD5 | add5912bb3d10745d9d6a6c52dc94136 |
|
BLAKE2b-256 | c44722561cb9bbc4db1fdba8da30b10e3e6a9797009de3f9781bdf9883089150 |
File details
Details for the file downstream_fairness-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: downstream_fairness-0.1.1-py3-none-any.whl
- Upload date:
- Size: 14.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ea38c15cd707f1fad0fe60db5e79c8d1bfe93cd3d09ef0f365b28ef90708d243 |
|
MD5 | 570c1bc0b23619714ab763e29519d3a2 |
|
BLAKE2b-256 | afe23603020713558a0ad4af14533860eb5a06d896bc14673364637128138746 |