Skip to main content

tinyshap

Package version Supported Python versions

A minimal implementation of the SHAP algorithm using the KernelSHAP method. In less then 100 lines of code, this repo serves as an educational resource to understand how SHAP works without all the complexities of a production-level package.

Installation

pip install tinyshap

Example usage

from tinyshap import SHAPExplainer

# Train model
model = GradientBoostingRegressor()
model.fit(X_train, y_train)

# Explain predictions
explainer = SHAPExplainer(model.predict, X=X_train.mean().to_frame().T)
contributions = explainer.shap_values(X)

See complete notebook

Resources

Licence

MIT

Metadata

Release files for tinyshap 0.1.0

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

Source distribution (sdist)

Source distribution for tinyshap 0.1.0
File Size Uploaded
tinyshap-0.1.0.tar.gz 5.2 kB Details

Built distribution (wheel)

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

Total release size: 9.7 kB

Release files / tinyshap-0.1.0.tar.gz

Download URL tinyshap-0.1.0.tar.gz
Size 5.2 kB
Tags Source
SHA-256 checksum
How to use checksums
2f72c7e2a6630bb595f9a34fb7d1838bcf37b23b21bc6e2896568fa66f0f4bf3
BLAKE2b-256 checksum
How to use checksums
09d314c23684538d0243ffbe569db81a7553b4d064762b7a19e770b99a633d80
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release files / tinyshap-0.1.0-py3-none-any.whl

Download URL tinyshap-0.1.0-py3-none-any.whl
Size 4.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6b45903a4987bda1d7b3648ea569a3306da45d9c827f2c1674799a7b427289a4
BLAKE2b-256 checksum
How to use checksums
3bc890f9179c4bc233554829c82b108dfa0865ea4cbb1a9795a67829489b0b5d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.1

2 release files

0.0.0

2 release files

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