tinyshap
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)
| File | Size | Uploaded | |
|---|---|---|---|
| tinyshap-0.1.0.tar.gz | 5.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| 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
|