shap for feature importance
**SHAP** (SHapley Additive exPlanations) is a **game-theoretic approach that assigns each feature an importance score for a particular prediction** — based on Shapley values from cooperative game theory, providing consistent, locally accurate, and fair attribution of feature contributions.
**How Does SHAP Work?**
- **Shapley Value**: The average marginal contribution of a feature across all possible feature combinations.
- **Additivity**: Feature contributions sum to the difference between the prediction and the average prediction.
- **Global + Local**: SHAP provides both per-prediction (local) and dataset-wide (global) explanations.
- **Implementations**: TreeSHAP (fast for tree models), KernelSHAP (model-agnostic), DeepSHAP (deep learning).
**Why It Matters**
- **Feature Ranking**: SHAP importance plots show which process parameters most influence yield/defect predictions.
- **Interaction Detection**: SHAP interaction values reveal synergistic effects between process variables.
- **Debugging**: Identifies when models rely on unexpected features — flagging potential data leakage or confounders.
**SHAP** is **the fair scorecard for features** — using game theory to assign each process variable its fair share of credit for every prediction.