SHAP_DEMO / README.md
xxnithicxx's picture
Update README.md
8ee09c6 verified
|
Raw
History Blame Contribute Delete
2.41 kB
---
title: SHAP Explainability Demo
emoji: 🔍
colorFrom: blue
colorTo: purple
sdk: gradio
sdk_version: 5.49.1
app_file: app.py
pinned: false
license: mit
---
# SHAP Explainability Demo 🔍
An interactive demonstration of SHAP (SHapley Additive exPlanations) algorithm with three different explanation approaches.
## 🎯 Features
This demo showcases three powerful SHAP explanation methods:
### 1. 🖼️ Pixel-level Explanations (MNIST Digits)
- Uses **DeepExplainer** for deep learning models
- Explains which pixels contribute to digit classification
- Interactive digit selection (0-9)
- Real-time visualization with red/blue attribution maps
### 2. 🎨 Image Segmentation Explanations (ImageNet)
- Uses **Partition Explainer** with image masking
- Explains image classification with region-based attributions
- Upload any image and see which regions matter
- Shows top 4 predicted classes with real names (e.g., "beagle", "golden_retriever")
- Uses ResNet50 pre-trained on ImageNet
### 3. 📊 Tabular Data Explanations (Adult Income)
- Uses **TreeExplainer** for tree-based models
- Explains income prediction with feature attributions
- Waterfall plots showing feature contributions
- Based on Adult Income dataset with Random Forest classifier
## 🚀 How to Use
### Tab 1: Pixel-level (MNIST)
1. Use the slider to select a digit index (0-99)
2. Click "Generate Explanation"
3. See the original digit and SHAP pixel attributions
### Tab 2: Image Segmentation (ImageNet)
1. Upload any image (JPG, PNG)
2. Click "Generate Explanation"
3. Wait 30-60 seconds (image masking is computationally intensive)
4. See SHAP region attributions for top 4 classes
### Tab 3: Tabular Data (Adult Income)
1. Use the slider to select a sample (0-99)
2. Click "Generate Explanation"
3. See the waterfall plot showing feature contributions
## 🛠️ Technologies
- **Gradio**: Web interface
- **SHAP**: Explanation framework
- **PyTorch**: MNIST model
- **TensorFlow/Keras**: ResNet50 model
- **scikit-learn**: Random Forest model
- **OpenCV**: Image inpainting for masking
## 📚 About SHAP
SHAP (SHapley Additive exPlanations) is a game-theoretic approach to explain machine learning model predictions.
**Learn more:**
- [SHAP GitHub](https://github.com/slundberg/shap)
- [SHAP Paper](https://arxiv.org/abs/1705.07874)
## 📄 License
MIT License
---
**Built with ❤️ using Gradio and SHAP**