shap

Compute SHAP values and generate visualizations to explain machine learning model predictions.

Updated Feb 27, 2026
One-click install
npx skills add https://github.com/gracefullight/cnn --skill shap-gracefullight
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: shap
Source: https://github.com/gracefullight/cnn/tree/main/.agents/skills/shap
Command: npx skills add https://github.com/gracefullight/cnn --skill shap-gracefullight

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires shap, numpy, pandas, scikit-learn, matplotlib, scipy, and includes references (resource) components.

What problem does it solve? Machine learning models often act as black boxes, making it hard to understand why they produce specific predictions. This Skill computes SHAP (SHapley Additive exPlanations) values to quantify each feature's contribution, enabling model debugging, bias detection, and explainable AI workflows. ## Core Features & Use Cases - Explainer Selection: Automatically choose the right explainer (TreeExplainer, DeepExplainer, KernelExplainer, LinearExplainer) for tree-based models, deep learning networks, linear models, or black-box functions. - Visualization Suite: Generate waterfall, beeswarm, bar, scatter, force, heatmap, violin, and decision plots for both individual predictions and global feature importance. - Structured Workflows: Follow guided workflows for model debugging, feature engineering, model comparison, fairness and bias analysis, and production deployment. - Use Case: After training an XGBoost classifier, compute SHAP values with TreeExplainer, plot a beeswarm chart to rank global feature importance, and use waterfall plots to explain individual misclassified predictions. ## Quick Start Explain my trained XGBoost model's predictions using SHAP and show me a beeswarm plot of the most important features.

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 with SHAP?▼

Create an explainer matching your model type, compute SHAP values on test data, then visualize with plots like beeswarm for global importance or waterfall for individual predictions. For tree models, use shap.TreeExplainer for fast, exact results.

Which SHAP explainer should I use for my model?▼

Use TreeExplainer for XGBoost, LightGBM, and Random Forest; DeepExplainer or GradientExplainer for TensorFlow and PyTorch networks; LinearExplainer for linear models; and KernelExplainer for black-box models. shap.Explainer auto-selects the best algorithm.

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

Yes, DeepExplainer and GradientExplainer support TensorFlow, Keras, and PyTorch models. Provide 100-1000 background samples from training data to balance explanation accuracy and computational cost.

Why are my SHAP values in log-odds instead of probabilities?▼

XGBoost classifiers explain margin output (log-odds) by default. To explain probabilities, set model_output="probability" in TreeExplainer, and always verify what output type your model produces before interpreting values.

What are the limitations of SHAP for feature importance?▼

SHAP shows association, not causation, and correlated features can distort attributions. KernelExplainer is slow for large datasets, and replacing features to form coalitions may create unrealistic out-of-distribution samples.