• Stars
    star
    2,370
  • Rank 19,406 (Top 0.4 %)
  • Language
    Python
  • License
    Other
  • Created over 5 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Algorithms for explaining machine learning models

Alibi Logo

Build Status Documentation Status codecov PyPI - Python Version PyPI - Package Version Conda (channel only) GitHub - License 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 or GitHub source (with pip)
  • Anaconda (with conda/mamba)

With pip

  • 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 
  • To take advantage of distributed computation of explanations, install alibi with ray:

    pip install alibi[ray]
  • For SHAP support, install alibi as follows:

    pip install alibi[shap]

With conda

To install from conda-forge it is recommended to use mamba, which can be installed to the base conda enviroment with:

conda install mamba -n base -c conda-forge
  • For the standard Alibi install:

    mamba install -c conda-forge alibi
  • For distributed computing support:

    mamba install -c conda-forge alibi ray
  • For SHAP support:

    mamba install -c conda-forge alibi shap

Usage

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 Distributed
ALE BB global βœ” βœ” βœ”
Partial Dependence BB WB global βœ” βœ” βœ” βœ”
PD Variance BB WB global βœ” βœ” βœ” βœ”
Permutation Importance 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
Counterfactuals with RL BB local βœ” βœ” βœ” βœ” βœ”
Integrated Gradients TF/Keras local βœ” βœ” βœ” βœ” βœ” βœ” Optional
Kernel SHAP BB local

global
βœ” βœ” βœ” βœ” βœ” βœ”
Tree SHAP WB local

global
βœ” βœ” βœ” βœ” Optional
Similarity explanations WB local βœ” βœ” βœ” βœ” βœ” βœ” βœ”

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

Prototypes

These algorithms provide a distilled view of the dataset and help construct a 1-KNN interpretable classifier.

Method Classification Regression Tabular Text Images Categorical Features Train set labels
ProtoSelect βœ” βœ” βœ” βœ” βœ” Optional

References and Examples

Citations

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

BibTeX entry:

@article{JMLR:v22:21-0017,
  author  = {Janis Klaise and Arnaud Van Looveren and Giovanni Vacanti and Alexandru Coca},
  title   = {Alibi Explain: Algorithms for Explaining Machine Learning Models},
  journal = {Journal of Machine Learning Research},
  year    = {2021},
  volume  = {22},
  number  = {181},
  pages   = {1-7},
  url     = {http://jmlr.org/papers/v22/21-0017.html}
}

More Repositories

1

seldon-core

An MLOps framework to package, deploy, monitor and manage thousands of production machine learning models
HTML
4,320
star
2

alibi-detect

Algorithms for outlier, adversarial and drift detection
Python
2,202
star
3

seldon-server

Machine Learning Platform and Recommendation Engine built on Kubernetes
Java
1,475
star
4

MLServer

An inference server for your machine learning models, including support for multiple frameworks, multi-model serving and more
Python
675
star
5

tempo

MLOps Python Library
Python
112
star
6

goven

Goven (go-oven) is a go library that allows you to have a drop-in query language for your database schema.
Go
59
star
7

seldonio.github.com

Seldon Documentation
HTML
31
star
8

k8s-local-docker-registry

Shell
29
star
9

seldon-spark

Seldon Spark Jobs
26
star
10

semantic-vectors-lucene-tools

Tools for building a Lucene index for Semantic Vectors
Java
21
star
11

mlgraph

Machine Learning Inference Graph Spec
21
star
12

seldon-ucl

Seldon UCL Project
JavaScript
17
star
13

seldon-vm

Seldon VM repo
JavaScript
16
star
14

seldon-deploy-sdk

SDK for Seldon Deploy
Mustache
13
star
15

sig-mlops-jenkins-classic

Jupyter Notebook
13
star
16

ml-prediction-schema

Generic schema structure for machine learning model predictions
13
star
17

seldon-operator

Seldon Core Operator for Kubernetes
Go
12
star
18

deploy-workshops

Jupyter Notebook
12
star
19

sig-mlops-seldon-jenkins-x

Jupyter Notebook
11
star
20

cassava-example

Example mlserver and seldon deployment for a cassava leaf classifier
Python
10
star
21

importer-movielens-10m

Create Seldon data import files from Movielens 10m source data
Python
10
star
22

trtis-k8s-scheduler

Custom Scheduler to deploy ML models to TRTIS for GPU Sharing
Go
10
star
23

movie-demo-frontend

js frontend for movie recommender demo
JavaScript
9
star
24

seldon-core-launcher

Seldon Core Cloud Launcher
Jupyter Notebook
9
star
25

seldon-core-examples

Python
8
star
26

eubot

Machine learning classifer for the EU Referendum
Python
7
star
27

seldon-js-lib

A Javascript library to interact with the Seldon Server
7
star
28

ansible-k8s-collection

Collection of Ansible roles and playbooks crafted for Seldon ecosystem
Jinja
7
star
29

seldon-importer-web

Web page importer
6
star
30

tensorflow-demo-notebooks

Building and deploying a TensorFlow MNIST digit classifier on Kubernetes with Seldon
Jupyter Notebook
6
star
31

seldon-java-client

Seldon Java REST Client
5
star
32

jenkins-x-seldon-core-sandbox

HTML
5
star
33

deep-mnist-webapp

A webapp that recognises characters you draw using Seldon and Tensorflow.
JavaScript
5
star
34

seldon-server-config-template

5
star
35

seldon-models

A repository of training, inference and packaging code for Seldon demo models
Jupyter Notebook
5
star
36

seldon-deploy-operator

Seldon Deploy installation
Makefile
4
star
37

i-am-spartakus

Go
4
star
38

cicd-demo-model-source-files

Makefile
4
star
39

triton-python-examples

Triton inference server python backend examples
Python
3
star
40

DistributedKernelShap

Python
3
star
41

JPMML-utils

Helper function to use JPMML with Seldon-Core
Java
3
star
42

seldon-server-config-vm

Seldon Server configuration required for the Docker VM
3
star
43

seldon-gcp-marketplace

Seldon Core GCP Marketplace
Makefile
2
star
44

environment-paladinrose-staging

Makefile
2
star
45

environment-seldon-core-test-ci-cluster-dev

Shell
2
star
46

alibi-testing

Repository for storing and loading model binaries for testing purposes
Python
2
star
47

environment-paladinrose-production

Makefile
2
star
48

seldon

Seldon Top Level Repo
2
star
49

helm-charts

Seldon Helm Charts
Mustache
2
star
50

cicd-demo-k8s-manifest-files

Shell
2
star
51

seldon-java-wrapper

Wrap java code for use with seldon-core
Java
2
star
52

test-ci-project

1
star
53

seldon-gitops

Example GitOps repository.
1
star
54

seldon-core-aws

Seldon Core AWS Marketplace Helm Charts
Smarty
1
star
55

seldon-deploy-demos-gitops-template

1
star
56

movie-demo-setup

movie-demo-setup
JavaScript
1
star
57

seldon-prometheus-exporter

Go
1
star
58

seldon-deploy-resources

Dockerfile
1
star
59

seldon-mlmd-tools

Python
1
star