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:
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
53271aca4237e945e507e474298e63d176f032cffe370a51f43fcfaa0d6fab3f
|
|
| MD5 |
c880468fda23d78ec6597abdef1c0017
|
|
| BLAKE2b-256 |
6c8fa5e708322fec371581eb7ace968ebe71c9dc93f45766ccb5b4a58af25127
|
Provenance
The following attestation bundles were made for rocelib-0.2.1.tar.gz:
Publisher:
publish-to-pypi.yml on JStadl/RoCELib
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rocelib-0.2.1.tar.gz -
Subject digest:
53271aca4237e945e507e474298e63d176f032cffe370a51f43fcfaa0d6fab3f - Sigstore transparency entry: 176859646
- Sigstore integration time:
-
Permalink:
JStadl/RoCELib@ce24fe66709170cd98b6d508ced13d44aef2dfc2 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/JStadl
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@ce24fe66709170cd98b6d508ced13d44aef2dfc2 -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
69699f09db52aacfb92c2ee70bc4f77f43608b88eae96ee8329246150a4d8ac1
|
|
| MD5 |
e8c75ce409ab8c0551ccbf3edcae2bd6
|
|
| BLAKE2b-256 |
b1991094d9de617f1f0dda1e2f3318fafe875b58d95535610a3d562d9dff5023
|
Provenance
The following attestation bundles were made for rocelib-0.2.1-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on JStadl/RoCELib
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rocelib-0.2.1-py3-none-any.whl -
Subject digest:
69699f09db52aacfb92c2ee70bc4f77f43608b88eae96ee8329246150a4d8ac1 - Sigstore transparency entry: 176859649
- Sigstore integration time:
-
Permalink:
JStadl/RoCELib@ce24fe66709170cd98b6d508ced13d44aef2dfc2 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/JStadl
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@ce24fe66709170cd98b6d508ced13d44aef2dfc2 -
Trigger Event:
push
-
Statement type: