Skip to main content

bias-detector detects bias in ML models

Project description

codecov CircleCI PyPI version

Bias Detector

Bias detector is a python package for detecting bias in machine learning models used for making high stakes decisions.

Based on email address/first and last name/zip code the package analyzes the probability of the user belonging to different genders/races. Then, the model predictions per gender/race are compared using various bias metrics.

Using this package the data scientist would be able to get insight on whether their model is biased or not.

The Bias Detector developers can be contacted on Stack Overflow using the bias-detector tag. We would appreciate your feedback!

Supported Metrics

There are many metrics which can possibly be used to detect Bias, we currently support the following three:

  1. Statistical Parity - tests whether the probability of 2 groups to be classified as belonging to the positive class by the model is equal.
  2. Equal Opportunity - tests whether the True Positive Rates of 2 groups are equal (how likely is the model to predict correctly the positive class for each group).
  3. Predictive Equality - tests whether there False Positive Rates of 2 groups are equal (how likely is the model to predict incorrectly the positive class for each group).

Usage

Install the package

!pip install bias-detector

Calculate bias metrics based on users data, y_true and y_pred:

from bias_detector.BiasDetector import BiasDetector
bias_report = BiasDetector().get_bias_report(first_names=first_names, last_names=last_names, zip_codes=zip_codes, y_true=y_true, y_pred=y_pred, country='US')
bias_report.plot_summary()
bias_report.print_summary()

Example for the report output:

bias_report contains:

  • plot_summary function to visualize the results.
  • print_summary function to summarize the results.
  • plot_groups function to visualize the estimated groups distribution.

Contributing

See CONTRIBUTING.md

References

  1. NINAREH MEHRABI, FRED MORSTATTER, NRIPSUTA SAXENA, KRISTINA LERMAN, and ARAM GALSTYAN, 2019. A Survey on Bias and Fairness in Machine Learning.
  2. Moritz Hardt, Eric Price, Nathan Srebro, 2016. Equality of Opportunity in Supervised Learning.
  3. Ioan Voicu (2018) Using First Name Information to Improve Race and Ethnicity Classification, Statistics and Public Policy, 5:1, 1-13, DOI: 10.1080/2330443X.2018.1427012

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bias-detector-0.0.3.tar.gz (246.8 kB view details)

Uploaded Source

Built Distribution

bias_detector-0.0.3-py3-none-any.whl (257.7 kB view details)

Uploaded Python 3

File details

Details for the file bias-detector-0.0.3.tar.gz.

File metadata

  • Download URL: bias-detector-0.0.3.tar.gz
  • Upload date:
  • Size: 246.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9

File hashes

Hashes for bias-detector-0.0.3.tar.gz
Algorithm Hash digest
SHA256 36cfa2c681cc5f4b2892c3fdaf3e1976d37ae6331790243fdea3593f2d9ac373
MD5 328d21de36db638045f1fcc45a566ad9
BLAKE2b-256 3107ea86d586f045d182bef7f4e104afeb5950aa2745bb791bde27d1445627b7

See more details on using hashes here.

File details

Details for the file bias_detector-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: bias_detector-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 257.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9

File hashes

Hashes for bias_detector-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9cfe862a1d783dcc32bfe52d6f3facf5aa3a3e5574c7144c02e7406c8699e05d
MD5 2c7ee8abc7414e566a176ed769c06f41
BLAKE2b-256 ee3a85b9324727baffe4a3f18a40bb6b3eabf097e945d0e5fffb8a4e23f94092

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page