Spaces:
Sleeping
Sleeping
A newer version of the Gradio SDK is available: 6.13.0
metadata
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)
- Use the slider to select a digit index (0-99)
- Click "Generate Explanation"
- See the original digit and SHAP pixel attributions
Tab 2: Image Segmentation (ImageNet)
- Upload any image (JPG, PNG)
- Click "Generate Explanation"
- Wait 30-60 seconds (image masking is computationally intensive)
- See SHAP region attributions for top 4 classes
Tab 3: Tabular Data (Adult Income)
- Use the slider to select a sample (0-99)
- Click "Generate Explanation"
- 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:
📄 License
MIT License
Built with ❤️ using Gradio and SHAP