VisuaLIME
VisuaLIME is an implementation of LIME (Local Interpretable Model-Agnostic Explanations) [1] focused on producing visual local explanations for image classifiers.
In contrast to the reference implementation, VisuaLIME exclusively supports image classification and gives its users full control over the properties of the generated explanations. It was written to produce stable, reliable, and expressive explanations at scale.
VisuaLIME was created as part of the XAI Demonstrator project.
A full documentation is available on visualime.readthedocs.io.
Getting Started
💡 If you're new to LIME, you might want to check out the Grokking LIME talk/tutorial for a general introduction prior to diving into VisuaLIME.
To install VisuaLIME, run:
pip install visualime
VisuaLIME provides two functions that package its building blocks into a reference explanation pipeline:
import numpy as np
from visualime.explain import explain_classification, render_explanation
image = ... # a numpy array of shape (width, height, 3) representing an RGB image
def predict_fn(images: np.ndarray) -> np.ndarray:
# a function that takes a numpy array of shape (num_of_samples, width, height, 3)
# representing num_of_samples RGB images and returns a numpy array of
# shape (num_of_samples, num_of_classes) where each entry corresponds to the
# classifiers output for the respective image
predictions = ...
return predictions
segment_mask, segment_weights = explain_classification(image, predict_fn)
explanation = render_explanation(
image,
segment_mask,
segment_weights,
positive="green",
negative="red",
coverage=0.2,
)
For a full example, see the example notebook on GitHub.
References
[1] Ribeiro et al.: "Why Should I Trust You?": Explaining the Predictions of Any Classifier (arXiv:1602.04938, 2016)
Metadata
Release files for visualime 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| visualime-0.1.0.tar.gz | 23.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| visualime-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 44.6 kB
Release files / visualime-0.1.0.tar.gz
| Download URL | visualime-0.1.0.tar.gz |
|---|---|
| Size | 23.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fd32bb85b7572a2a6360ac96875f8bf2a00c6a0180f6f11594395c83b3b085c4
|
|
BLAKE2b-256 checksum How to use checksums |
376e183495405a945d989b5ec6336602097195cd1f95e55238eee3c5b97e3e87
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.11.3
|
Release files / visualime-0.1.0-py3-none-any.whl
| Download URL | visualime-0.1.0-py3-none-any.whl |
|---|---|
| Size | 21.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bc2948a4f39f26bdbee1f0bcf7f4c7b23c4a39aa7c8a81f8efa719268eb7fad4
|
|
BLAKE2b-256 checksum How to use checksums |
ef27f42dedd596fbf9fc93f12c999a160b55f4134d13eb50e0a53015ed47f57c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.11.3
|