Skip to main content

Shapley values for interpreting radiomic models

Project description

radshap

Documentation Status Code style: black PyPI version Downloads

This repository proposes a python tool for highlighting the contribution of different regions of interest (ROIs) to the predictions of radiomic models. It estimates the Shapley value of the different ROIs of an image that a trained radiomic model uses to obtain a prediction.

Graphical abstract

a. schematic view of a generic aggregated radiomic model - b. computation of a Shapley value for a specific region.

Install

Install from source

pip install git+https://github.com/ncaptier/radshap.git

Experiments

We provide a jupyter notebook for an illustration with PET images and simple aggregation strategies:

We provide a jupyter notebook for an illustration of a robust strategy for computing Shapley values:

Examples

Explanation with Shapley values

import numpy as np
import joblib
from radshap.shapley import Shapley

model = joblib.load("trained_logistic_regression.joblib")
shap = Shapley(predictor = lambda x: model.predict_proba(x)[:, 1], aggregation = ('mean', None))
shapvalues = shap.explain(X) # X a 2D array of shape (n_instances, n_instance_features)

Robust explanation with Shapley values

import numpy as np
import joblib
from radshap.shapley import RobustShapley

model = joblib.load("trained_logistic_regression.joblib")
shap = RobustShapley(predictor = lambda x: model.predict_proba(x)[:, 1],
                     aggregation = ('nanmean', None),
                     background_data = Xback) # Xback a 2D array of shape (n_samples_background, n_input_features)
shapvalues = shap.explain(X) # X a 2D array of shape (n_instances, n_instance_features)

License

This project is licensed under a custom open-source license (see the LICENSE.md file for more details).

Acknowledgements

This package was created as a part of the PhD project of Nicolas Captier in the Laboratory of Translational Imaging in Oncology (LITO) of Institut Curie.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

radshap-0.0.1.tar.gz (15.6 kB view hashes)

Uploaded Source

Built Distribution

radshap-0.0.1-py3-none-any.whl (16.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page