Skip to main content

Minimal implementation of approximate Kernel SHAP algorithm

Project description

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

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

tinyshap-0.1.0.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

tinyshap-0.1.0-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file tinyshap-0.1.0.tar.gz.

File metadata

  • Download URL: tinyshap-0.1.0.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for tinyshap-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2f72c7e2a6630bb595f9a34fb7d1838bcf37b23b21bc6e2896568fa66f0f4bf3
MD5 82a5743055ea9a44203e1b00c0d7ffc7
BLAKE2b-256 09d314c23684538d0243ffbe569db81a7553b4d064762b7a19e770b99a633d80

See more details on using hashes here.

File details

Details for the file tinyshap-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: tinyshap-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for tinyshap-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6b45903a4987bda1d7b3648ea569a3306da45d9c827f2c1674799a7b427289a4
MD5 ed0e89e5cd42cbd7f9776203283ec278
BLAKE2b-256 3bc890f9179c4bc233554829c82b108dfa0865ea4cbb1a9795a67829489b0b5d

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