shap

shap is a skill for Claude Code from K-Dense-AI/scientific-agent-skills. It costs 46 tokens per session (3,108 once invoked), scanned A, original, MIT.

A toolkit for explaining predictions from trained machine-learning models by assigning each input feature a contribution to an output. SHAP explanations can describe one prediction or patterns across many predictions.

In plain words
What is it for?
Use it to calculate and validate feature attributions, choose explanation methods, handle models with multiple outputs, and create local or global explanation plots.
Why use it?
It helps you inspect why a model produced an output without treating the explanation as proof of causation, fairness, or clinical usefulness. It also encourages checking that explanations match the model's actual output.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter.

Good fit Use it to calculate and validate feature attributions, choose explanation methods, handle models with multiple outputs, and create local or global explanation plots.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/k-dense-ai/scientific-agent-skills/shap
About the project

Scientific Agent Skills is a collection of reusable procedures that give AI agents capabilities for scientific research across areas such as biology, chemistry, medicine, and drug discovery. It is used by researchers and by people building AI scientist workflows with compatible coding agents. The catalogue contains many of the project's skills and supporting instructions.

K-Dense-AI/scientific-agent-skills · 44,220 stars · on GitHub · arxiv.org

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.

Any agent
npx skills add K-Dense-AI/scientific-agent-skills --skill shap
Clone the repo
git clone --depth 1 https://github.com/K-Dense-AI/scientific-agent-skills

Made for: Claude Code.

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/k-dense-ai/scientific-agent-skills/shap/github.svg)](https://agentmods.dev/skills/k-dense-ai/scientific-agent-skills/shap)
Your own site
<a href="https://agentmods.dev/skills/k-dense-ai/scientific-agent-skills/shap"><img src="https://agentmods.dev/badge/skills/k-dense-ai/scientific-agent-skills/shap/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for shap

Your own site · 80×15
<a href="https://agentmods.dev/skills/k-dense-ai/scientific-agent-skills/shap"><img src="https://agentmods.dev/badge/skills/k-dense-ai/scientific-agent-skills/shap.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 46 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,108 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • Socket pass 9 Apr 2026
  • Snyk pass 9 Apr 2026
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
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.00046 $0.03108
Opus 5 $0.00023 $0.01554
Sonnet 5 $0.00009 $0.00622
Haiku 4.5 $0.00005 $0.00311

Measured 8d ago against content hash 6e1e3a128848, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, 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 8d ago.

The scan reads SKILL.md. This mod also ships 1 executable file (scripts/tabular_report.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/shap/SKILL.md · 300 lines

How it starts

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

SHAP

Use SHAP to describe how a fitted predictive model maps inputs to outputs. Work from the modern shap.Explanation API, make the explained output and background distribution explicit, and validate every explanation before interpreting it.

This skill is aligned with SHAP 0.52.0 (released 2026-05-28). That release requires Python 3.12 or newer.

Operating Rules

  1. Explain a fixed, evaluated model; do not use SHAP as a substitute for predictive validation.
  2. Use held-out or clearly labeled analysis rows for explanations. Choose background rows only from an appropriate training or reference population.
  3. State the explained output: regression value, raw margin, probability, log loss, logit, or another model method.
  4. Keep explanations as shap.Explanation objects. Call explainer(X); use .shap_values(X) only when maintaining legacy code.
  5. For multi-output models, select one output before using tabular plots: explanation[..., output_index].
  6. Check base_values + values.sum(...) against the exact model output being explained.
  7. Treat SHAP as a description of model behavior under a masking/background choice. It does not establish causality, fairness, recourse, or scientific mechanism.
  8. Never silence an additivity failure until input shape, preprocessing, model version, output space, and row ordering have been checked.
  9. Do not load untrusted pickle, joblib, model, or explainer artifacts; those formats can execute code during deserialization.

Install

Create an isolated environment and pin the documented release:

uv venv --python 3.12
source .venv/bin/activate
uv pip install "shap[plots]==0.52.0"

shap[plots] installs the plotting dependencies. Add the fitted model's package at a version compatible with the project. For older Python compatibility, read references/migration.md instead of silently installing a different SHAP release.

Confirm the environment before debugging an API mismatch:

import platform
import shap

print("Python:", platform.python_version())
print("SHAP:", shap.__version__)

Read the full file on GitHub · 300 lines

Files

What ships with it

9 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. 8d ago First seen · 300 lines · 46 tokens per session scan A 6e1e3a128848

Subscribe to this mod's changes

shap is a skill published in the GitHub repository K-Dense-AI/scientific-agent-skills (44,220 stars, last pushed 4d ago), licensed MIT. It adds 46 tokens to every session and 3,108 once invoked, about $0.0002 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-09-03.