Measure bias from data and machine learning models.
Project description
Parity
Overview
This repository contains codes that demonstrate the use of fairness metrics, bias mitigations and explainability tool.
Installation
Install using:
foo@bar:~$ pip install parity-fairness
Bias Measurement Usage
Setup the data such that the target column is a binary string target. Then find out which features are the privileged categories
and which values are privileged values
. Afterwards, feed them into the function called show_bias
like:
from parity.fairness_metrics import show_bias
priv_category = 'Race-White'
priv_value = 'True'
target_label = 'high pay'
unencoded_target_label = 'True'
cols_to_drop = ''
show_bias(data, priv_category, priv_value, target_label, unencoded_target_label, cols_to_drop)
Bias and Fairness
A common problem with most machine learning models is bias from data. This notebook shows how to measure those biases and perform bias mitigation. A python package called aif360 can give us metrics and algorithms for bias measurement and mitigation
Metrics
- Statistical Parity Difference
- Equal Opportunity Difference
- Average Absolute Odds Difference
- Disparate Impact
- Theil Index
Some metrics need predictions while others just the original dataset. This is why we will use 2 classes of the aif360 package : ClassificationMetric
and BinaryLabelDatasetMetric
.
For metrics that require predictions:
- Equal Opportunity Difference:
equal_opportunity_difference()
- Average Absolute Odds Difference:
average_abs_odds_difference()
- Theil Index :
theil_index()
For metrics that don't require predictions:
- Statistical Parity Difference:
statistical_parity_difference()
- Disparate Impact:
disparate_impact()
Sample Display
The fairness metrics should display like this:
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
File details
Details for the file parity-fairness-0.1.12.tar.gz
.
File metadata
- Download URL: parity-fairness-0.1.12.tar.gz
- Upload date:
- Size: 13.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/47.3.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d3e69dadcf6ee01b5063cd6436723f57cb9d0f76464ed9f3cda30927a988d0bb |
|
MD5 | 1874a91f6bc8466ff01003755cd705d1 |
|
BLAKE2b-256 | a8e0477d5341d862cc87d896a5b0f95e8a3ba36d7c217a4e89f9820332f83b58 |