Visual explanations for humans
Project description
VisuaLIME
VisuaLIME is an implementation of LIME [1] focused on producing visual local explanations for image classifiers created as part of the XAI Demonstrator project.
In contrast to the reference implementation, VisuaLIME exclusively supports image classification and allows its users control full control over the properties of the generated explanations. It was written to produce stable, reliable, and expressive explanations at scale.
Getting Started
VisuaLIME provides two functions that package its building blocks into a reference explanation pipeline:
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):
# 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.
Roadmap
- Verify that the algorithm matches the original LIME and document differences
- Build out a comprehensive unit test suite
- Add performance benchmarks and optimize implementation of the algorithm
- Include utilities to assess and tune explanations for stability and truthfulness
- Provide a best practice example of implementing a fully configurable LIME explainer
References
[1] Ribeiro et al.: "Why Should I Trust You?": Explaining the Predictions of Any Classifier (arXiv:1602.04938, 2016)
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
Hashes for visualime-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a961ad487e7d3e32cacdfb5af0466add2f215d32ff5dda804ea4f91dd053f94b |
|
MD5 | ab09da9176b99da00a43b7480835c388 |
|
BLAKE2b-256 | 6c8e071b5e61bcbbd02dac61a9d82cbcc0040e5a3c4be7885d09270d4b13736e |