Skip to main content

The NLP Bias Identification Toolkit

Project description

biaslyze

The NLP Bias Identification Toolkit

Usage example

from biaslyze.bias_detectors import CounterfactualBiasDetector

bias_detector = CounterfactualBiasDetector()

# detect bias in the model based on the given texts
# here, clf is a scikit-learn text classification pipeline trained for a binary classification task
detection_res = bias_detector.process(
    texts=texts,
    predict_func=clf.predict_proba
)

# see a summary of the detection
detection_res.report()

# visualize the counterfactual scores
detection_res.visualize_counterfactual_scores(concept="religion", top_n=10)

Example output:

Development setup

  • First you need to install poetry to manage your python environment: https://python-poetry.org/docs/#installation
  • Run make install to install the dependencies and get the spacy basemodels.
  • Now you can use biaslyze in your jupyter notebooks.

Adding concepts and keywords

You can add concepts and new keywords for existing concepts by editing concepts.py.

Preview/build the documentation with mkdocs

To preview the documentation run make doc-preview. This will launch a preview of the documentation on http://127.0.0.1:8000/. To build the documentation html run make doc.

Run the automated tests

make test

Style guide

We are using isort and black: make style For linting we are running ruff: make lint

Contributing

Follow the google style guide for python: https://google.github.io/styleguide/pyguide.html

This project uses black, isort and ruff to enforce style. Apply it by running make style and make lint.

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

biaslyze-0.0.4a0.tar.gz (19.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

biaslyze-0.0.4a0-py3-none-any.whl (21.3 kB view details)

Uploaded Python 3

File details

Details for the file biaslyze-0.0.4a0.tar.gz.

File metadata

  • Download URL: biaslyze-0.0.4a0.tar.gz
  • Upload date:
  • Size: 19.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.1 CPython/3.8.10 Linux/5.15.0-72-generic

File hashes

Hashes for biaslyze-0.0.4a0.tar.gz
Algorithm Hash digest
SHA256 0bcf6b04acfae5324d51d32b2cacc687ab1c31b28d7487df4b013c8a7ab7ecdf
MD5 7e7ada0966efe1fe982e594193e19c01
BLAKE2b-256 ffb88b5b1694d18aaceb8e79aaf823e7110fb38a81ab14de558167fa2596e96d

See more details on using hashes here.

File details

Details for the file biaslyze-0.0.4a0-py3-none-any.whl.

File metadata

  • Download URL: biaslyze-0.0.4a0-py3-none-any.whl
  • Upload date:
  • Size: 21.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.1 CPython/3.8.10 Linux/5.15.0-72-generic

File hashes

Hashes for biaslyze-0.0.4a0-py3-none-any.whl
Algorithm Hash digest
SHA256 41dbbc5247851a49254b9737bb416a0979cc1eec5c246f2bb2aa82eee525d44f
MD5 81789fa56639c1dc2bc48437228b4565
BLAKE2b-256 dc2f5bdab2585ce7e9eead36143b08038218cc18dc9f4bebe7ba4a35a860674f

See more details on using hashes here.

Supported by

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