AGENT SKILL

explainable-ai

Explainable AI (XAI) techniques

License 许可
MIT
最近更新
2026-03-01
Stars
★ 3
Forks
2

01 前言 Front Matter

name
explainable-ai
license
MIT
metadata
{ "audience": "machine-learning-engineers", "category": "artificial-intelligence" }
description
Explainable AI (XAI) techniques
compatibility
opencode

03 SKILL.md 正文

What I do

  • Apply XAI techniques to models
  • Generate model-agnostic explanations
  • Create interpretable features
  • Build trust in AI systems
  • Handle fairness and bias

When to use me

Use me when:

  • Regulatory compliance (GDPR, EU AI Act)
  • High-stakes decisions
  • Debugging model behavior
  • Building trust with users

Key Concepts

XAI Methods

  • SHAP: Shapley additive explanations
  • LIME: Local interpretable model-agnostic
  • Counterfactuals: What-if analysis
  • Feature importance: Permutation, tree-based

SHAP Framework

import shap

# Kernel SHAP for any model
explainer = shap.KernelExplainer(model.predict, X_background)
shap_values = explainer.shap_values(X_test)

# Tree SHAP for tree-based
explainer = shap.TreeExplainer(model)
shap_values = explainer.shap_values(X_test)

# Visualization
shap.force_plot(
    explainer.expected_value, 
    shap_values[0,:], 
    X_test.iloc[0,:]
)

Counterfactual Explanations

from dice_ml import Explainer

# Create explainer
explainer = Explainer(model, X_train, outcome_class="target")

# Generate counterfactuals
explanation = explanation.generate_counterfactuals(
    X_test[0:1], 
    total_CFs=3, 
    desired_class="opposite"
)

Fairness

  • Demographic parity
  • Equalized odds
  • Individual fairness
  • Bias detection metrics

04 同仓库更多 Skills