Machine learning algorithms create potentially more accurate models than linear models, but any increase in accuracy over more traditional, better-understood, and more easily explainable techniques is not practical for those who must explain their models to regulators or customers. For many decades, the models created by machine learning algorithms were generally taken to be black-boxes. However, a recent flurry of research has introduced credible techniques for interpreting complex, machine-learned models. Materials presented here illustrate applications or adaptations of these techniques for practicing data scientists.
Want to contribute your own content? Just make a pull request.
Want to use the content in this repo? Just cite the H2O.ai machine learning interpretability team or the original author(s) as appropriate.
(A Dockerfile is provided that will construct a container with all necessary dependencies to run the examples here.)
A Dockerfile is provided to build a docker container with all necessary packages and dependencies. This is the easiest way to use these examples if you are on Mac OS X, *nix, or Windows 10. To do so:
$ mkdir anaconda_py36_h2o_xgboost_graphviz
$ curl https://raw.githubusercontent.com/h2oai/mli-resources/master/anaconda_py36_h2o_xgboost_graphviz/Dockerfile > anaconda_py36_h2o_xgboost_graphviz/Dockerfile
sudo
.
$ docker build --no-cache anaconda_py36_h2o_xgboost_graphviz
$ docker images
$ docker run -i -t -p 8888:8888 <image_id> /bin/bash -c "/opt/conda/bin/conda install jupyter -y --quiet && /opt/conda/bin/jupyter notebook --notebook-dir=/mli-resources --ip='*' --port=8888 --no-browser --allow-root"
$ docker ps
$ docker cp path/to/train.csv <container_id>:/mli-resources/data/train.csv
Install:
Anaconda Python 5.1.0 from the Anaconda archives.
Java.
The latest stable h2o Python package.
Git.
XGBoost with Python bindings.
Anaconda Python, Java, Git, and GraphViz must be added to your system path.
From a terminal:
Clone the mli-resources repository with examples.
$ git clone https://github.com/h2oai/mli-resources.git
$ cd mli-resources
Copy the sample data into the mli-resources repo directory. Refer to GetData.md to obtain datasets needed for notebooks.
$ cp path/to/train.csv ./data
Start the Jupyter notebook server.
$ jupyter notebook
Navigate to the port Jupyter directs you to on your machine.
The notebooks in this repo have been revamped and refined many times. Other versions with different, and potentially interesting, details are available at these locations:
One way to test generated explanations for accuracy is with simulated data with known characteristics. For instance, models trained on totally random data with no relationship between a number of input variables and a prediction target should not give strong weight to any input variable nor generate compelling local explanations or reason codes. Conversely, you can use simulated data with a known signal generating function to test that explanations accurately represent that known function. Detailed examples of testing explanations with simulated data are available here. A summary of these results are available here.