Skip to main content

RoCELib is an open-source Python library designed for benchmarking the robustness of counterfactual explanation (CE) methods.

Project description

RoCELib

The increasing use of machine learning models to aid decision-making in high-stakes industries like finance and healthcare demands explainability to build trust. Counterfactual Explanations (CEs) provide valuable insights into model predictions by showing how slight changes in input data could lead to different outcomes. A key aspect of CEs is their robustness, which ensures that the desired outcomes remain stable even with minor alterations to the input. Robustness is important since produced CEs should hold up in the future should the original model be altered or replaced.Despite the importance of robustness, there has been a lack of standardised tools to comprehensively evaluate and compare robust CE generation methods. To address this, RoCELib was developed as an open-source Python library aimed at benchmarking the robustness of various CE methods. RoCELib provides a systematic framework for generating, evaluating, and comparing CEs with a focus on robustness, enabling fair and effective benchmarking. The library is highly extensible, allowing for custom models, datasets, and tools to be integrated, making it an essential tool for enhancing the reliability and interpretability of machine learning models in critical applications.

Features

  • Standardises the evaluation and benchmarking of robust CEs.
  • Supports multiple ML frameworks, including PyTorch, Keras, and scikit-learn.
  • Extensible to incorporate custom models, datasets, CE methods, and evaluation metrics.
  • Includes several robust CE generation algorithms (e.g., TRexNN, RNCE) and non-robust baselines (e.g., MCE, BLS).

Setup

To set up do:

(1) Create a virtual environment in the root

python -m venv venv

(2) Activate it. (You may have to use a different command depending on your platform)

source venv/bin/activate

(3) Download dependencies:

pip install -r requirements.txt

If you want to also run tests, regenerate docs, do the below, this installs rocelib itself as library:

pip install .

You need Gurobi to run all tests.

If you are on PyCharm, to run tests make sure that your default tester is pytest. (Settings > Tools > Python Integrated Tools > Default Test Runner > pytest)

Generating Docs

The documentation for RoCELib is automatically generated and hosted online. You can access the latest version here:

🔗 RoCELib Documentation

There is no need to manually build the documentation unless making local modifications. However, if you need to generate docs locally, navigate to docs/source and run:

make html

If that does not work, try:

sphinx-build -b html . _build/html

Examples

Python notebooks demonstrating the usage of RoCELib are available here.

The docs pages can be accessed by opening docs/build/html/index.html.

For a step-by-step tutorial, you can also watch the video guide here .

Release Process

For detailed instructions on publishing a new version of RoCELib to PyPI, refer to the RELEASE.md file in the repository. This file contains step-by-step guidance on versioning, tagging, and triggering the GitHub Action workflow for automated publishing.

License

RoCELib is licensed under the MIT License. For more details, please refer to the LICENSE file in this repository.

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

rocelib-0.2.1.tar.gz (8.2 MB view details)

Uploaded Source

Built Distribution

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

rocelib-0.2.1-py3-none-any.whl (97.4 kB view details)

Uploaded Python 3

File details

Details for the file rocelib-0.2.1.tar.gz.

File metadata

  • Download URL: rocelib-0.2.1.tar.gz
  • Upload date:
  • Size: 8.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for rocelib-0.2.1.tar.gz
Algorithm Hash digest
SHA256 53271aca4237e945e507e474298e63d176f032cffe370a51f43fcfaa0d6fab3f
MD5 c880468fda23d78ec6597abdef1c0017
BLAKE2b-256 6c8fa5e708322fec371581eb7ace968ebe71c9dc93f45766ccb5b4a58af25127

See more details on using hashes here.

Provenance

The following attestation bundles were made for rocelib-0.2.1.tar.gz:

Publisher: publish-to-pypi.yml on JStadl/RoCELib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rocelib-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: rocelib-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 97.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for rocelib-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 69699f09db52aacfb92c2ee70bc4f77f43608b88eae96ee8329246150a4d8ac1
MD5 e8c75ce409ab8c0551ccbf3edcae2bd6
BLAKE2b-256 b1991094d9de617f1f0dda1e2f3318fafe875b58d95535610a3d562d9dff5023

See more details on using hashes here.

Provenance

The following attestation bundles were made for rocelib-0.2.1-py3-none-any.whl:

Publisher: publish-to-pypi.yml on JStadl/RoCELib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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