Skip to content

arnavsm/med-cbm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Evaluating Concept Locality in Medical Concept Bottleneck Models

This repository contains code for evaluating concept locality in Concept Bottleneck Models (CBMs) applied to medical imaging. The goal is to assess whether learned concepts are faithfully grounded in the correct spatial regions of an image.

Concept locality is evaluated by analyzing whether model explanations rely on medically relevant regions or on spurious correlations. Failure to respect locality undermines the interpretability and trustworthiness of CBMs in clinical settings.


Environment Setup

Python version

Python 3.10.18

Conda (recommended)

conda create -n conc python=3.10
conda activate conc
pip install -r requirements.txt

Alternative (uv)

uv pip install -r requirements.txt

Repository Structure

.
├── ConceptBottleneck/  # Concept Bottleneck implementation
├── datasets/           # Dataset Directory
├── models/             # Model Data Saved
├── src/                # Core implementation
├── scripts/            # Shell scripts to run experiments
├── misc/               # Miscellaneous utilities
├── results/            # Experiment results
├── requirements.txt    # Python dependencies
├── LICENSE             # License information
└── README.md           # This file

All .sh files inside scripts/ directly invoke the corresponding Python experiments.


Installation

After cloning the repository:

pip install -e .

This installs the package in editable mode using setup.py.


Datasets

Datasets are not included in this repository, please refer to this link for more info

Set the dataset root directory in the code or scripts:

data_dir = "/DATA/arnav"

Update this path to match your local setup before running experiments.


Running Experiments

Activate the environment and run any script from the scripts/ directory:

bash scripts/<script_name>.sh

Each script executes a complete experiment pipeline using predefined configurations.


Reproducibility Notes

  • All dependencies are pinned in requirements.txt
  • Scripts are self-contained and reproducible given correct dataset paths
  • Results depend only on configuration files and dataset location
  • Experiment outputs are saved to results/

License

This project is intended for academic and research use. See LICENSE for details.

About

code for investigating if concept bottleneck models for medical imaging respect locality

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published