Skip to main content

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 signxai

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

signxai-0.0.5.tar.gz (5.0 MB view hashes)

Uploaded Source

Built Distribution

signxai-0.0.5-py3-none-any.whl (5.0 MB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page