Skip to main content

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.

Metadata

Release files for radshap 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for radshap 0.0.1
File Size Uploaded Provenance
radshap-0.0.1.tar.gz 15.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for radshap 0.0.1
File Interpreter ABI Platform
radshap-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 32.0 kB

Release files / radshap-0.0.1.tar.gz

Download URL radshap-0.0.1.tar.gz
Size 15.6 kB
Tags Source
SHA-256 checksum
How to use checksums
cc4cfa9c5102d13787ea922661dcbeb711eb1f833cae5d8fbff84a88be63cdc2
BLAKE2b-256 checksum
How to use checksums
6e658187bb88b65a7c7da248c614a1bea70de606775534012f917fd3fcd6df06
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.7

Release files / radshap-0.0.1-py3-none-any.whl

Download URL radshap-0.0.1-py3-none-any.whl
Size 16.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d7e0610c39b55785248ae8b6733c0987f8ea671921da7aef94f41c5d77fd11d6
BLAKE2b-256 checksum
How to use checksums
fd4751d2b4bccc033a0a22a83459643297bb81f32c20ccfdd18d019b1271d3c4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.7

Security for radshap 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page