SHAP

SHAP is a skill for Claude Code, Codex from zjunlp/Mechanist. It costs 126 tokens per session (870 once invoked), scanned A, original, MIT.

A method for explaining why a machine-learning model made a prediction by assigning importance values to its input features. SHAP stands for SHapley Additive exPlanations and uses a game-theory idea to measure each feature's contribution.

In plain words
What is it for?
Use it to explain predictions and measure feature importance for tree models, neural networks, language models, and other custom models.
Why use it?
It helps you inspect individual predictions and summarize which inputs generally influence a model, while making the explanation method consistent across model types.

Skill for Claude CodeCodex

Part of the mechanist plugin — 54 skills, 4 agents shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/zjunlp/mechanist/shap
Any agent
npx skills add zjunlp/Mechanist --skill shap
Clone the repo
git clone --depth 1 https://github.com/zjunlp/Mechanist

Made for: Claude Code, Codex.

Or install mechanist, the plugin that ships this one along with the rest of its 54 skills, 4 agents.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for SHAP

README.md
[![agentmods](https://agentmods.dev/badge/skills/zjunlp/mechanist/shap.svg)](https://agentmods.dev/skills/zjunlp/mechanist/shap)
Your own site
<a href="https://agentmods.dev/skills/zjunlp/mechanist/shap"><img src="https://agentmods.dev/badge/skills/zjunlp/mechanist/shap.svg" alt="Measured on agentmods" height="20"></a>
Per session 126 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 870 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00126 $0.00870
Opus 5 $0.00063 $0.00435
Sonnet 5 $0.00025 $0.00174
Haiku 4.5 $0.00013 $0.00087

Measured 5d ago against content hash fff83c9c6a41, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, from the pricing page.

Security

Grade A, and why

SHAP scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.

The scan reads SKILL.md. This mod also ships 5 executable files (amortized-shap/scripts/01_tabular_fastshap_demo.py, amortized-shap/scripts/02_normalization_and_utils_demo.py, foundational-and-estimator-based-shap/scripts/kernel_explainer_demo.py, …), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/mechanism-skills/SHAP/SKILL.md · 25 lines

How it starts

The opening of the file, as written. The whole thing — 25 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Advantage

SHAP unifies several previously ad-hoc attribution methods (LIME, DeepLIFT, Layer-wise Relevance Propagation, classic Shapley value methods such as Shapley regression and Shapley sampling) under one axiomatic framework, so attributions from different model families can be compared on the same scale. The decomposition is local — it explains a single prediction — yet averaging the absolute Shapley values over a dataset yields a global feature-importance ranking that inherits the same axiomatic foundation, supporting both per-instance debugging and dataset-level summaries. For tree ensembles, an exact polynomial-time estimator removes the usual exponential cost, making SHAP the de-facto standard for explaining XGBoost / LightGBM / CatBoost / scikit-learn tree models.

Limitation

Computing exact Shapley values for an arbitrary model is exponential in the number of features, so practical use relies on estimators (KernelSHAP, sampling, deep- or gradient-based variants) whose accuracy depends on the number of samples / coalitions and on assumptions about how "missing" features should be modelled (typically marginal- vs conditional-expectation). The values themselves are correlational — they describe how the model uses features, not whether those features are causally related to the outcome — and additive decomposition can obscure strong feature interactions, which require interaction-aware Shapley extensions to surface.

Submethods

The toolkit comprises two forms — per-sample estimators that compute Shapley values one input at a time, and amortized explainers that learn to predict them in a single forward pass:

  • Foundational and Estimator-based SHAP: The reference SHAP library covers the full taxonomy of Shapley estimators — model-agnostic (KernelSHAP), exact tree-specific (TreeSHAP), deep-learning (DeepExplainer / GradientExplainer for TensorFlow, Keras, PyTorch), and linear models — together with the standard plotting suite (waterfall, beeswarm, force, dependence) and interaction extensions. It is the right starting point for explaining any single model and serves as the reference implementation against which downstream methods are compared. You can find a demo for this method in ./foundational-and-estimator-based-shap. This demo shows shap: Use this skill when working with SHAP (SHapley Additive exPlanations) to explain machine learning model predictions, compute feature importance, generate SHAP values for tree ensembles (XGBoost, LightGBM, CatBoost, scikit-learn), deep learning models (TensorFlow, Keras, PyTorch), NLP transformers, or any model-agnostic function.

Read the full file on GitHub · 25 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 5d ago First seen · 25 lines · 126 tokens per session scan A fff83c9c6a41

Subscribe to this mod's changes

SHAP is a skill published in the GitHub repository zjunlp/Mechanist (55 stars, last pushed 10d ago), licensed MIT. It adds 126 tokens to every session and 870 once invoked, about $0.0006 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.