Skip to main content

Explaining Random Forest model predictions by Building Explanations through a LocaLly AccuraTe Rule EXtractor

Project description

Bellatrex Logo

Python Versions Downloads License Cross OS integration DOI PyPI version codecov Roadmap

Bellatrex: Explain your Random Forest predictions

Bellatrex is a Python library designed to generate concise, interpretable, and visually appealing explanations for predictions made by Random Forest models. The name says it all: Bellatrex stands for Building Explanations through a LocalLy AccuraTe Rule EXtractor.

Curious about the details and inner mechanisms of Bellatrex? Check out our paper and jump into the reproducibility branch to dive into the experiments.

How Bellatrex works

When explaining a prediction for a specific test instance, Bellatrex:

  1. pre-selects a subset of the rules used to make the prediction;
  2. creates a vector representation of such rules and (optionally) projects them into a low-dimensional space
  3. clusters such representations to pick a rule from each cluster to explain the instance prediction.
  4. Shows the selected rule through visually appealing plots, and the tool's GUI allows users to explore similar rules to those extracted.
Bellatrex image
Overview of Bellatrex, starting from top left, proceeding clockwise, we reach the output with related explanations on the bottom left.

Supported models and tasks

The current support of Bellatrex focuses on Random Forest models implemented via scikit-learn and scikit-survival:

  • Classification tasks and multi-label classification via RandomForestClassifier
  • Regression tasks and multi-target regression via RandomForestRegressor
  • Survival Analysis (time-to-event predictions with censoring) via RandomSurvivalForest

Set-up

To install the standard version of Bellatrex (without an interacting GUI), run:

pip install bellatrex

If this step fails and you don't find a solution immediately, please open an issue. In the meantime, you can also try to clone the repository manually.

Interactive GUI mode

For an enhanced user experience that includes interactive plots, you can run:

pip install bellatrex[gui]

or manually install the following additional packages:

pip install dearpygui==1.6.2
pip install dearpygui-ext==0.9.5

Note: When running Bellatrex with the GUI for multiple test samples, the program will generate an interactive window. The process may take a couple of seconds, and the the user might have to click at least once within the generated window in order to activate the interactive mode. Once this is done, the user can explore the generated rules by clicking on the corresponding representation. To show the Bellatrex explanation for the next sample, close the interactive window and wait until Bellatrex generates the explanation for the new sample.

Ready to go? Quickstart tutorial

If you have downloaded the content of this folder and installed the packages successfully, you can dive into tutorial.ipynb and try Bellatrex yourself.

Support and Contributions

Bellatrex is an open-source project that was initially developed from research funding by Flanders AI. Since the end of that funding period, the project has been maintained through volunteer work, but there is always exiting work ahead: new features, performance improvements, tests for robustness... if you find Bellatrex useful or believe in its goals, there are several meaningful ways you can help support its ongoing development:

  • 🐛 Test and Report Issues: if you encounter any bugs, inconsistencies, or simply find areas for improvement, open an issue and share example code and error traces.
  • Give a star Bellatrex: it will make the project more visible to others and motivate ongoing voluntary development.

Refrences

Please cite the following paper if you are using Bellatrex:

Dedja, K., Nakano, F.K., Pliakos, K. and Vens, C., 2023. BELLATREX: Building explanations through a locally accurate rule extractor. Ieee Access, 11, pp.41348-41367.

@article{dedja2023bellatrex,
  title={BELLATREX: Building explanations through a locally accurate rule extractor},
  author={Dedja, Klest and Nakano, Felipe Kenji and Pliakos, Konstantinos and Vens, Celine},
  journal={Ieee Access},
  volume={11},
  pages={41348--41367},
  year={2023},
  publisher={IEEE}
}

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

bellatrex-0.3.1.tar.gz (127.6 kB view details)

Uploaded Source

Built Distribution

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

bellatrex-0.3.1-py3-none-any.whl (120.9 kB view details)

Uploaded Python 3

File details

Details for the file bellatrex-0.3.1.tar.gz.

File metadata

  • Download URL: bellatrex-0.3.1.tar.gz
  • Upload date:
  • Size: 127.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for bellatrex-0.3.1.tar.gz
Algorithm Hash digest
SHA256 7a0105210b909195d72d0483ebd4cc99341db09ee3d73cea546dae873e27f36d
MD5 a4fbbd50b16792c4d55ae60c3d309fa4
BLAKE2b-256 6dd72a72f7ad08b5b49f07d8807e925485dad88718d106ad4f41848e270a3ec7

See more details on using hashes here.

Provenance

The following attestation bundles were made for bellatrex-0.3.1.tar.gz:

Publisher: release.yaml on KlestDedja/Bellatrex

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

File details

Details for the file bellatrex-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: bellatrex-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 120.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for bellatrex-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a81bb7d6356546d4667f9554ee012503340a48b345ca841bc4775293e8be1645
MD5 77d3f7cbddb77969c22b1c9989a184fb
BLAKE2b-256 7b8b9f410a0e9518bc3dfc4c586dcf1e3e75cc2ef0e8c9b719923a0494702a89

See more details on using hashes here.

Provenance

The following attestation bundles were made for bellatrex-0.3.1-py3-none-any.whl:

Publisher: release.yaml on KlestDedja/Bellatrex

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