understandable-machine-intelligence-lab/Quantus

[JMLR 2023] Quantus is an eXplainable AI toolkit for responsible evaluation of neural network explanations

Quantus – A Toolkit for Evaluating Neural‑Network Explanations

What it is Quantus is an open‑source Python library that helps researchers and practitioners measure how good explanation methods (also called XAI methods) are for neural networks. It provides more than 35 quantitative metrics, grouped into six families (faithfulness, robustness, localisation, complexity, randomisation/sensitivity, and axiomatic), and works with both PyTorch and TensorFlow models.

Why it matters Explaining a model’s predictions is easy to do visually, but deciding which explanation method actually reflects the model’s reasoning is hard. Quantus automates this decision‑making by turning qualitative visual checks into reproducible numbers, making it possible to compare methods, run sensitivity analyses, and report results that can be reproduced by others.

Key features

  • 35+ ready‑to‑use metrics covering the main evaluation dimensions used in XAI research.
  • Framework agnostic – works with PyTorch or TensorFlow models and supports popular explanation libraries such as Captum, tf‑explain, and Zennit.
  • Multi‑modal support – currently handles image, time‑series, and tabular data, with NLP support planned.
  • Batch implementation for a 12× speed‑up of existing faithfulness metrics.
  • Extensible – new metrics can be added, and the library is under active development (e.g., EfficientMPRT, SmoothMPRT).
  • Documentation & tutorials – Colab notebook, Binder launch, and detailed docs on ReadTheDocs.
  • Installation options – lightweight core package on PyPI; optional extras install the deep‑learning framework you need (quantus[torch] or quantus[tensorflow]).

Typical workflow

  1. Prepare inputs – a trained model, a batch of data (x_batch), true labels (y_batch), and the explanations you want to evaluate (a_batch).
  2. Instantiate a metric – e.g., FaithfulnessCorrelation() from quantus.metrics.faithfulness.
  3. Run the metric – call metric.evaluate(model, x_batch, a_batch, y_batch) to obtain a numeric score.
  4. Compare – repeat for multiple explanation methods and metrics; visualise results with the library’s built‑in plotting utilities.

Getting started

pip install "quantus[torch]"   # or "quantus[tensorflow]"

Then follow the Colab tutorial linked in the README for a step‑by‑step example using a pre‑trained LeNet model.

Community The project is maintained by the Understandable Machine Intelligence Lab. Contributions are welcomed via GitHub and a Discord community.

Citation If you use Quantus, cite the accompanying JMLR paper:

@article{hedstrom2023quantus,
  author = {Anna Hedström et al.},
  title  = {Quantus: An Explainable AI Toolkit for Responsible Evaluation of Neural Network Explanations and Beyond},
  journal= {JMLR},
  year   = 2023
}

Related

  • Project
  • Project
  • Project
  • Project
  • Project