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

Uploaded Source

Built Distribution

tinyshap-0.1.0-py3-none-any.whl (4.6 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