shap

Compute SHAP values and generate visual explanations for model predictions.

52|6|Updated Nov 24, 2025
One-click install
npx skills add https://github.com/ovachiever/droid-tings --skill shap-ovachiever
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: shap
Source: https://github.com/ovachiever/droid-tings/tree/main/skills/shap
Command: npx skills add https://github.com/ovachiever/droid-tings --skill shap-ovachiever

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides guidance and visualization patterns for SHAP-based explanations across model types, enabling clear attributions, debugging, and fairness analyses.

Core Features & Use Cases

  • Global & local explanations: Compute SHAP values and visualize top features for both whole datasets and individual predictions.
  • Interactive diagnosis: Use waterfall, beeswarm, bar, scatter, force, and heatmap plots to understand model behavior, interactions, and potential biases.
  • Model comparison & fairness: Compare explanations across models or cohorts to identify biases and ensure fairness.

Quick Start

Use SHAP explainer to generate explanations for a trained model and render a waterfall plot for a single instance.

Frequently Asked Questions about shap

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I explain machine learning model predictions using SHAP values?

SHAP values attribute model outputs to input features by computing Shapley values from game theory. Load a trained model, initialize the appropriate explainer (TreeExplainer for XGBoost/LightGBM/CatBoost/Random Forest, DeepExplainer for TensorFlow/PyTorch, or KernelExplainer for black-box models), pass background data, compute SHAP values, then visualize with waterfall, beeswarm, bar, or force plots to see feature contributions.

What's the best way to visualize feature importance for individual predictions?

Waterfall plots display how each feature pushes a single prediction from the baseline toward the final output, showing both magnitude and direction. Beeswarm plots reveal feature value distributions across many predictions. For a single instance, waterfall provides the clearest local explanation; for cohorts, use beeswarm or bar plots to identify patterns.

Can I use SHAP to compare model fairness across different groups?

Yes. Compute SHAP values separately for different cohorts or demographics, then compare feature attributions and prediction patterns across groups using heatmap or scatter plots. This reveals whether the model relies on protected attributes or treats similar cases differently, enabling bias detection and fairness auditing.

Does SHAP work with deep learning models like TensorFlow and PyTorch?

Yes. SHAP includes DeepExplainer for neural networks; it computes attributions using expected gradients. For tree-based models, use TreeExplainer. For any other black-box model or when you lack white-box access, use KernelExplainer, which works model-agnostically but requires more computation.

What data do I need to prepare before computing SHAP explanations?

Prepare a trained model and background data—a representative sample of your training or validation set used to establish baseline predictions. Larger background datasets improve SHAP value stability but increase computation time. Ensure features are in the same format and scale as the model expects.

How do I debug why a model makes unexpected predictions?

Generate a waterfall plot for the problematic prediction to see which features drove the decision and their magnitudes. Compare against waterfall plots for similar correct predictions using force or scatter plots. This reveals feature interactions, data issues, or model biases causing the error.