chore: import upstream snapshot with attribution

This commit is contained in:
wehub-resource-sync
2026-07-13 13:22:52 +08:00
commit 9d4c7d16ba
528 changed files with 740585 additions and 0 deletions
+226
View File
@@ -0,0 +1,226 @@
# Makefile for Sphinx documentation
#
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
PAPER =
BUILDDIR = _build
# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
# the i18n builder cannot share the environment and doctrees with the others
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
.PHONY: help
help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " html to make standalone HTML files"
@echo " dirhtml to make HTML files named index.html in directories"
@echo " singlehtml to make a single large HTML file"
@echo " pickle to make pickle files"
@echo " json to make JSON files"
@echo " htmlhelp to make HTML files and a HTML help project"
@echo " qthelp to make HTML files and a qthelp project"
@echo " applehelp to make an Apple Help Book"
@echo " devhelp to make HTML files and a Devhelp project"
@echo " epub to make an epub"
@echo " epub3 to make an epub3"
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
@echo " latexpdf to make LaTeX files and run them through pdflatex"
@echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx"
@echo " text to make text files"
@echo " man to make manual pages"
@echo " texinfo to make Texinfo files"
@echo " info to make Texinfo files and run them through makeinfo"
@echo " gettext to make PO message catalogs"
@echo " changes to make an overview of all changed/added/deprecated items"
@echo " xml to make Docutils-native XML files"
@echo " pseudoxml to make pseudoxml-XML files for display purposes"
@echo " linkcheck to check all external links for integrity"
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
@echo " coverage to run coverage check of the documentation (if enabled)"
@echo " dummy to check syntax errors of document sources"
.PHONY: clean
clean:
rm -rf $(BUILDDIR)/*
rm -rf generated/*
.PHONY: html
html:
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
.PHONY: dirhtml
dirhtml:
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
.PHONY: singlehtml
singlehtml:
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
@echo
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
.PHONY: pickle
pickle:
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
@echo
@echo "Build finished; now you can process the pickle files."
.PHONY: json
json:
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
@echo
@echo "Build finished; now you can process the JSON files."
.PHONY: htmlhelp
htmlhelp:
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
@echo
@echo "Build finished; now you can run HTML Help Workshop with the" \
".hhp project file in $(BUILDDIR)/htmlhelp."
.PHONY: qthelp
qthelp:
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
@echo
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/SHAP.qhcp"
@echo "To view the help file:"
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/SHAP.qhc"
.PHONY: applehelp
applehelp:
$(SPHINXBUILD) -b applehelp $(ALLSPHINXOPTS) $(BUILDDIR)/applehelp
@echo
@echo "Build finished. The help book is in $(BUILDDIR)/applehelp."
@echo "N.B. You won't be able to view it unless you put it in" \
"~/Library/Documentation/Help or install it in your application" \
"bundle."
.PHONY: devhelp
devhelp:
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
@echo
@echo "Build finished."
@echo "To view the help file:"
@echo "# mkdir -p $$HOME/.local/share/devhelp/SHAP"
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/SHAP"
@echo "# devhelp"
.PHONY: epub
epub:
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
@echo
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
.PHONY: epub3
epub3:
$(SPHINXBUILD) -b epub3 $(ALLSPHINXOPTS) $(BUILDDIR)/epub3
@echo
@echo "Build finished. The epub3 file is in $(BUILDDIR)/epub3."
.PHONY: latex
latex:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
@echo "Run \`make' in that directory to run these through (pdf)latex" \
"(use \`make latexpdf' here to do that automatically)."
.PHONY: latexpdf
latexpdf:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through pdflatex..."
$(MAKE) -C $(BUILDDIR)/latex all-pdf
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
.PHONY: latexpdfja
latexpdfja:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through platex and dvipdfmx..."
$(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
.PHONY: text
text:
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
@echo
@echo "Build finished. The text files are in $(BUILDDIR)/text."
.PHONY: man
man:
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
@echo
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
.PHONY: texinfo
texinfo:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo
@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
@echo "Run \`make' in that directory to run these through makeinfo" \
"(use \`make info' here to do that automatically)."
.PHONY: info
info:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo "Running Texinfo files through makeinfo..."
make -C $(BUILDDIR)/texinfo info
@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
.PHONY: gettext
gettext:
$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
@echo
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
.PHONY: changes
changes:
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
@echo
@echo "The overview file is in $(BUILDDIR)/changes."
.PHONY: linkcheck
linkcheck:
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
@echo
@echo "Link check complete; look for any errors in the above output " \
"or in $(BUILDDIR)/linkcheck/output.txt."
.PHONY: doctest
doctest:
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
@echo "Testing of doctests in the sources finished, look at the " \
"results in $(BUILDDIR)/doctest/output.txt."
.PHONY: coverage
coverage:
$(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage
@echo "Testing of coverage in the sources finished, look at the " \
"results in $(BUILDDIR)/coverage/python.txt."
.PHONY: xml
xml:
$(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
@echo
@echo "Build finished. The XML files are in $(BUILDDIR)/xml."
.PHONY: pseudoxml
pseudoxml:
$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
@echo
@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."
.PHONY: dummy
dummy:
$(SPHINXBUILD) -b dummy $(ALLSPHINXOPTS) $(BUILDDIR)/dummy
@echo
@echo "Build finished. Dummy builder generates no files."
+57
View File
@@ -0,0 +1,57 @@
.wy-side-nav-search>div.version {
color: black;
}
@media screen and (min-width: 767px) {
.wy-table-responsive table td {
white-space: normal;
}
.wy-table-responsive {
overflow: visible;
}
}
.wy-side-nav-search .wy-dropdown>a img.logo,.wy-side-nav-search>a img.logo {
max-width: 40%;
}
.wy-side-nav-search>div.version {
color: #d9d9d9;
}
.wy-nav-top {
background: #343131;
}
.highlight {
background: #f7f7f7;
}
.wy-side-nav-search input[type=text] {
border-color: #666666;
}
a {
color: #008bfb;
}
a:hover {
color: #008bfb;
}
a:visited {
color: #008bfb;
}
html.writer-html4 .rst-content dl:not(.docutils)>dt, html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.glossary):not(.simple)>dt {
background: #008bfb11;
color: #0086f6;
border-top: 3px solid #008bfbaa;
}
.rst-versions .rst-current-version {
color: #fcfcfc;
}
.wy-menu-vertical a {
color: #d9d9d9;
}
+5
View File
@@ -0,0 +1,5 @@
{# layout.html #}
{# Import the layout of the theme. #}
{% extends "!layout.html" %}
{% set css_files = css_files + ['_static/css/style.css'] %}
+154
View File
@@ -0,0 +1,154 @@
.. currentmodule:: shap
API Reference
=============
This page contains the API reference for public objects and functions in SHAP.
There are also :ref:`example notebooks <api_examples>` available that demonstrate how
to use the API of each object/function.
.. _explanation_api:
Explanation
-----------
.. autosummary::
:toctree: generated/
shap.Explanation
shap.Cohorts
.. _explainers_api:
explainers
----------
*See also:* :ref:`Explainer API Examples <explainers_examples>`.
.. autosummary::
:toctree: generated/
shap.Explainer
shap.TreeExplainer
shap.GPUTreeExplainer
shap.LinearExplainer
shap.PermutationExplainer
shap.PartitionExplainer
shap.SamplingExplainer
shap.AdditiveExplainer
shap.DeepExplainer
shap.KernelExplainer
shap.GradientExplainer
shap.ExactExplainer
shap.explainers.other.Coefficient
shap.explainers.other.Random
shap.explainers.other.LimeTabular
shap.explainers.other.Maple
shap.explainers.other.TreeMaple
shap.explainers.other.TreeGain
.. _plots_api:
plots
-----
*See also:* :ref:`Plot API Examples <plots_examples>`.
.. autosummary::
:toctree: generated/
shap.plots.bar
shap.plots.waterfall
shap.plots.scatter
shap.plots.heatmap
shap.plots.force
shap.plots.text
shap.plots.image
shap.plots.partial_dependence
shap.plots.decision
shap.plots.embedding
shap.plots.initjs
shap.plots.group_difference
shap.plots.image_to_text
shap.plots.monitoring
shap.plots.beeswarm
shap.plots.violin
.. _maskers_api:
maskers
-------
*See also:* :ref:`Masker API Examples <maskers_examples>`.
.. autosummary::
:toctree: generated/
shap.maskers.Masker
shap.maskers.Independent
shap.maskers.Partition
shap.maskers.Impute
shap.maskers.Fixed
shap.maskers.Composite
shap.maskers.FixedComposite
shap.maskers.OutputComposite
shap.maskers.Text
shap.maskers.Image
.. _models_api:
models
------
.. autosummary::
:toctree: generated/
shap.models.Model
shap.models.TeacherForcing
shap.models.TextGeneration
shap.models.TopKLM
shap.models.TransformersPipeline
.. _utils_api:
utils
-----
.. autosummary::
:toctree: generated/
shap.utils.hclust
shap.utils.hclust_ordering
shap.utils.partition_tree
shap.utils.partition_tree_shuffle
shap.utils.delta_minimization_order
shap.utils.approximate_interactions
shap.utils.potential_interactions
shap.utils.sample
shap.utils.shapley_coefficients
shap.utils.convert_name
shap.utils.OpChain
shap.utils.show_progress
shap.utils.MaskedModel
shap.utils.make_masks
.. _datasets_api:
datasets
--------
.. autosummary::
:toctree: generated/
shap.datasets.a1a
shap.datasets.adult
shap.datasets.california
shap.datasets.communitiesandcrime
shap.datasets.corrgroups60
shap.datasets.diabetes
shap.datasets.imagenet50
shap.datasets.imdb
shap.datasets.independentlinear60
shap.datasets.iris
shap.datasets.linnerud
shap.datasets.nhanesi
shap.datasets.rank
+71
View File
@@ -0,0 +1,71 @@
.. currentmodule:: shap
.. _api_examples:
API Examples
----------------
These examples parallel the namespace structure of SHAP. Each object or function in SHAP has a
corresponding example notebook here that demonstrates its API usage. The source notebooks
are `available on GitHub <https://github.com/shap/shap/tree/master/notebooks/api_examples>`_.
.. toctree::
:glob:
:maxdepth: 1
example_notebooks/api_examples/migrating-to-new-api.ipynb
.. _explainers_examples:
explainers
==========
*See also:* :ref:`Explainer API Reference <explainers_api>`.
.. toctree::
:glob:
:maxdepth: 1
example_notebooks/api_examples/explainers/*
.. _maskers_examples:
maskers
=======
*See also:* :ref:`Masker API Reference <maskers_api>`.
.. toctree::
:glob:
:maxdepth: 1
example_notebooks/api_examples/maskers/*
.. _models_examples:
models
======
.. Examples for members of :ref:`shap.models <models_api>`.
Work in progress.
.. TODO: Uncomment this toctree once we have at least one example to share
.. toctree::
:glob:
:maxdepth: 1
example_notebooks/api_examples/models/*
.. _plots_examples:
plots
=====
*See also:* :ref:`Plot API Reference <plots_api>`.
.. toctree::
:glob:
:maxdepth: 1
example_notebooks/api_examples/plots/*
Binary file not shown.

After

Width:  |  Height:  |  Size: 89 KiB

File diff suppressed because one or more lines are too long
Binary file not shown.

After

Width:  |  Height:  |  Size: 517 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

File diff suppressed because one or more lines are too long
Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 502 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 344 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB

+1454
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 95 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 179 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 167 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

File diff suppressed because one or more lines are too long
Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 235 KiB

+48
View File
@@ -0,0 +1,48 @@
.. currentmodule:: shap
.. benchmarks
Benchmarks
----------
These benchmark notebooks compare different types of explainers across a variety of metrics.
They are all generated from Jupyter notebooks
`available on GitHub <https://github.com/shap/shap/tree/master/notebooks/benchmarks>`_.
Image
=====
.. toctree::
:glob:
:maxdepth: 1
example_notebooks/benchmarks/image/*
Tabular
=======
Benchmarks that compare explainers on tabular datasets.
.. toctree::
:glob:
:maxdepth: 1
example_notebooks/benchmarks/tabular/*
Text
====
Benchmarks that compare explainers on text datasets.
.. toctree::
:glob:
:maxdepth: 1
example_notebooks/benchmarks/text/*
Others
======
.. toctree::
:glob:
:maxdepth: 1
example_notebooks/benchmarks/others/*
+455
View File
@@ -0,0 +1,455 @@
#!/usr/bin/env python3
#
# SHAP documentation build configuration file, created by
# sphinx-quickstart on Tue May 22 10:44:55 2018.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
import shutil
import sys
import requests
print(os.path.abspath("./shap"))
sys.path.insert(0, os.path.abspath(".."))
# make copy of notebooks in docs folder, as they must be here for sphinx to
# pick them up properly.
NOTEBOOKS_DIR = os.path.abspath("example_notebooks")
if os.path.exists(NOTEBOOKS_DIR):
import warnings
warnings.warn("example_notebooks directory exists, replacing...")
shutil.rmtree(NOTEBOOKS_DIR)
shutil.copytree(os.path.abspath("../notebooks"), NOTEBOOKS_DIR)
if os.path.exists(NOTEBOOKS_DIR + "/local_scratch"):
shutil.rmtree(NOTEBOOKS_DIR + "/local_scratch")
# -- General configuration ------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
#
# needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.autosectionlabel",
"sphinx.ext.autosummary",
"sphinx.ext.intersphinx",
"sphinx_rtd_theme",
"numpydoc",
"nbsphinx", # Allows parsing Jupyter notebooks
"myst_parser", # Allows parsing Markdown, such as CONTRIBUTING.md
"sphinx_github_changelog",
]
# --- Extension options
# [autodoc]
autodoc_default_options = {"members": True, "inherited-members": True}
# [autosectionlabel]
# Make sure the autogenerated targets are unique
autosectionlabel_prefix_document = True
# [autosummary]
autosummary_generate = True
# [intersphinx]
intersphinx_mapping = {
# "stdlib": ("https://docs.python.org/3", None),
"mpl": (
"https://matplotlib.org/stable/",
"https://matplotlib.org/stable/objects.inv",
),
"scikit-learn": (
"https://scikit-learn.org/stable/",
"https://scikit-learn.org/stable/objects.inv",
),
"scipy": ("https://docs.scipy.org/doc/scipy", None),
}
# Sphinx defaults to automatically resolve *unresolved* labels using all your Intersphinx mappings.
# This behavior has unintended side-effects, namely that documentations local references can
# suddenly resolve to an external location.
# See also:
# https://www.sphinx-doc.org/en/master/usage/extensions/intersphinx.html#confval-intersphinx_disabled_reftypes
intersphinx_disabled_reftypes = ["*"]
# [numpydoc]
numpydoc_show_class_members = False
# ---
# Do not create toctree entries for each class/function
toc_object_entries = False
# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]
# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = ".rst"
# The encoding of source files.
#
# source_encoding = 'utf-8-sig'
# The master toctree document.
master_doc = "index"
# General information about the project.
project = "SHAP"
copyright = "2018, Scott Lundberg"
author = "Scott Lundberg"
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = "latest"
# The full version, including alpha/beta/rc tags.
release = "latest"
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = "en"
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#
# today = ''
#
# Else, today_fmt is used as the format for a strftime call.
#
# today_fmt = '%B %d, %Y'
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path
exclude_patterns = [
"_build",
"Thumbs.db",
".DS_Store",
"example_notebooks/tabular_examples/tree_based_models/tree_shap_paper",
"user_studies",
"local",
]
# The reST default role (used for this markup: `text`) to use for all
# documents.
#
# default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text.
#
# add_function_parentheses = True
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
#
# add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
#
# show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = "sphinx"
# A list of ignored prefixes for module index sorting.
# modindex_common_prefix = []
# If true, keep warnings as "system message" paragraphs in the built documents.
# keep_warnings = False
# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False
# -- Release notes configuration ------------------------------------------
# Make available a URL that points to the latest unreleased changes
def get_latest_tag() -> str:
"""Query GitHub API to get the most recent git tag"""
url = "https://api.github.com/repos/shap/shap/releases/latest"
response = requests.get(url)
response.raise_for_status()
return response.json()["tag_name"]
_latest_tag = get_latest_tag()
_url = f"https://github.com/shap/shap/compare/{_latest_tag}...master"
# Make an RST substitution that inserts the correct hyperlink
rst_epilog = f"""
.. |unreleasedchanges| replace:: {_latest_tag}...master
.. _unreleasedchanges: {_url}
"""
# -- Options for HTML output ----------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
# html_theme = 'alabaster'
html_theme = "sphinx_rtd_theme"
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#
html_theme_options = {
#'canonical_url': '',
"logo_only": True,
"display_version": True,
"prev_next_buttons_location": "bottom",
"style_external_links": False,
"style_nav_header_background": "#343131",
# Toc options
"collapse_navigation": True,
"sticky_navigation": True,
"navigation_depth": 4,
"includehidden": True,
"titles_only": False,
}
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
html_logo = "artwork/shap_logo_white.png"
# Add any paths that contain custom themes here, relative to this directory.
# html_theme_path = []
# The name for this set of Sphinx documents.
# "<project> v<release> documentation" by default.
#
# html_title = 'SHAP v0.16'
# A shorter title for the navigation bar. Default is the same as html_title.
#
# html_short_title = None
# The name of an image file (relative to this directory) to use as a favicon of
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#
html_favicon = "artwork/favicon.ico"
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"]
# Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
# directly to the root of the documentation.
#
# html_extra_path = []
# If not None, a 'Last updated on:' timestamp is inserted at every page
# bottom, using the given strftime format.
# The empty string is equivalent to '%b %d, %Y'.
#
# html_last_updated_fmt = None
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
#
# html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
#
# html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to
# template names.
#
# html_additional_pages = {}
# If false, no module index is generated.
#
# html_domain_indices = True
# If false, no index is generated.
#
# html_use_index = True
# If true, the index is split into individual pages for each letter.
#
# html_split_index = False
# If true, links to the reST sources are added to the pages.
#
# html_show_sourcelink = True
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
#
# html_show_sphinx = True
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
#
# html_show_copyright = True
# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served.
#
# html_use_opensearch = ''
# This is the file name suffix for HTML files (e.g. ".xhtml").
# html_file_suffix = None
# Language to be used for generating the HTML full-text search index.
# Sphinx supports the following languages:
# 'da', 'de', 'en', 'es', 'fi', 'fr', 'h', 'it', 'ja'
# 'nl', 'no', 'pt', 'ro', 'r', 'sv', 'tr', 'zh'
#
# html_search_language = 'en'
# A dictionary with options for the search language support, empty by default.
# 'ja' uses this config value.
# 'zh' user can custom change `jieba` dictionary path.
#
# html_search_options = {'type': 'default'}
# The name of a javascript file (relative to the configuration directory) that
# implements a search results scorer. If empty, the default will be used.
#
# html_search_scorer = 'scorer.js'
# Output file base name for HTML help builder.
htmlhelp_basename = "SHAPdoc"
# -- Options for LaTeX output ---------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',
# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, "SHAP.tex", "SHAP Documentation", "Scott Lundberg", "manual"),
]
# The name of an image file (relative to this directory) to place at the top of
# the title page.
#
# latex_logo = None
# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
#
# latex_use_parts = False
# If true, show page references after internal links.
#
# latex_show_pagerefs = False
# If true, show URL addresses after external links.
#
# latex_show_urls = False
# Documents to append as an appendix to all manuals.
#
# latex_appendices = []
# It false, will not define \strong, \code, itleref, \crossref ... but only
# \sphinxstrong, ..., \sphinxtitleref, ... To help avoid clash with user added
# packages.
#
# latex_keep_old_macro_names = True
# If false, no module index is generated.
#
# latex_domain_indices = True
# -- Options for manual page output ---------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [(master_doc, "shap", "SHAP Documentation", [author], 1)]
# If true, show URL addresses after external links.
#
# man_show_urls = False
# -- Options for Texinfo output -------------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(
master_doc,
"SHAP",
"SHAP Documentation",
author,
"SHAP",
"One line description of project.",
"Miscellaneous",
),
]
# Documents to append as an appendix to all manuals.
#
# texinfo_appendices = []
# If false, no module index is generated.
#
# texinfo_domain_indices = True
# How to display URL addresses: 'footnote', 'no', or 'inline'.
#
# texinfo_show_urls = 'footnote'
# If true, do not generate a @detailmenu in the "Top" node's menu.
#
# texinfo_no_detailmenu = False
def setup(app):
import shap # noqa: F401
app.connect("build-finished", build_finished)
def build_finished(app, exception):
shutil.rmtree(NOTEBOOKS_DIR)
+2
View File
@@ -0,0 +1,2 @@
.. include:: ../CONTRIBUTING.md
:parser: myst_parser.sphinx_
+11
View File
@@ -0,0 +1,11 @@
Genomic examples
----------------
These examples explain machine learning models applied to genomic data. They are all generated from Jupyter
notebooks `available on GitHub <https://github.com/shap/shap/tree/master/notebooks/genomic_examples>`_.
.. toctree::
:glob:
:maxdepth: 1
example_notebooks/genomic_examples/*
+27
View File
@@ -0,0 +1,27 @@
Image examples
----------------
These examples explain machine learning models applied to image data. They are all generated from Jupyter
notebooks `available on GitHub <https://github.com/shap/shap/tree/master/notebooks/image_examples>`_.
Image classification
====================
Examples using :class:`shap.explainers.Partition` to explain image classifiers.
.. toctree::
:glob:
:maxdepth: 1
example_notebooks/image_examples/image_classification/*
Image captioning
================
Examples using :class:`shap.explainers.Permutation` to produce explanations in a model agnostic manner.
.. toctree::
:glob:
:maxdepth: 1
example_notebooks/image_examples/image_captioning/*
+57
View File
@@ -0,0 +1,57 @@
.. SHAP documentation master file, created by
sphinx-quickstart on Tue May 22 10:44:55 2018.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to the SHAP documentation
---------------------------------
.. image:: artwork/shap_header.png
:width: 600px
:align: center
**SHAP (SHapley Additive exPlanations)** is a game theoretic approach to explain the output of
any machine learning model. It connects optimal credit allocation with local explanations
using the classic Shapley values from game theory and their related extensions (see
`papers <https://github.com/shap/shap#citations>`_ for details and citations).
Install
=======
SHAP can be installed from either `PyPI <https://pypi.org/project/shap>`_ or
`conda-forge <https://anaconda.org/conda-forge/shap>`_::
pip install shap
or
conda install -c conda-forge shap
.. toctree::
:maxdepth: 2
:caption: Introduction
Topical overviews <overviews>
.. toctree::
:maxdepth: 2
:caption: Examples
Tabular examples <tabular_examples>
Text examples <text_examples>
Image examples <image_examples>
Genomic examples <genomic_examples>
.. toctree::
:maxdepth: 2
:caption: Reference
API reference <api>
API examples <api_examples>
Benchmarks <benchmarks>
.. toctree::
:maxdepth: 1
:caption: Development
Release notes <release_notes>
Contributing guide <contributing>
+281
View File
@@ -0,0 +1,281 @@
@ECHO OFF
REM Command file for Sphinx documentation
if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set BUILDDIR=_build
set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% .
set I18NSPHINXOPTS=%SPHINXOPTS% .
if NOT "%PAPER%" == "" (
set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS%
)
if "%1" == "" goto help
if "%1" == "help" (
:help
echo.Please use `make ^<target^>` where ^<target^> is one of
echo. html to make standalone HTML files
echo. dirhtml to make HTML files named index.html in directories
echo. singlehtml to make a single large HTML file
echo. pickle to make pickle files
echo. json to make JSON files
echo. htmlhelp to make HTML files and a HTML help project
echo. qthelp to make HTML files and a qthelp project
echo. devhelp to make HTML files and a Devhelp project
echo. epub to make an epub
echo. epub3 to make an epub3
echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter
echo. text to make text files
echo. man to make manual pages
echo. texinfo to make Texinfo files
echo. gettext to make PO message catalogs
echo. changes to make an overview over all changed/added/deprecated items
echo. xml to make Docutils-native XML files
echo. pseudoxml to make pseudoxml-XML files for display purposes
echo. linkcheck to check all external links for integrity
echo. doctest to run all doctests embedded in the documentation if enabled
echo. coverage to run coverage check of the documentation if enabled
echo. dummy to check syntax errors of document sources
goto end
)
if "%1" == "clean" (
for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i
del /q /s %BUILDDIR%\*
goto end
)
REM Check if sphinx-build is available and fallback to Python version if any
%SPHINXBUILD% 1>NUL 2>NUL
if errorlevel 9009 goto sphinx_python
goto sphinx_ok
:sphinx_python
set SPHINXBUILD=python -m sphinx.__init__
%SPHINXBUILD% 2> nul
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.http://sphinx-doc.org/
exit /b 1
)
:sphinx_ok
if "%1" == "html" (
%SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The HTML pages are in %BUILDDIR%/html.
goto end
)
if "%1" == "dirhtml" (
%SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml.
goto end
)
if "%1" == "singlehtml" (
%SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml.
goto end
)
if "%1" == "pickle" (
%SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle
if errorlevel 1 exit /b 1
echo.
echo.Build finished; now you can process the pickle files.
goto end
)
if "%1" == "json" (
%SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json
if errorlevel 1 exit /b 1
echo.
echo.Build finished; now you can process the JSON files.
goto end
)
if "%1" == "htmlhelp" (
%SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp
if errorlevel 1 exit /b 1
echo.
echo.Build finished; now you can run HTML Help Workshop with the ^
.hhp project file in %BUILDDIR%/htmlhelp.
goto end
)
if "%1" == "qthelp" (
%SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp
if errorlevel 1 exit /b 1
echo.
echo.Build finished; now you can run "qcollectiongenerator" with the ^
.qhcp project file in %BUILDDIR%/qthelp, like this:
echo.^> qcollectiongenerator %BUILDDIR%\qthelp\SHAP.qhcp
echo.To view the help file:
echo.^> assistant -collectionFile %BUILDDIR%\qthelp\SHAP.ghc
goto end
)
if "%1" == "devhelp" (
%SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp
if errorlevel 1 exit /b 1
echo.
echo.Build finished.
goto end
)
if "%1" == "epub" (
%SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The epub file is in %BUILDDIR%/epub.
goto end
)
if "%1" == "epub3" (
%SPHINXBUILD% -b epub3 %ALLSPHINXOPTS% %BUILDDIR%/epub3
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The epub3 file is in %BUILDDIR%/epub3.
goto end
)
if "%1" == "latex" (
%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
if errorlevel 1 exit /b 1
echo.
echo.Build finished; the LaTeX files are in %BUILDDIR%/latex.
goto end
)
if "%1" == "latexpdf" (
%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
cd %BUILDDIR%/latex
make all-pdf
cd %~dp0
echo.
echo.Build finished; the PDF files are in %BUILDDIR%/latex.
goto end
)
if "%1" == "latexpdfja" (
%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
cd %BUILDDIR%/latex
make all-pdf-ja
cd %~dp0
echo.
echo.Build finished; the PDF files are in %BUILDDIR%/latex.
goto end
)
if "%1" == "text" (
%SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The text files are in %BUILDDIR%/text.
goto end
)
if "%1" == "man" (
%SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The manual pages are in %BUILDDIR%/man.
goto end
)
if "%1" == "texinfo" (
%SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo.
goto end
)
if "%1" == "gettext" (
%SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The message catalogs are in %BUILDDIR%/locale.
goto end
)
if "%1" == "changes" (
%SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes
if errorlevel 1 exit /b 1
echo.
echo.The overview file is in %BUILDDIR%/changes.
goto end
)
if "%1" == "linkcheck" (
%SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck
if errorlevel 1 exit /b 1
echo.
echo.Link check complete; look for any errors in the above output ^
or in %BUILDDIR%/linkcheck/output.txt.
goto end
)
if "%1" == "doctest" (
%SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest
if errorlevel 1 exit /b 1
echo.
echo.Testing of doctests in the sources finished, look at the ^
results in %BUILDDIR%/doctest/output.txt.
goto end
)
if "%1" == "coverage" (
%SPHINXBUILD% -b coverage %ALLSPHINXOPTS% %BUILDDIR%/coverage
if errorlevel 1 exit /b 1
echo.
echo.Testing of coverage in the sources finished, look at the ^
results in %BUILDDIR%/coverage/python.txt.
goto end
)
if "%1" == "xml" (
%SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The XML files are in %BUILDDIR%/xml.
goto end
)
if "%1" == "pseudoxml" (
%SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml.
goto end
)
if "%1" == "dummy" (
%SPHINXBUILD% -b dummy %ALLSPHINXOPTS% %BUILDDIR%/dummy
if errorlevel 1 exit /b 1
echo.
echo.Build finished. Dummy builder generates no files.
goto end
)
:end
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Binary file not shown.
+26
View File
@@ -0,0 +1,26 @@
# Create 'crime.pickle'
import pickle
import lightgbm as lgb
from sklearn.model_selection import train_test_split
import shap
random_state = 1203344
# Load data and train model
X, y = shap.datasets.communitiesandcrime()
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33, random_state=random_state)
model = lgb.LGBMRegressor(random_state=random_state)
model.fit(X_train, y_train, eval_set=[(X_test, y_test)], verbose=False)
# Calculate and plot SHAP values
explainer = shap.TreeExplainer(model)
idx = 13
shap_values = explainer.shap_values(X_test.iloc[[idx]], y_test[idx])
# Dump to pickle
o = (explainer.expected_value, shap_values, X_test.iloc[0])
with open("./crime.pickle", "wb") as fl:
pickle.dump(o, fl)
Binary file not shown.
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+11
View File
@@ -0,0 +1,11 @@
Topical Overviews
-----------------
These overviews are generated from Jupyter notebooks that are
`available on GitHub <https://github.com/shap/shap/tree/master/notebooks/overviews>`_
.. toctree::
:glob:
:maxdepth: 1
example_notebooks/overviews/*
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+10
View File
@@ -0,0 +1,10 @@
@article{lundberg2018explainable,
title={Explainable machine-learning predictions for the prevention of hypoxaemia during surgery},
author={Lundberg, Scott M and Nair, Bala and Vavilala, Monica S and Horibe, Mayumi and Eisses, Michael J and Adams, Trevor and Liston, David E and Low, Daniel King-Wai and Newman, Shu-Fang and Kim, Jerry and others},
journal={Nature Biomedical Engineering},
volume={2},
number={10},
pages={749},
year={2018},
publisher={Nature Publishing Group}
}
+7
View File
@@ -0,0 +1,7 @@
@incollection{NIPS2017_7062,
title = {A Unified Approach to Interpreting Model Predictions},
author = {Lundberg, Scott M and Lee, Su-In},
year = {2017},
publisher = {Curran Associates, Inc.},
url = {http://papers.nips.cc/paper/7062-a-unified-approach-to-interpreting-model-predictions.pdf}
}
+10
View File
@@ -0,0 +1,10 @@
@article{lundberg2020local2global,
title={From local explanations to global understanding with explainable AI for trees},
author={Lundberg, Scott M. and Erion, Gabriel and Chen, Hugh and DeGrave, Alex and Prutkin, Jordan M. and Nair, Bala and Katz, Ronit and Himmelfarb, Jonathan and Bansal, Nisha and Lee, Su-In},
journal={Nature Machine Intelligence},
volume={2},
number={1},
pages={2522-5839},
year={2020},
publisher={Nature Publishing Group}
}
+6
View File
@@ -0,0 +1,6 @@
@article{lundberg2019explainable,
title={Explainable AI for Trees: From Local Explanations to Global Understanding},
author={Lundberg, Scott M and Erion, Gabriel and Chen, Hugh and DeGrave, Alex and Prutkin, Jordan M and Nair, Bala and Katz, Ronit and Himmelfarb, Jonathan and Bansal, Nisha and Lee, Su-In},
journal={arXiv preprint arXiv:1905.04610},
year={2019}
}
+9
View File
@@ -0,0 +1,9 @@
Release notes
-------------
To see the latest changes that are due on the next release, see |unreleasedchanges|_.
.. changelog::
:changelog-url: https://shap.readthedocs.io/en/latest/release_notes.html
:github: https://github.com/shap/shap/releases/
:pypi: https://pypi.org/project/shap/
+265
View File
@@ -0,0 +1,265 @@
# This file was autogenerated by uv via the following command:
# uv pip compile pyproject.toml --group docs --python-version 3.12 -o docs/requirements-docs.txt
alabaster==1.0.0
# via sphinx
asttokens==3.0.1
# via stack-data
attrs==26.1.0
# via
# jsonschema
# referencing
babel==2.18.0
# via sphinx
beautifulsoup4==4.14.3
# via nbconvert
bleach==6.4.0
# via nbconvert
certifi==2026.2.25
# via requests
charset-normalizer==3.4.6
# via requests
cloudpickle==3.1.2
# via shap (pyproject.toml)
comm==0.2.3
# via ipywidgets
contourpy==1.3.3
# via matplotlib
cycler==0.12.1
# via matplotlib
decorator==5.2.1
# via ipython
defusedxml==0.7.1
# via nbconvert
docutils==0.22.4
# via
# myst-parser
# nbsphinx
# sphinx
# sphinx-github-changelog
# sphinx-rtd-theme
executing==2.2.1
# via stack-data
fastjsonschema==2.21.2
# via nbformat
fonttools==4.62.1
# via matplotlib
idna==3.15
# via requests
imagesize==2.0.0
# via sphinx
ipython==9.12.0
# via
# shap (pyproject.toml:docs)
# ipywidgets
ipython-pygments-lexers==1.1.1
# via ipython
ipywidgets==8.1.8
# via shap (pyproject.toml:docs)
jedi==0.19.2
# via ipython
jinja2==3.1.6
# via
# myst-parser
# nbconvert
# nbsphinx
# sphinx
joblib==1.5.3
# via scikit-learn
jsonschema==4.26.0
# via nbformat
jsonschema-specifications==2025.9.1
# via jsonschema
jupyter-client==8.8.0
# via nbclient
jupyter-core==5.9.1
# via
# jupyter-client
# nbclient
# nbconvert
# nbformat
jupyterlab-pygments==0.3.0
# via nbconvert
jupyterlab-widgets==3.0.16
# via ipywidgets
kiwisolver==1.5.0
# via matplotlib
llvmlite==0.47.0
# via
# shap (pyproject.toml)
# numba
markdown-it-py==4.0.0
# via
# mdit-py-plugins
# myst-parser
markupsafe==3.0.3
# via
# jinja2
# nbconvert
matplotlib==3.10.8
# via shap (pyproject.toml:docs)
matplotlib-inline==0.2.1
# via ipython
mdit-py-plugins==0.5.0
# via myst-parser
mdurl==0.1.2
# via markdown-it-py
mistune==3.2.1
# via nbconvert
myst-parser==5.0.0
# via shap (pyproject.toml:docs)
nbclient==0.10.4
# via nbconvert
nbconvert==7.17.1
# via nbsphinx
nbformat==5.10.4
# via
# nbclient
# nbconvert
# nbsphinx
nbsphinx==0.9.8
# via shap (pyproject.toml:docs)
numba==0.65.0
# via shap (pyproject.toml)
numpy==2.4.4
# via
# shap (pyproject.toml)
# contourpy
# matplotlib
# numba
# pandas
# scikit-learn
# scipy
numpydoc==1.10.0
# via shap (pyproject.toml:docs)
packaging==26.0
# via
# shap (pyproject.toml)
# matplotlib
# nbconvert
# sphinx
pandas==3.0.2
# via shap (pyproject.toml)
pandocfilters==1.5.1
# via nbconvert
parso==0.8.6
# via jedi
pexpect==4.9.0
# via ipython
pillow==12.2.0
# via matplotlib
platformdirs==4.9.4
# via jupyter-core
prompt-toolkit==3.0.52
# via ipython
ptyprocess==0.7.0
# via pexpect
pure-eval==0.2.3
# via stack-data
pygments==2.20.0
# via
# ipython
# ipython-pygments-lexers
# nbconvert
# sphinx
pyparsing==3.3.2
# via matplotlib
python-dateutil==2.9.0.post0
# via
# jupyter-client
# matplotlib
# pandas
pyyaml==6.0.3
# via myst-parser
pyzmq==27.1.0
# via jupyter-client
referencing==0.37.0
# via
# jsonschema
# jsonschema-specifications
requests==2.33.1
# via
# shap (pyproject.toml:docs)
# sphinx
# sphinx-github-changelog
roman-numerals==4.1.0
# via sphinx
rpds-py==0.30.0
# via
# jsonschema
# referencing
scikit-learn==1.8.0
# via shap (pyproject.toml)
scipy==1.17.1
# via
# shap (pyproject.toml)
# scikit-learn
six==1.17.0
# via python-dateutil
slicer==0.0.8
# via shap (pyproject.toml)
snowballstemmer==3.0.1
# via sphinx
soupsieve==2.8.3
# via beautifulsoup4
sphinx==9.1.0
# via
# shap (pyproject.toml:docs)
# myst-parser
# nbsphinx
# numpydoc
# sphinx-github-changelog
# sphinx-rtd-theme
# sphinxcontrib-jquery
sphinx-github-changelog==1.7.2
# via shap (pyproject.toml:docs)
sphinx-rtd-theme==3.1.0
# via shap (pyproject.toml:docs)
sphinxcontrib-applehelp==2.0.0
# via sphinx
sphinxcontrib-devhelp==2.0.0
# via sphinx
sphinxcontrib-htmlhelp==2.1.0
# via sphinx
sphinxcontrib-jquery==4.1
# via sphinx-rtd-theme
sphinxcontrib-jsmath==1.0.1
# via sphinx
sphinxcontrib-qthelp==2.0.0
# via sphinx
sphinxcontrib-serializinghtml==2.0.0
# via sphinx
stack-data==0.6.3
# via ipython
threadpoolctl==3.6.0
# via scikit-learn
tinycss2==1.4.0
# via bleach
tornado==6.5.7
# via jupyter-client
tqdm==4.67.3
# via shap (pyproject.toml)
traitlets==5.14.3
# via
# ipython
# ipywidgets
# jupyter-client
# jupyter-core
# matplotlib-inline
# nbclient
# nbconvert
# nbformat
# nbsphinx
typing-extensions==4.15.0
# via
# beautifulsoup4
# referencing
urllib3==2.7.0
# via requests
wcwidth==0.6.0
# via prompt-toolkit
webencodings==0.5.1
# via
# bleach
# tinycss2
widgetsnbextension==4.0.15
# via ipywidgets
+49
View File
@@ -0,0 +1,49 @@
Tabular examples
----------------
These examples explain machine learning models applied to tabular data. They are all generated from Jupyter
notebooks `available on GitHub <https://github.com/shap/shap/tree/master/notebooks/tabular_examples>`_.
Tree-based models
=================
Examples demonstrating how to explain tree-based machine learning models.
.. toctree::
:glob:
:maxdepth: 1
example_notebooks/tabular_examples/tree_based_models/*
Linear models
=============
Examples demonstrating how to explain linear machine learning models.
.. toctree::
:glob:
:maxdepth: 1
example_notebooks/tabular_examples/linear_models/*
Neural networks
===============
Examples demonstrating how to explain machine learning models based on neural networks.
.. toctree::
:glob:
:maxdepth: 1
example_notebooks/tabular_examples/neural_networks/*
Model agnostic
==============
Examples demonstrating how to explain arbitrary machine learning pipelines.
.. toctree::
:glob:
:maxdepth: 1
example_notebooks/tabular_examples/model_agnostic/*
+81
View File
@@ -0,0 +1,81 @@
Text examples
-------------
These examples explain machine learning models applied to text data. They are all generated from Jupyter
notebooks `available on GitHub <https://github.com/shap/shap/tree/master/notebooks/text_examples>`_.
Sentiment analysis
==================
Examples of how to explain predictions from sentiment analysis models.
.. toctree::
:glob:
:maxdepth: 1
example_notebooks/text_examples/sentiment_analysis/*
Translation
===========
Examples of how to explain predictions from translation models.
.. toctree::
:glob:
:maxdepth: 1
example_notebooks/text_examples/translation/*
Text generation
===============
Examples of how to explain predictions from text generation models.
.. toctree::
:glob:
:maxdepth: 1
example_notebooks/text_examples/text_generation/*
Summarization
=============
Examples of how to explain predictions from summarization models.
.. toctree::
:glob:
:maxdepth: 1
example_notebooks/text_examples/summarization/*
Question Answering
==================
Examples of how to explain predictions from question answering models.
.. toctree::
:glob:
:maxdepth: 1
example_notebooks/text_examples/question_answering/*
Language modelling
==================
Examples of how to explain predictions from language models.
.. toctree::
:glob:
:maxdepth: 1
example_notebooks/text_examples/language_modelling/*
Text entailment
===============
Examples of how to explain predictions from text entailment models.
.. toctree::
:glob:
:maxdepth: 1
example_notebooks/text_examples/text_entailment/*
Binary file not shown.
File diff suppressed because one or more lines are too long
@@ -0,0 +1,145 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Approve Hits"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import boto3"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"aws_access_key_id = \"AKIAJ7ODKKKLEQNUJYZA\"\n",
"aws_secret_access_key = \"XXXXX\"\n",
"aws_region = \"us-east-1\"\n",
"client = boto3.client('mturk', region_name= \"us-east-1\", aws_access_key_id=aws_access_key_id, aws_secret_access_key=aws_secret_access_key)"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'ResponseMetadata': {'RequestId': '5c6b81ce-fc0c-4125-a1c2-bfc4d157bfa9',\n",
" 'HTTPStatusCode': 200,\n",
" 'HTTPHeaders': {'x-amzn-requestid': '5c6b81ce-fc0c-4125-a1c2-bfc4d157bfa9',\n",
" 'content-type': 'application/x-amz-json-1.1',\n",
" 'content-length': '2',\n",
" 'date': 'Sun, 03 Mar 2019 01:04:12 GMT'},\n",
" 'RetryAttempts': 0}}"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"client.approve_assignment(AssignmentId=\"3QFUFYSY9ZFOQSZK8PZXFP84UVOF4N\")"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'NextToken': 'p1:thjV0Iu9KED6Jtn5ylDyJ+bUn3ooStDrFP8Z1CmhpFWeCbNFBveoYz1nm2qSsQ==',\n",
" 'NumResults': 1,\n",
" 'Assignments': [{'AssignmentId': '3QFUFYSY9ZFOQSZK8PZXFP84UVOF4N',\n",
" 'WorkerId': 'A19H44LQJ0TEXF',\n",
" 'HITId': '3R0WOCG21N9NNMH96NQNG98SB7WUDM',\n",
" 'AssignmentStatus': 'Approved',\n",
" 'AutoApprovalTime': datetime.datetime(2019, 4, 1, 15, 56, 22, tzinfo=tzlocal()),\n",
" 'AcceptTime': datetime.datetime(2019, 3, 2, 14, 51, 24, tzinfo=tzlocal()),\n",
" 'SubmitTime': datetime.datetime(2019, 3, 2, 14, 56, 22, tzinfo=tzlocal()),\n",
" 'ApprovalTime': datetime.datetime(2019, 3, 2, 17, 4, 12, tzinfo=tzlocal()),\n",
" 'Answer': '<?xml version=\"1.0\" encoding=\"ASCII\"?><QuestionFormAnswers xmlns=\"http://mechanicalturk.amazonaws.com/AWSMechanicalTurkDataSchemas/2005-10-01/QuestionFormAnswers.xsd\"><Answer><QuestionIdentifier>workerId</QuestionIdentifier><FreeText>A19H44LQJ0TEXF</FreeText></Answer></QuestionFormAnswers>'}],\n",
" 'ResponseMetadata': {'RequestId': 'c20c08c1-c74f-4fdb-a170-78a45f8b7369',\n",
" 'HTTPStatusCode': 200,\n",
" 'HTTPHeaders': {'x-amzn-requestid': 'c20c08c1-c74f-4fdb-a170-78a45f8b7369',\n",
" 'content-type': 'application/x-amz-json-1.1',\n",
" 'content-length': '687',\n",
" 'date': 'Sun, 03 Mar 2019 01:04:29 GMT'},\n",
" 'RetryAttempts': 0}}"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"client.list_assignments_for_hit(HITId='3R0WOCG21N9NNMH96NQNG98SB7WUDM', AssignmentStatuses=['Submitted'])"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"def approve_all_submitted_assignments(client):\n",
" for id in [h['HITId'] for h in client.list_hits()['HITs']]:\n",
" lst = client.list_assignments_for_hit(HITId=id, AssignmentStatuses=['Submitted'])\n",
" for aid in [a[\"AssignmentId\"] for a in lst[\"Assignments\"]]:\n",
" client.approve_assignment(AssignmentId=aid)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"approve_all_submitted_assignments(client)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.4"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
@@ -0,0 +1,83 @@
import React from 'react';
import {Link} from 'react-router';
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
import RaisedButton from 'material-ui/RaisedButton';
import TextField from 'material-ui/TextField';
export default class Debrief extends React.Component {
constructor() {
super();
this.handleChange = this.handleChange.bind(this);
this.start_time = new Date();
window.psiTurk.recordTrialData({
'mark': "debrief_start",
'time': this.start_time.valueOf()
});
}
finish(answer) {
window.psiTurk.recordTrialData({
'mark': "debrief_end",
'answer': answer,
'text': this.text,
'time': new Date().valueOf(),
'response_time': new Date() - this.start_time
});
psiTurk.saveData({
success: function(){
psiTurk.completeHIT();
},
error: this.prompt_resubmit
});
}
handleChange(event) {
this.text = event.target.value;
}
render() {
return (
<MuiThemeProvider>
<div id="container-instructions">
<h1>Debriefing</h1>
<hr/>
<p>Thank you for your participation in our study! Your anonymous data makes an
important contribution to our understanding of human machine interaction. </p>
<p>If you have any questions about this research, you may contact slund1@cs.washington.edu.</p>
<div style={{textAlign: "center"}}>
<TextField style={{width: "400px"}}
hintText="Comments"
multiLine={true}
rows={2}
rowsMax={8}
onChange={this.handleChange}
/>
</div>
<br/>
<div className="instructions well">
<p>I feel that I have been adequately debriefed about the nature
of the study. The investigator has explained the purposes of the
research to me, and I feel that any questions I have asked were
satisfactorily answered.</p>
<script type="text/javascript">
//console.log(psiTurk.getInstructionIndicator())
</script>
</div>
<div style={{textAlign: "center"}}>
<RaisedButton onClick={()=>this.finish("agree")} label="Yes, I agree. Complete this HIT" primary={true} /><br/><br/>
<RaisedButton onClick={()=>this.finish("questions")} label="No, please withhold my data. I will contact the experimenter with questions." />
</div>
</div>
</MuiThemeProvider>
);
}
}
@@ -0,0 +1,53 @@
import React from 'react';
import {hashHistory} from 'react-router';
import RaisedButton from 'material-ui/RaisedButton';
export default class Instructions extends React.Component {
constructor() {
super();
this.next_page = this.next_page.bind(this);
this.start_time = new Date().getTime();
window.psiTurk.recordTrialData({
'mark': "instructions_start",
'condition': condition,
'time': this.start_time.valueOf()
});
}
next_page() {
window.psiTurk.recordTrialData({
'mark': "instructions_stop",
'time': new Date().valueOf(),
'condition': condition,
'response_time': new Date() - this.start_time
});
hashHistory.push("/questions");
// if (condition === 0) hashHistory.push("/allocate1");
// else if (condition === 1) hashHistory.push("/allocate2");
}
render() {
return (
<div id="container-instructions">
<h1>Instructions</h1>
<hr/>
<div className="instructions well">
You will be asked to allocate blame for a person's "sickness score",
where 0 is healthy and higher numbers mean more sickness. There are
<i> 4 different ways</i> to measure sickness (A, B, C and D). There
are also <i>3 different people</i> for each score. This leads to 12
total questions. Each question should not take very long to
complete, the goal is simply for you to assign blame among a person's
symptoms in a way you consider the most intuitive.
</div>
<div style={{textAlign: "center"}}>
<RaisedButton label="Next >" primary={true} onClick={this.next_page} />
</div>
</div>
);
}
}
@@ -0,0 +1,26 @@
import React from 'react'
import {Router, Route, hashHistory} from 'react-router'
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider'
import Instructions from './Instructions'
import Questions from './Questions'
import Debrief from './Debrief'
export default class Main extends React.Component {
constructor() {
super();
}
render() {
return (
<MuiThemeProvider>
<div>
<Router history={hashHistory}>
<Route path="/" component={Instructions} />
<Route path="/questions" component={Questions} />
<Route path="/debrief" component={Debrief} />
</Router>
</div>
</MuiThemeProvider>
);
}
}
@@ -0,0 +1,337 @@
import React from 'react';
import {Link, hashHistory} from 'react-router';
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
import RaisedButton from 'material-ui/RaisedButton';
import TextField from 'material-ui/TextField';
export default class QuestionA1 extends React.Component {
constructor() {
super();
this.state = {
fever: 0,
cough: 0,
headache: 0,
person: 0,
score: 0
};
this.last_time = new Date().getTime();
this.handleChange = this.handleChange.bind(this);
this.symptoms = [
{
'fever': true,
'cough': true,
'headache': true
},
{
'fever': false,
'cough': true,
'headache': true
},
{
'fever': false,
'cough': false,
'headache': true
}
]
this.score_names = ["A", "B", "C", "D"];
this.score_methods = [
{ // XOR
"true true": 4,
"false true": 8,
"false false": 0
},
{ // AND
"true true": 10,
"false true": 2,
"false false": 0
},
{ // OR
"true true": 10,
"false true": 8,
"false false": 0
},
{ // SUM
"true true": 4,
"false true": 2,
"false false": 0
}
];
window.psiTurk.recordTrialData({
'mark': "question"+this.score_names[this.state.score]+this.person+"_start",
'time': this.last_time.valueOf()
});
}
handleChange(event) {
if (event.target.value !== undefined) {
var data = {};
data[event.target.name] = event.target.value;
this.setState(data);
}
}
saveAnswers() {
if (this.state.person != 2 && parseInt(this.state.fever) + parseInt(this.state.cough) + parseInt(this.state.headache) === 0) {
alert("Please consider carefully how to assign blame among the symptoms before submitting.");
} else {
window.psiTurk.recordTrialData({
'mark': "question"+this.score_names[this.state.score]+this.state.person+"_stop",
'fever': this.symptoms[this.state.person]['fever'],
'cough': this.symptoms[this.state.person]['cough'],
'headache': this.symptoms[this.state.person]['headache'],
'fever_credit': parseInt(this.state.fever),
'cough_credit': parseInt(this.state.cough),
'headache_credit': parseInt(this.state.headache),
'time': new Date().valueOf(),
'condition': condition,
'response_time': new Date().getTime() - this.last_time
});
this.state.fever = 0;
this.state.cough = 0;
this.state.headache = 0;
if (this.state.person < 2) {
this.state.person++;
} else if (this.state.score < 3) {
this.state.person = 0;
this.state.score++;
} else {
hashHistory.push("/debrief");
}
this.setState(this.state);
this.last_time = new Date().getTime();
}
}
render() {
var fever = this.symptoms[this.state.person]['fever'];
var cough = this.symptoms[this.state.person]['cough'];
var interaction_effect_rule;
var interaction_effect_result;
if (this.state.score == 0) {
interaction_effect_rule = (
<tr>
<td style={{textAlign: "right", padding: "3px"}}>
If they have a fever <i>OR</i> a cough but not both:
</td>
<td>
+6 points
</td>
</tr>
);
if ((fever || cough) && !(fever && cough)) {
interaction_effect_result = (
<tr>
<td style={{textAlign: "right", padding: "3px"}}>
They have a fever <i>OR</i> a cough but not both:
</td>
<td>
<b>+6 points</b>
</td>
</tr>
);
}
} else if (this.state.score == 1) {
interaction_effect_rule = (
<tr>
<td style={{textAlign: "right", padding: "3px"}}>
If they have a fever <i>AND</i> a cough:
</td>
<td>
+6 points
</td>
</tr>
);
if (fever && cough) {
interaction_effect_result = (
<tr>
<td style={{textAlign: "right", padding: "3px"}}>
They have a fever <i>AND</i> a cough:
</td>
<td>
<b>+6 points</b>
</td>
</tr>
);
}
} else if (this.state.score == 2) {
interaction_effect_rule = (
<tr>
<td style={{textAlign: "right", padding: "3px"}}>
If they have a fever <i>OR</i> a cough:
</td>
<td>
+6 points
</td>
</tr>
);
if (fever || cough) {
interaction_effect_result = (
<tr>
<td style={{textAlign: "right", padding: "3px"}}>
They have a fever <i>OR</i> a cough:
</td>
<td>
<b>+6 points</b>
</td>
</tr>
);
}
}
var fever_effect_result;
if (fever) {
fever_effect_result = (
<tr>
<td style={{textAlign: "right", padding: "3px"}}>
They have a fever:
</td>
<td>
<b>+2 points</b>
</td>
</tr>
);
}
var cough_effect_result;
if (cough) {
cough_effect_result = (
<tr>
<td style={{textAlign: "right", padding: "3px"}}>
They have a cough:
</td>
<td>
<b>+2 points</b>
</td>
</tr>
);
}
if (!fever && !cough) {
fever_effect_result = (
<tr>
<td style={{textAlign: "right", padding: "3px"}}>
They have neither a fever nor a cough.
</td>
<td>
</td>
</tr>
);
}
var total_score = this.score_methods[this.state.score][fever + " " + cough];
return (
<MuiThemeProvider>
<div id="container-instructions">
<h2>Assign blame among symptoms (score {this.score_names[this.state.score]}, person {this.state.person+1})</h2>
<hr/>
<div className="instructions well">
<p>"<b>Sickness score {this.score_names[this.state.score]}</b>" is computed in the following manner:</p>
<div style={{textAlign: "center"}}>
<table style={{display: "inline-block", textAlign: "left"}}><tbody>
<tr>
<td style={{textAlign: "right", padding: "3px"}}>
If they have a fever:
</td>
<td>
+2 points
</td>
</tr>
<tr>
<td style={{textAlign: "right", padding: "3px"}}>
If they have a cough:
</td>
<td>
+2 points
</td>
</tr>
{interaction_effect_rule}
</tbody></table>
</div>
<br/>
<b>Person {this.state.person+1}</b> has the following symptoms:<br/>
<div style={{textAlign: "center", marginTop: "-20px"}}>
<table style={{display: "inline-block", textAlign: "left"}}><tbody>
<tr>
<td style={{textAlign: "right", padding: "3px"}}>
Fever:
</td>
<td style={{fontWeight: "bold", color: "#990000"}}>
{this.symptoms[this.state.person]['fever'] ? 'YES' : 'NO'}
</td>
</tr>
<tr>
<td style={{textAlign: "right", padding: "3px"}}>
Cough:
</td>
<td style={{fontWeight: "bold", color: "#990000"}}>
{this.symptoms[this.state.person]['cough'] ? 'YES' : 'NO'}
</td>
</tr>
<tr>
<td style={{textAlign: "right", padding: "3px"}}>
Headache:
</td>
<td style={{fontWeight: "bold", color: "#990000"}}>
{this.symptoms[this.state.person]['headache'] ? 'YES' : 'NO'}
</td>
</tr>
</tbody></table>
</div>
This leads to a total sickness score {this.score_names[this.state.score]} value of <b>{total_score} points</b> because:<br/>
<div style={{textAlign: "center"}}>
<table style={{display: "inline-block", textAlign: "left"}}><tbody>
{fever_effect_result}
{cough_effect_result}
{interaction_effect_result}
</tbody></table>
</div>
<br/>
Using numbers please assign blame for their sickness score of <b>{total_score} points</b> among the following symptoms{this.state.person == 2 ? ' (zero blame is okay)' : ''}:<br/>
<br/>
<div style={{textAlign: "center"}}>
<table style={{display: "inline-block", textAlign: "left"}}><tbody>
<tr>
<td style={{textAlign: "center", width: "150px"}}>
<TextField name="fever" value={this.state.fever} onChange={this.handleChange} style={{width: "20px", marginLeft: 3, marginRight: 3}} /> point(s)<br/>
Fever: <b style={{color: "#990000"}}>{this.symptoms[this.state.person]['fever'] ? 'YES' : 'NO'}</b>
</td>
<td style={{textAlign: "center", width: "150px"}}>
<TextField name="cough" value={this.state.cough} onChange={this.handleChange} style={{width: "20px", marginLeft: 3, marginRight: 3}} /> point(s)<br/>
Cough: <b style={{color: "#990000"}}>{this.symptoms[this.state.person]['cough'] ? 'YES' : 'NO'}</b>
</td>
<td style={{textAlign: "center", width: "150px"}}>
<TextField name="headache" value={this.state.headache} onChange={this.handleChange} style={{width: "20px", marginLeft: 3}} /> point(s)<br/>
Headache: <b style={{color: "#990000"}}>{this.symptoms[this.state.person]['headache'] ? 'YES' : 'NO'}</b>
</td>
</tr>
</tbody></table>
</div>
</div>
<div style={{textAlign: "center"}}>
<RaisedButton label={"Submit answer for score " + this.score_names[this.state.score] + ", person " + (this.state.person+1)} primary={true} onClick={()=>this.saveAnswers()} />
</div>
</div>
</MuiThemeProvider>
);
}
}
@@ -0,0 +1,41 @@
# Exclusive OR function experiment based on sickness score
```shell
npm install
npm build
```
Using a python 2 environment
```
pip install psiturk
```
Create a `~/.psiturkconfig` with your credentials:
```
[AWS Access]
aws_access_key_id = XXXXXXXXXXXXXX
aws_secret_access_key = XXXXXXXXXXXXXX
aws_region = us-east-1
[psiTurk Access]
psiturk_access_key_id = XXXXXXXXXXXXXX
psiturk_secret_access_id = XXXXXXXXXXXXXX
```
In `config.txt` replace the host name with the public name of the machine.
In the current directory run PsiTurk
```
psiturk
> server on
> debug
```
Now you can test things and download results with
```
> download_datafiles
```
@@ -0,0 +1,45 @@
[HIT Configuration]
title = Intuitive credit allocation experiment
description = Allocate blame for sickness among three symptoms in a simple scenario.
amt_keywords = explainable, interpretable, machine learning
lifetime = 24
us_only = true
approve_requirement = 95
contact_email_on_error = slund1@cs.washington.edu
ad_group = Explainable testing
psiturk_keywords = shap
organization_name = University of Washington
browser_exclude_rule = MSIE, mobile, tablet
[Database Parameters]
database_url = sqlite:///participants.db
table_name = turkdemo
[Server Parameters]
host = 0.0.0.0
port = 22363
cutoff_time = 30
logfile = server.log
loglevel = 2
debug = true
login_username = examplename
login_pw = examplepassword221s0982927998292900
threads = auto
secret_key = 'ksd9f98239s9df8skjkj2j32k09a0-k2lk32kl'
#certfile = <path_to.crt>
#keyfile = <path_to.key>
[Task Parameters]
experiment_code_version = 1.0
num_conds = 1
num_counters = 1
[Shell Parameters]
launch_in_sandbox_mode = true
# If you are not using the psiturk ad server, set `use_psiturk_ad_server` to `false` and point `ad_location` to your proxy server <host> and <port>. Format the ad_location like this:
#
# https://<host>:<port>/ad
use_psiturk_ad_server = true
ad_location = false
@@ -0,0 +1,8 @@
debugB9EJOF:debug2CU4FC,initialized,0,,1551550976525
debugB9EJOF:debug2CU4FC,window_resize,0,"[1024, 746]",1551550976525
debugCVL5VN:debug8MU7CL,initialized,0,,1551555460816
debugCVL5VN:debug8MU7CL,window_resize,0,"[1024, 746]",1551555460816
debugCVL5VN:debug8MU7CL,focus,40949,off,1551555501765
debugCVL5VN:debug8MU7CL,focus,4268,on,1551555506033
debugCVL5VN:debug8MU7CL,focus,15022,off,1551555521055
debugCVL5VN:debug8MU7CL,focus,148,on,1551555521203
1 debugB9EJOF:debug2CU4FC initialized 0 1551550976525
2 debugB9EJOF:debug2CU4FC window_resize 0 [1024, 746] 1551550976525
3 debugCVL5VN:debug8MU7CL initialized 0 1551555460816
4 debugCVL5VN:debug8MU7CL window_resize 0 [1024, 746] 1551555460816
5 debugCVL5VN:debug8MU7CL focus 40949 off 1551555501765
6 debugCVL5VN:debug8MU7CL focus 4268 on 1551555506033
7 debugCVL5VN:debug8MU7CL focus 15022 off 1551555521055
8 debugCVL5VN:debug8MU7CL focus 148 on 1551555521203
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,15 @@
import React from 'react';
import ReactDom from 'react-dom';
import injectTapEventPlugin from 'react-tap-event-plugin';
import Main from './Main';
// Needed for onTouchTap for material-ui
// http://stackoverflow.com/a/34015469/988941
injectTapEventPlugin();
// Save some globals for the inline scripts to access
window.IML = {
Main: Main,
React: React,
ReactDom: ReactDom
};
@@ -0,0 +1,30 @@
{
"name": "iml-sickness-score-experiment",
"version": "0.1.0",
"description": "Measure how people explain a sickness score.",
"main": "index.jsx",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "node_modules/.bin/webpack --content-base build/",
"build": "node_modules/.bin/webpack"
},
"author": "Scott Lundberg",
"repository": "https://github.com/interpretable-ml/benchmark/experiments/sickness-score",
"license": "MIT",
"dependencies": {
"d3": "^4",
"lodash": "^4",
"material-ui": "^0.16",
"react": "^15",
"react-dom": "^15",
"react-router": "^3",
"react-tap-event-plugin": "^2"
},
"devDependencies": {
"babel-core": "^6",
"babel-loader": "^6",
"babel-preset-es2015": "^6",
"babel-preset-react": "^6",
"webpack": "^2"
}
}
Binary file not shown.
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
@@ -0,0 +1,77 @@
body {
padding:0px;
margin: 0px;
background-color: white;
color: black;
font-weight: 300;
font-size: 13pt;
}
/* text styling */
strong {
font-weight: 600;
}
.warm {
color: steelblue;
text-align: justify;
}
.cool {
color: #ccccff;
}
h1 {
margin-top: 0px;
}
/* these are all the same for now, but easy to modify individually */
#container-not-an-ad, #container-error, #container-exp, #container-consent, #container-instructions, #container-questionnaire {
background: white;
margin: 30px;
}
/* ad.html - the ad that people view first */
#adlogo {
width: 140px;
padding: 2px;
border: 1px solid #ccc;
margin-right: 1em;
}
/* consent.html - the consent form */
#consent {
margin: 0 auto;
margin-top: 0;
width: 800px;
font-size: 100%;
}
.legal {
text-align: justify;
font-size: 11pt;
line-height: 1.1em;
}
#trial {
margin: 0 auto;
width: 800px;
text-align: center;
}
#query {
color: darkgray;
}
.question {
margin-bottom: 30px;
}
/* errors */
#error img {
padding-right: 10px;
padding-top: 15px;
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Some files were not shown because too many files have changed in this diff Show More