Skater is a python package for model agnostic interpretation of predictive models. With Skater, you can unpack the internal mechanics of arbitrary models; as long as you can obtain inputs, and use a function to obtain outputs, you can use Skater to learn about the models internal decision policies.
The project was started as a research idea to find ways to enable better interpretability(preferably human interpretability) to predictive "black boxes" both for researchers and practioners.
Overview | Introduction to the Skater library |
Installing | How to install the Skater library |
Tutorial | Steps to use Skater effectively. |
API Reference | The detailed reference for Skater's API. |
Contributing | Guide to contributing to the Skater project. |
Feature Requests/Bugs | GitHub issue tracker |
Usage questions | Gitter chat |
General discussion | Gitter chat |
Skater relies on numpy, pandas, scikit-learn, and the DataScience.com fork of the LIME package. Plotting functionality requires matplotlib, though it is not required to install the package.
When using pip, to ensure your system is not modified by an installation, it is recommended that you use a virtual environment (virtualenv, conda environment).
pip install -U Skater
Skater is available in the conda-forge channel with builds for Linux, OS X and Windows.
conda install -c conda-forge Skater
Follow the steps mentioned at the link mentioned below to install conda, https://conda.io/docs/user-guide/install/linux.html
Quick summary to install conda and setup the python environment(recommended steps for using python3.x) 1. wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh 2. bash miniconda.sh -b -p $HOME/miniconda 3. export PATH="$HOME/miniconda/bin:$PATH" 4. conda config --set always_yes yes --set changeps1 no 5. conda info -a Installation: Option1: 1. conda install gxx_linux-64 2. git clone the repo 3. sudo python setup.py install --ostype=linux-ubuntu --rl=True Option2: 1. conda install gxx_linux-64 2. sudo pip install -U --no-deps --force-reinstall --install-option="--rl=True" skater==1.1.0b1
The code below illustrates a typical workflow with the Skater package.
import numpy as np from scipy.stats import norm #gen some data B = np.random.normal(0, 10, size = 3) X = np.random.normal(0,10, size=(1000, 3)) feature_names = ["feature_{}".format(i) for i in xrange(3)] e = norm(0, 5) y = np.dot(X, B) + e.rvs(1000) example = X[0] #model it from sklearn.ensemble import RandomForestRegressor regressor = RandomForestRegressor() regressor.fit(X, y) #partial dependence from skater.core.explanations import Interpretation from skater.model import InMemoryModel i = Interpretation(X, feature_names=feature_names) model = InMemoryModel(regressor.predict, examples = X) i.partial_dependence.plot_partial_dependence([feature_names[0], feature_names[1]], model) #local interpretation from skater.core.local_interpretation.lime.lime_tabular import LimeTabularExplainer explainer = LimeTabularExplainer(X, feature_names = feature_names) model = InMemoryModel(regressor.predict) explainer.explain_regressor_instance(example, model).show_in_notebook()
1. If repo is cloned:
python skater/tests/all_tests.py
2. If pip installed:
python -c "from skater.tests.all_tests import run_tests; run_tests()"
If you decide to use Skater to resolve interpretability needs, please consider citing the project with the below mentioned DOI,
@misc{pramit_choudhary_2018_1198885, author = {Pramit Choudhary and Aaron Kramer and datascience.com team}, contributor = {Ben Van Dyke, alvinthai, Dave Thompson}, title = {{Skater: Model Interpretation Library}}, month = mar, year = 2018, doi = {10.5281/zenodo.1198885}, url = {https://doi.org/10.5281/zenodo.1198885} }
Refer to https://github.com/christophM/iml
- Christoph Molnar, Interpretable Machine Learning: https://christophm.github.io/interpretable-ml-book/
- Dipanjan Sarkar et al., Practical Machine Learning with Python: https://github.com/dipanjanS/practical-machine-learning-with-python