Skip to content

This script focuses on explaining a pre-trained CNN’s predictions on the MedMNIST dataset using Deep SHAP. Shapley values are computed for each pixel, summed to create a single Shapley score per image, and saved alongside labels in CSV files for interpretability in medical image classification.

Notifications You must be signed in to change notification settings

reyhanhosavci/Shapley_Value

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

This script demonstrates a deep learning workflow for medical image classification using the MedMNIST dataset. It integrates PyTorch for model training and evaluation and SHAP for explainability. Below is a concise overview:

  1. Dataset and Preprocessing**
  • Uses the MedMNIST API to load datasets (e.g., pathmnist) with preprocessing (tensor conversion and normalization).
  • Data is organized into train and test loaders for efficient batching.

  1. CNN Model**
  • Defines a convolutional neural network (Net) with:
    • Convolutional Layers: Feature extraction using ReLU, BatchNorm, and MaxPooling.
    • Fully Connected Layers: Classification into dataset-specific classes.
  • Loads a pre-trained model (cnnmodel.pt) for evaluation.

  1. SHAP Explainability**
  • Creates multiple SHAP explainers (DeepExplainer) using subsets of the training data.
  • Computes Shapley values to quantify feature (pixel) importance for predictions.
  • Saves results (image indices, labels, Shapley values) into CSV files for analysis.

Key Features**

  • Parameters: Configurable batch size, learning rate, and epochs.
  • Output: Model predictions and interpretable Shapley values for each image.

This workflow combines accurate classification with explainability, making it useful for medical AI applications where interpretability is essential.

About

This script focuses on explaining a pre-trained CNN’s predictions on the MedMNIST dataset using Deep SHAP. Shapley values are computed for each pixel, summed to create a single Shapley score per image, and saved alongside labels in CSV files for interpretability in medical image classification.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages