A Python project (soon to be, package) for time-dependent SHAP (SHapley Additive exPlanations) explanations in survival models. This repository provides scripts and utilities for generating synthetic survival data, running time-dependent SHAP explanations for Random Survival Forest models, and visualizing the generated explanations.
- Generate synthetic survival data for benchmarking
- Compute and visualize time-dependent SHAP values
- Support for scikit-survival models
- Example scripts and figures for reproducibility
Create a new conda environment named intervalshap with e.g. Python 3.10:
conda create -n intervalshap python=3.10
conda activate intervalshapIf you are not using Anaconda, you can use pip to install the required packages (see below).
With Anaconda, run the following commands in your environment:
conda install -c sebp scikit-survival>=0.22
conda install shap>=0.47
conda install matplotlib>=3.10
conda install ipython>=8.30These packages will also install the following dependencies:
- bottleneck
- numpy
- scikit-learn
- pillow
If using pip, install the equivalent versions:
pip install "scikit-survival>=0.22" "shap==0.47" "matplotlib==3.10.0" "ipython==8.30.0"main_script_run.py— Main script to run intervalSHAP analysisgenerate_surv_data.py— Script to generate synthetic survival data (being tested)environment.yml— Conda environment specification (alternative to manual setup)FLChain-single-event-imputed/— Example dataset (csv files)saved_data_*.pkl— Example saved datasetsdraft-figures/,figures/— Output figures and plots when draft setting is on (with smaller data)other-material-and-slides/— Additional figures and slides
-
Activate the environment:
conda activate intervalshap
-
Run the main script:
python main_script_run.py
This will perform the intervalSHAP analysis and generate output figures in the
figures/directory. -
Generate synthetic data (optional):
python generate_surv_data.py
- Figures and plots are saved in the
figures/anddraft-figures/directories. - Example datasets are provided in
FLChain-single-event-imputed/.
- The code is tested with the package versions listed above. Other package and Python versions should work but are not guaranteed.
- For questions or issues, please open an issue on GitHub.