Skip to content

Python package providing a minimal implementation of the SHAP algorithm using the Kernel method

License

Notifications You must be signed in to change notification settings

tsitsimis/tinyshap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Python package providing a minimal implementation of the SHAP algorithm using the Kernel method

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published