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)
Gurobi offers academic licenses. You can obtain one here.
Generating docs
Navigate to docs/source and run make html. If that doesn't work, try to run 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 .
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.1.0.tar.gz.
File metadata
- Download URL: rocelib-0.1.0.tar.gz
- Upload date:
- Size: 56.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
54a950ca759730bcd8e85b7eb25df8fe4b9d27eef75dd9dedb4bad481f0921d0
|
|
| MD5 |
88e5d2371f2de4e640ce00c06b289474
|
|
| BLAKE2b-256 |
a60d8fdc90d7090114cb6ac56211a51248c2fe3d061c30613195f86419ce5aa3
|
File details
Details for the file rocelib-0.1.0-py3-none-any.whl.
File metadata
- Download URL: rocelib-0.1.0-py3-none-any.whl
- Upload date:
- Size: 91.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4783c1ed08b738dbbce0e703301e4f27ef7fb53daa013e11bf0dcdacb0ba687f
|
|
| MD5 |
fe1bdd70c0fefaf22e3b0c56ec423c72
|
|
| BLAKE2b-256 |
1b2b1dc9c67da0fce6781b531e100aef171dbf2f56b2a7a674cee957f7e11b44
|