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])
Metadata
Release files for downstream-fairness 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| downstream_fairness-0.1.1.tar.gz | 14.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| downstream_fairness-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 28.6 kB
Release files / downstream_fairness-0.1.1.tar.gz
| Download URL | downstream_fairness-0.1.1.tar.gz |
|---|---|
| Size | 14.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
75ac1d907dfcf002576eacccdbb1845643ed76171fcf6af2cb04c5736f080bdb
|
|
BLAKE2b-256 checksum How to use checksums |
c44722561cb9bbc4db1fdba8da30b10e3e6a9797009de3f9781bdf9883089150
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.3
|
Release files / downstream_fairness-0.1.1-py3-none-any.whl
| Download URL | downstream_fairness-0.1.1-py3-none-any.whl |
|---|---|
| Size | 14.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ea38c15cd707f1fad0fe60db5e79c8d1bfe93cd3d09ef0f365b28ef90708d243
|
|
BLAKE2b-256 checksum How to use checksums |
afe23603020713558a0ad4af14533860eb5a06d896bc14673364637128138746
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.3
|
Security for downstream-fairness 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.