Automated summary
Computes SHAP values for a trained model and produces feature-attribution plots (summary, bar, waterfall, force, dependence, interaction).
Strengths
- Supports multiple explainer families: TreeExplainer, DeepExplainer, KernelExplainer, linear and gradient
- Generates a configurable set of plots (summary, bar, waterfall, force, dependence, interaction) with a max-features cap
- Returns structured output: SHAP values path, expected value, ranked feature importance and top interactions
- Includes cohort-based analysis and sampling controls (numSamples, backgroundSamples) to bound compute cost
Limitations
- Assumes the model and data already exist locally (modelPath, dataPath); it does not train models
- Does not detail handling of models unsupported by the chosen explainer or the exact serialization formats required
- KernelExplainer is expensive on large datasets, and explanation quality depends heavily on the background sample choice
Use it when a trained model needs feature-level explanations with shareable plots for a review or report.
Avoid it if you need to train, tune or deploy a model, or if you require advanced fairness metrics that this skill does not provide.
Security analysis
CautionThe skill is a legitimate SHAP explainability specification with no destructive, exfiltrating, or obfuscated instructions. However, it grants Bash and Write permissions and accepts user-supplied filesystem paths, so it can execute code and write files wherever directed. The risk is inherent to a data-science tool rather than malicious, so it merits caution rather than risky.
- •Declares Bash and Write access, allowing arbitrary command execution and filesystem writes during skill execution
- •User-controlled outputDir, modelPath, and dataPath are passed to file I/O without path restrictions, so they could reference sensitive locations
- •Dependencies (SHAP, matplotlib, numpy) are unpinned, creating supply-chain/version risk
- •Model deserialization (e.g., .pkl) is implied and can execute arbitrary code if an untrusted model file is supplied
Examples
Use the shap-explainer skill on models/xgboost_model.pkl with data/test.csv, explainerType 'tree', numSamples 1000, backgroundSamples 100, and generate summary, bar and dependence plots into explanations/ with maxFeatures 20.Run shap-explainer with explainerType 'kernel' on my pickled model at artifacts/model.pkl and features at data/holdout.csv; give me the top 15 features by importance and a waterfall plot for the first 5 rows.Compute SHAP interaction values for models/lgbm.txt on data/val.csv using TreeExplainer and report the top feature interactions plus a summary plot.name: shap-explainer description: SHAP-based model explainability skill for feature attribution, summary plots, and interaction analysis. allowed-tools:
- Read
- Write
- Bash
- Glob
- Grep graph: domains: [domain:data-science] specializations: [specialization:data-science-ml] skillAreas: [skill-area:explainability-interpretation, skill-area:model-explainability-testing] roles: [role:data-scientist, role:ml-engineer] workflows: [workflow:ml-model-lifecycle]
shap-explainer
Overview
SHAP-based model explainability skill for feature attribution, summary plots, interaction analysis, and model interpretation.
Capabilities
- TreeExplainer for tree-based models (XGBoost, LightGBM, Random Forest)
- DeepExplainer for neural networks
- KernelExplainer for model-agnostic explanations
- Summary, dependence, and force plots
- Interaction value computation
- Cohort-based analysis
- Waterfall and bar plots
- Expected value analysis
Target Processes
- Model Interpretability and Explainability Analysis
- Model Evaluation and Validation Framework
- A/B Testing Framework for ML Models
Tools and Libraries
- SHAP
- matplotlib
- numpy
Input Schema
{
"type": "object",
"required": ["modelPath", "dataPath", "explainerType"],
"properties": {
"modelPath": {
"type": "string",
"description": "Path to the trained model"
},
"dataPath": {
"type": "string",
"description": "Path to data for explanation"
},
"explainerType": {
"type": "string",
"enum": ["tree", "deep", "kernel", "linear", "gradient"],
"description": "Type of SHAP explainer to use"
},
"analysisConfig": {
"type": "object",
"properties": {
"numSamples": { "type": "integer" },
"backgroundSamples": { "type": "integer" },
"featureNames": { "type": "array", "items": { "type": "string" } },
"outputIndex": { "type": "integer" }
}
},
"plotConfig": {
"type": "object",
"properties": {
"plotTypes": {
"type": "array",
"items": { "type": "string", "enum": ["summary", "bar", "waterfall", "force", "dependence", "interaction"] }
},
"maxFeatures": { "type": "integer" },
"outputDir": { "type": "string" }
}
}
}
}
Output Schema
{
"type": "object",
"required": ["status", "shapValues"],
"properties": {
"status": {
"type": "string",
"enum": ["success", "error"]
},
"shapValues": {
"type": "string",
"description": "Path to SHAP values file"
},
"expectedValue": {
"type": "number"
},
"featureImportance": {
"type": "array",
"items": {
"type": "object",
"properties": {
"feature": { "type": "string" },
"importance": { "type": "number" },
"rank": { "type": "integer" }
}
}
},
"plots": {
"type": "array",
"items": {
"type": "object",
"properties": {
"type": { "type": "string" },
"path": { "type": "string" }
}
}
},
"interactions": {
"type": "object",
"description": "Top feature interactions"
}
}
}
Usage Example
{
kind: 'skill',
title: 'Generate SHAP explanations',
skill: {
name: 'shap-explainer',
context: {
modelPath: 'models/xgboost_model.pkl',
dataPath: 'data/test.csv',
explainerType: 'tree',
analysisConfig: {
numSamples: 1000,
backgroundSamples: 100
},
plotConfig: {
plotTypes: ['summary', 'bar', 'dependence'],
maxFeatures: 20,
outputDir: 'explanations/'
}
}
}
}
Prompt Engineering
Data & AI
Prompt engineering best practices and templates to maximize AI outputs.
Data Visualization
Data & AI
Generates data visualizations and charts tailored to your data.
RAG Architecture Setup
Data & AI
Setup guide for RAG (Retrieval-Augmented Generation) architectures.