# Explainable AI

> Explainable AI (XAI) techniques

- Skill: `ffsshhttiikk/explainable-ai` (Agent Skill)
- Install (CLI): `npx skillmds@latest add ffsshhttiikk/explainable-ai`
- Raw SKILL.md: https://api.skillmd.com/api/skills/ffsshhttiikk/explainable-ai/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- License: MIT
- Author: ffsshhttiikk (https://skillmd.com/u/ffsshhttiikk)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/ffsshhttiikk/explainable-ai

---


## 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
```python
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
```python
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

