shap

Model interpretability and explainability using SHAP (SHapley Additive exPlanations). Use this skill when explaining machine learning model predictions, computing feature importance, generating SHAP plots (waterfall, beeswarm, bar, scatter, force, heatmap), debugging models, analyzing model bias or fairness, comparing models, or implementing explainable AI. Works with tree-based models (XGBoost, LightGBM, Random Forest), deep learning (TensorFlow, PyTorch), linear models, and any black-box model.

Install

Hot:13

Download and extract to your skills directory

Copy command and send to OpenClaw for auto-install:

Download and install this skill https://openskills.cc/api/download?slug=k-dense-ai-scientific-skills-shap&locale=en&source=copy

SHAP - Machine Learning Model Interpretability Tool

Skill Overview

The SHAP skill provides Shapley value–based explanations for machine learning models, helping you understand the reasoning behind any model's predictions, compute feature importance, and generate various visualizations.

Use Cases

  • Model debugging and validation

  • When your model's predictions are unexpected, use SHAP to analyze each feature's contribution to the prediction and quickly pinpoint data leakage, anomalous features, or patterns the model learned incorrectly.

  • Feature engineering optimization

  • Use SHAP scatter plots to discover nonlinear relationships between features and predictions, identify valuable feature interactions, and guide feature transformations and the creation of interaction terms.

  • Fairness and bias analysis

  • Detect whether a model has discriminatory effects on different groups, analyze whether protected attributes (such as gender or age) are being implicitly used by the model, discover proxy features, and implement mitigation strategies.

    Core Features

  • Support for multiple model types

  • Provides a fast TreeExplainer for tree models (XGBoost, LightGBM, CatBoost, random forest), DeepExplainer for deep learning models (TensorFlow, PyTorch), LinearExplainer for linear models, and the model-agnostic KernelExplainer for any black‑box model.

  • Rich visualizations

  • Generate waterfall plots to show detailed breakdowns of individual predictions, beeswarm plots to display global feature importance distributions, bar charts for concise importance summaries, scatter plots to reveal feature–prediction relationships, as well as force plots and heatmaps and other interactive visualizations.

  • Complete analysis from local to global

  • Support explaining the reason for a single sample's prediction (local explanation), analyze feature importance patterns across an entire dataset (global explanation), compare feature contribution differences between groups or models, and integrate explanation services into production APIs.

    Frequently Asked Questions

    Which machine learning models does SHAP support?

    SHAP supports almost all types of machine learning models. For tree models like XGBoost, LightGBM, CatBoost, and random forests, the dedicated TreeExplainer is the fastest; for deep learning models such as TensorFlow, PyTorch, and Keras, you can use DeepExplainer or GradientExplainer; linear regression and logistic regression use LinearExplainer; for SVMs or any custom black‑box models, use the model‑agnostic KernelExplainer. If you're unsure which explainer to choose, you can use shap.Explainer to automatically select the most appropriate algorithm.

    What do positive and negative SHAP values mean?

    A SHAP value indicates which direction a feature pushes the prediction. A positive value means the feature raises the prediction above the baseline, while a negative value means the feature lowers the prediction below the baseline. The larger the absolute value, the stronger the feature's influence on that prediction. For example, in a credit scoring model, a SHAP value of +0.15 for "annual income" means the user's income increased their credit score by 0.15, whereas a SHAP value of -0.25 for "delinquency record" means the delinquency record decreased the score by 0.25. The sum of all feature SHAP values equals the difference between the final prediction and the baseline.

    Should I choose TreeExplainer or KernelExplainer?

    If your model is a tree model (XGBoost, LightGBM, CatBoost, random forest, etc.), you should choose TreeExplainer. TreeExplainer leverages the tree structure and can compute exact values in milliseconds, while KernelExplainer, as a model-agnostic general method, is dozens to hundreds of times slower and provides approximate results. Only use KernelExplainer when your model cannot use any dedicated explainer (for example, SVM, KNN, or a custom prediction function). Choosing the wrong explainer is the most common performance issue when using SHAP.