SIGNed explanations: Unveiling relevant features by reducing bias
Project description
SIGNed explanations: Unveiling relevant features by reducing bias
This repository and python package has been published alongside the following journal article: https://doi.org/10.1016/j.inffus.2023.101883
If you use the code from this repository in your work, please cite:
@article{Gumpfer2023SIGN,
title = {SIGNed explanations: Unveiling relevant features by reducing bias},
author = {Nils Gumpfer and Joshua Prim and Till Keller and Bernhard Seeger and Michael Guckert and Jennifer Hannig},
journal = {Information Fusion},
pages = {101883},
year = {2023},
issn = {1566-2535},
doi = {https://doi.org/10.1016/j.inffus.2023.101883},
url = {https://www.sciencedirect.com/science/article/pii/S1566253523001999}
}
Setup
To install the package in your environment, run:
pip3 install SIGN-XAI
Usage
The below example illustrates the usage of the signxai
package in combination with a VGG16 model trained on imagenet:
import numpy as np
import matplotlib.pyplot as plt
from tensorflow.keras.applications.vgg16 import VGG16
from signxai.methods.wrappers import calculate_relevancemap
from signxai.utils.utils import load_example_image, aggregate_and_normalize_relevancemap_rgb
# Load model
model = VGG16(weights='imagenet')
# Remove last layer's softmax activation (we need the raw values!)
model.layers[-1].activation = None
# Load example image
img, x = load_example_image()
# Calculate relevancemaps
R1 = calculate_relevancemap('lrpz_epsilon_0_1_std_x', np.array(x), model)
R2 = calculate_relevancemap('lrpsign_epsilon_0_1_std_x', np.array(x), model)
# Aggregate and normalize relevancemaps for visualization
H1 = aggregate_and_normalize_relevancemap_rgb(R1)
H2 = aggregate_and_normalize_relevancemap_rgb(R2)
# Visualize heatmaps
fig, axs = plt.subplots(ncols=3, figsize=(18, 6))
axs[0].imshow(img)
axs[1].matshow(H1, cmap='seismic', clim=(-1, 1))
axs[2].matshow(H2, cmap='seismic', clim=(-1, 1))
plt.show()
Experiments
To reproduce the experiments from our paper, please find a detailed description on https://github.com/nilsgumpfer/SIGN.
Project details
Release history Release notifications | RSS feed
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
File details
Details for the file signxai-0.0.3.tar.gz
.
File metadata
- Download URL: signxai-0.0.3.tar.gz
- Upload date:
- Size: 5.0 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.9.6 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/1.0.0 urllib3/1.26.16 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6bb9f10b46395f451645835e9b4726547e972e71e84f3e274f6cd180f3c1e56d |
|
MD5 | b397feb81f4f24a0086e17c4a3732b9f |
|
BLAKE2b-256 | dd2d2ba9069009552ef30db243ffb1d6eefaf1bbff723e41660eaf4d8534fb37 |
File details
Details for the file signxai-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: signxai-0.0.3-py3-none-any.whl
- Upload date:
- Size: 108.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.9.6 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/1.0.0 urllib3/1.26.16 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0e792b48f5f3ed8e706b697ae23e8494e70f2f8b9d2072248cf49550c85fcacd |
|
MD5 | 28e0e3f5824bc4002dfb53a66dd86e72 |
|
BLAKE2b-256 | 8f47154694ca3c77b5e68a96cb9b84f11782a8a1a4014b673347800a4a98ca83 |