Skip to main content

Algorithms for monitoring and explaining machine learning models

Project description

Alibi Logo

Build Status Documentation Status codecov Python version PyPI version GitHub Licence Slack channel

Alibi is an open source Python library aimed at machine learning model inspection and interpretation. The focus of the library is to provide high-quality implementations of black-box, white-box, local and global explanation methods for classification and regression models.

If you're interested in outlier detection, concept drift or adversarial instance detection, check out our sister project alibi-detect.


Anchor explanations for images


Integrated Gradients for text


Counterfactual examples


Accumulated Local Effects

Table of Contents

Installation and Usage

Alibi can be installed from PyPI:

pip install alibi

Alternatively, the development version can be installed:

pip install git+https://github.com/SeldonIO/alibi.git 

The alibi explanation API takes inspiration from scikit-learn, consisting of distinct initialize, fit and explain steps. We will use the AnchorTabular explainer to illustrate the API:

from alibi.explainers import AnchorTabular

# initialize and fit explainer by passing a prediction function and any other required arguments
explainer = AnchorTabular(predict_fn, feature_names=feature_names, category_map=category_map)
explainer.fit(X_train)

# explain an instance
explanation = explainer.explain(x)

The explanation returned is an Explanation object with attributes meta and data. meta is a dictionary containing the explainer metadata and any hyperparameters and data is a dictionary containing everything related to the computed explanation. For example, for the Anchor algorithm the explanation can be accessed via explanation.data['anchor'] (or explanation.anchor). The exact details of available fields varies from method to method so we encourage the reader to become familiar with the types of methods supported.

Supported Methods

The following tables summarize the possible use cases for each method.

Model Explanations

Method Models Explanations Classification Regression Tabular Text Images Categorical features Train set required
ALE BB global
Anchors BB local For Tabular
CEM BB* TF/Keras local Optional
Counterfactuals BB* TF/Keras local No
Prototype Counterfactuals BB* TF/Keras local Optional
Integrated Gradients TF/Keras local Optional
Kernel SHAP BB local

global
Tree SHAP WB local

global
Optional

Model Confidence

These algorithms provide instance-specific scores measuring the model confidence for making a particular prediction.

Method Models Classification Regression Tabular Text Images Categorical Features Train set required
Trust Scores BB ✔(1) ✔(2) Yes
Linearity Measure BB Optional

Key:

  • BB - black-box (only require a prediction function)
  • BB* - black-box but assume model is differentiable
  • WB - requires white-box model access. There may be limitations on models supported
  • TF/Keras - TensorFlow models via the Keras API
  • Local - instance specific explanation, why was this prediction made?
  • Global - explains the model with respect to a set of instances
  • (1) - depending on model
  • (2) - may require dimensionality reduction

References and Examples

Dependencies

  attrs
  beautifulsoup4
  numpy
  Pillow
  pandas
  prettyprinter
  requests
  scikit-learn
  scikit-image<0.17
  scipy
  shap>=0.36
  spacy
  tensorflow>=2.0
  typing-extensions

Citations

If you use alibi in your research, please consider citing it.

BibTeX entry:

@software{alibi,
  title = {Alibi: Algorithms for monitoring and explaining machine learning models},
  author = {Klaise, Janis and Van Looveren, Arnaud and Vacanti, Giovanni and Coca, Alexandru},
  url = {https://github.com/SeldonIO/alibi},
  version = {0.5.4},
  date = {2020-09-03},
  year = {2019}
}

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

alibi-0.5.4.tar.gz (189.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

alibi-0.5.4-py3-none-any.whl (215.7 kB view details)

Uploaded Python 3

File details

Details for the file alibi-0.5.4.tar.gz.

File metadata

  • Download URL: alibi-0.5.4.tar.gz
  • Upload date:
  • Size: 189.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1.post20200616 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.6

File hashes

Hashes for alibi-0.5.4.tar.gz
Algorithm Hash digest
SHA256 de0fdbd08cd5267d050f7b61dc671f1f6b18f872e1088ee58a9a468f25c24380
MD5 1749fa91a1341d695692617f6a69dc86
BLAKE2b-256 e8236334387a44bc960c55af78d7458dbae6ae104323ed92ac785a56859f4d35

See more details on using hashes here.

File details

Details for the file alibi-0.5.4-py3-none-any.whl.

File metadata

  • Download URL: alibi-0.5.4-py3-none-any.whl
  • Upload date:
  • Size: 215.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1.post20200616 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.6

File hashes

Hashes for alibi-0.5.4-py3-none-any.whl
Algorithm Hash digest
SHA256 6b1668d99df719d0c3f7a48ff2a960a23db2e03a6e04e14b266b51d02b47f8a1
MD5 8493892e23bf6c0bccbdda2d0b1f3ae7
BLAKE2b-256 2c0f1de259336ecb2eeeb06d703c210effb66febf9f9273ff146fb29b66f17a7

See more details on using hashes here.

Supported by

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