lime for local explanations
**LIME** (Local Interpretable Model-Agnostic Explanations) is an **XAI technique that explains individual predictions by fitting a simple, interpretable model (e.g., linear regression) in the neighborhood of the prediction** — showing which features most influenced a specific decision.
**How Does LIME Work?**
- **Perturbation**: Generate perturbed versions of the input by randomly modifying features.
- **Black Box**: Query the original model on all perturbed samples to get their predictions.
- **Local Model**: Fit a simple, interpretable model (linear, decision tree) to the perturbed data weighted by proximity.
- **Explanation**: The local model's coefficients explain which features pushed the prediction up or down.
**Why It Matters**
- **Model-Agnostic**: Works with any ML model (neural networks, random forests, gradient boosting) without modification.
- **Individual Predictions**: Explains specific predictions rather than global model behavior.
- **Image Explanations**: For defect images, LIME highlights which image regions were most important for classification.
**LIME** is **a local explanation lens** — zooming into a single prediction to understand what drove that specific decision.