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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

Details for the file radshap-0.0.1.tar.gz.

File metadata

  • Download URL: radshap-0.0.1.tar.gz
  • Upload date:
  • Size: 15.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.7

File hashes

Hashes for radshap-0.0.1.tar.gz
Algorithm Hash digest
SHA256 cc4cfa9c5102d13787ea922661dcbeb711eb1f833cae5d8fbff84a88be63cdc2
MD5 3dcde6690a792a273951116694ddc473
BLAKE2b-256 6e658187bb88b65a7c7da248c614a1bea70de606775534012f917fd3fcd6df06

See more details on using hashes here.

File details

Details for the file radshap-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: radshap-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 16.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.7

File hashes

Hashes for radshap-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d7e0610c39b55785248ae8b6733c0987f8ea671921da7aef94f41c5d77fd11d6
MD5 03dd77af4edb58eda9ebd8d0e9999edf
BLAKE2b-256 fd4751d2b4bccc033a0a22a83459643297bb81f32c20ccfdd18d019b1271d3c4

See more details on using hashes here.

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