This repository contains implementation for the AISTATS 2021 paper ”Shapley Flow: A Graph-based Approach to Interpreting Model Predictions”.
The directory is organized as the following.
notebooks/
contains case studies and experiments for the paper
- Tutorial for Shapley Flow: pdf version, ipynb version
- Sanity check examples for Section 4.3
- Experiments with the nutrition dataset for sanity check with linear model in Section 4.3
- Experiments with the adult censor income dataset for sanity check with linear model
- Case study of the nutrition dataset in Section 4.4
- Case study of the adult censor income dataset
- Case study of the nutrition dataset with multiple baseline and 95% confidence interval
archive/
include note and experiments for previous iterations of the project.
Files in the current directory include implementations of the algorithm and baselines.
- Implementation of the Shapley Flow algorithm
- Implementation of the on-manifold SHAP baseline
- Evaluation code for paper Section 4.3
We rely on pygraphviz for visualization. Installing pygraphviz requires to install graphviz first, see this post if pygraphviz fails to install.
pip3 install shapflow
from shapflow import flow
flow.example_concise() # running the sanity check example in flow.py
get graphviz related packages
brew install graphviz # for mac os
python -m pip install \
--global-option=build_ext \
--global-option="-I$(brew --prefix graphviz)/include/" \
--global-option="-L$(brew --prefix graphviz)/lib/" \
pygraphviz # see https://github.com/pygraphviz/pygraphviz/issues/398 for an explanation
pip install graphviz
Now it should be able to run
python flow.py # should output a print out of flow credit for a sample graph
python3 -m venv venv # create virtual env, I'm using python 3.10.8
. venv/bin/activate
pip install xgboost
pip install pandas
pip install tqdm
pip install joblib
pip install dill
pip install scikit-learn
One can check that the installation works:
python flow.py # should output a print out of flow credit for a sample graph
Some users reported errors installing using pipenv, try the above 2 methods first
Install dependencies using pipenv
pip install pipenv
pipenv shell # create a shell that can later deactivate by Ctrl-d
pipenv install # install all packages in Pipfile