Skillpedia
تعلّم الآلة33k · #9029

shap

ما الذي تفعله

تمنح وكيلك SHAP، وهي طريقة لشرح تنبؤات النماذج. تعمل مع نماذج الأشجار والتعلم العميق والنماذج الخطية والنماذج الصندوقية السوداء. وهي لعلماء البيانات الذين يحتاجون إلى شرح نماذجهم أو تصحيح أخطائها.

متى تستخدمها

  • ✓عندما تحتاج إلى شرح السمات التي تدفع تنبؤات النموذج.
  • ✓عندما تريد مخطط شلال أو مخطط نحلة أو مخطط أعمدة لأهمية السمات.
  • ✓عندما تحتاج إلى فحص النموذج بحثًا عن الانحياز أو سلوك غير متوقع.

رابط المهارة

https://github.com/davila7/claude-code-templates/blob/main/cli-tool/components/skills/scientific/shap/SKILL.md

انسخه والصقه في الذكاء الاصطناعي الذي تستخدمه (Claude أو ChatGPT أو Cursor) واطلب منه اتباع التعليمات.

طريقة الاستخدام

أسهل طريقة: انسخ الرسالة والصقها في الذكاء الاصطناعي الذي تستخدمه. سيقرأ المهارة وينفّذ تعليماتها.

رسالة جاهزة للصق

استخدم هذه المهارة لمساعدتي: https://github.com/davila7/claude-code-templates/blob/main/cli-tool/components/skills/scientific/shap/SKILL.md اقرأ ملف SKILL.md في هذا الرابط ونفّذ تعليماته لمهمتي.
تريد أن يجد الذكاء الاصطناعي مهارات مثل هذه بنفسه؟ثبّت خادم Skillpedia MCP المجاني: سطر واحد، ويبحث في 15,000+ مهارة قبل كل مهمة.ثبّته في دقيقة واحدة →

مثال على ما تطلبه من الذكاء الاصطناعي

“اشرح لي أي السمات تؤثر أكثر في تنبؤات نموذج القروض XGBoost الخاص بي، وارسم مخطط نحلة.”

5 مهارات جديدة كل أسبوع. قراءة في دقيقة واحدة.

كيف تعمل

يحسب وكيلك قيم SHAP لنموذجك ولكل تنبؤ. ثم يحوّلها إلى مخططات وملخصات توضح كيف تدفع كل سمة التنبؤات صعودًا أو هبوطًا.

المحتوى التقني (ملف SKILL.md الأصلي)

النص الأصلي من المؤلف، مباشرة من GitHub.

SHAP (SHapley Additive exPlanations)

Overview

SHAP is a unified approach to explain machine learning model outputs using Shapley values from cooperative game theory. This skill provides comprehensive guidance for:

  • Computing SHAP values for any model type
  • Creating visualizations to understand feature importance
  • Debugging and validating model behavior
  • Analyzing fairness and bias
  • Implementing explainable AI in production

SHAP works with all model types: tree-based models (XGBoost, LightGBM, CatBoost, Random Forest), deep learning models (TensorFlow, PyTorch, Keras), linear models, and black-box models.

When to Use This Skill

Trigger this skill when users ask about:

  • "Explain which features are most important in my model"
  • "Generate SHAP plots" (waterfall, beeswarm, bar, scatter, force, heatmap, etc.)
  • "Why did my model make this prediction?"
  • "Calculate SHAP values for my model"
  • "Visualize feature importance using SHAP"
  • "Debug my model's behavior" or "validate my model"
  • "Check my model for bias" or "analyze fairness"
  • "Compare feature importance across models"
  • "Implement explainable AI" or "add explanations to my model"
  • "Understand feature interactions"
  • "Create model interpretation dashboard"

Quick Start Guide

Step 1: Select the Right Explainer

Decision Tree:

  1. Tree-based model? (XGBoost, LightGBM, CatBoost, Random Forest, Gradient Boosting)

    • Use shap.TreeExplainer (fast, exact)
  2. Deep neural network? (TensorFlow, PyTorch, Keras, CNNs, RNNs, Transformers)

    • Use shap.DeepExplainer or shap.GradientExplainer
  3. Linear model? (Linear/Logistic Regression, GLMs)

    • Use shap.LinearExplainer (extremely fast)
  4. Any other model? (SVMs, custom functions, black-box models)

    • Use shap.KernelExplainer (model-agnostic but slower)
  5. Unsure?

    • Use shap.Explainer (automatically selects best algorithm)

See references/explainers.md for detailed information on all explainer types.

Step 2: Compute SHAP Values

import shap

# Example with tree-based model (XGBoost)
import xgboost as xgb

# Train model
model = xgb.XGBClassifier().fit(X_train, y_train)

# Create explainer
explainer = shap.TreeExplainer(model)

# Compute SHAP values
shap_values = explainer(X_test)

# The shap_values object contains:
# - values: SHAP values (feature attributions)
# - base_values: Expected model output (baseline)
# - data: Original feature values

Step 3: Visualize Results

For Global Understanding (entire dataset):

# Beeswarm plot - shows feature importance with value distributions
shap.plots.beeswarm(shap_values, max_display=15)

# Bar plot - clean summary of feature importance
shap.plots.bar(shap_values)

For Individual Predictions:

# Waterfall plot - detailed breakdown of single prediction
shap.plots.waterfall(shap_values[0])

# Force plot - additive force visualization
shap.plots.force(shap_values[0])

For Feature Relationships:

# Scatter plot - feature-prediction relationship
shap.plots.scatter(shap_values[:, "Feature_Name"])

# Colored by another feature to show interactions
shap.plots.scatter(shap_values[:, "Age"], color=shap_values[:, "Education"])

See references/plots.md for comprehensive guide on all plot types.

Core Workflows

This skill supports several common workflows. Choose the workflow that matches the current task.

Workflow 1: Basic Model Explanation

Goal: Understand what drives model predictions

Steps:

  1. Train model and create appropriate explainer
  2. Compute SHAP values for test set
  3. Generate global importance plots (beeswarm or bar)
  4. Examine top feature relationships (scatter plots)
  5. Explain specific predictions (waterfall plots)

Example:

# Step 1-2: Setup
explainer = shap.TreeExplainer(model)
shap_values = explainer(X_test)

# Step 3: Global importance
shap.plots.beeswarm(shap_values)

# Step 4: Feature relationships
shap.plots.scatter(shap_values[:, "Most_Important_Feature"])

# Step 5: Individual explanation
shap.plots.waterfall(shap_values[0])

Workflow 2: Model Debugging

Goal: Identify and fix model issues

Steps:

  1. Compute SHAP values
  2. Identify prediction errors
  3. Explain misclassified samples
  4. Check for unexpected feature importance (data leakage)
  5. Validate feature relationships make sense
  6. Check feature interactions

**See references/workflows.md for detailed debu

الأسئلة الشائعة

ما قيم SHAP؟

هي درجات تبيّن مقدار إضافة كل سمة إلى تنبؤ واحد أو إنقاصه، استنادًا إلى قيم Shapley.

مع أي نماذج تعمل؟

تغطي المهارة نماذج الأشجار مثل XGBoost وLightGBM، ونماذج التعلم العميق، والنماذج الخطية.

هل يمكنها فحص الانحياز؟

نعم. تغطي المهارة تحليل انحياز النموذج وعدالته باستخدام 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.

repo: davila7/claude-code-templates

الشعبية

نجوم GitHub
33k
الترتيب
#9029
الترخيص
MIT
آخر تحديث
2‏/11‏/2026

هل هذه المهارة مفيدة؟

0

سجّل الدخول للتصويت.

التعليقات

  • …

المزيد من المهارات من هذا المستودع

مهارات مشابهة