PyInterpret: A Unified Python Library for Machine Learning Model Interpretation
PyInterpret is a comprehensive Python library that unifies fragmented explainability tools under one consistent API. It provides modular coverage of both global and local explanations across different data modalities, consolidating capabilities from state-of-the-art tools like SHAP, LIME, and others.
🎯 Key Features
- Unified API: Consistent interface across all interpretation methods
- Local Attribution: SHAP, LIME, and other instance-level explanations
- Global Insights: Permutation importance, partial dependence plots
- Modular Architecture: Easy extension and customization
- Multiple Data Types: Support for tabular, text, image, and time-series data
- Framework Integration: Works seamlessly with scikit-learn, pandas, and other ML libraries
- Professional Quality: Comprehensive testing, documentation, and error handling
🚀 Quick Start
Installation
# Basic installation
pip install pyinterpret
# With SHAP support
pip install pyinterpret[shap]
# With LIME support
pip install pyinterpret[lime]
# With all optional dependencies
pip install pyinterpret[all]
Basic Usage
from pyinterpret import SHAPExplainer, LIMEExplainer, PermutationImportanceExplainer
from sklearn.ensemble import RandomForestClassifier
from sklearn.datasets import make_classification
import pandas as pd
# Create sample data and train model
X, y = make_classification(n_samples=1000, n_features=10, random_state=42)
X_df = pd.DataFrame(X, columns=[f'feature_{i}' for i in range(X.shape[1])])
model = RandomForestClassifier(random_state=42)
model.fit(X_df, y)
# Local explanation with SHAP
shap_explainer = SHAPExplainer(model, explainer_type='tree')
shap_result = shap_explainer.explain_instance(X_df.iloc[0])
print("SHAP attributions:", shap_result.attributions)
print("Feature names:", shap_result.feature_names)
# Global explanation with Permutation Importance
perm_explainer = PermutationImportanceExplainer(model, scoring='accuracy')
perm_result = perm_explainer.explain_global(X_df, y)
print("Most important features:", perm_result.feature_names[:5])
print("Importance scores:", perm_result.attributions[:5])
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyinterpret-0.1.1.tar.gz.
File metadata
- Download URL: pyinterpret-0.1.1.tar.gz
- Upload date:
- Size: 353.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1a6eaa39aa9d8017b2125c84185b9e870f8ed0ea35d97ae91ae551d65fff774d
|
|
| MD5 |
d6230a53db4dbfc6a7dafe0aa11b65e7
|
|
| BLAKE2b-256 |
00a4225145571cab032f97f1ad25e11fe0eb9a071c2baf22d0d0df4f7be87bbb
|
Provenance
The following attestation bundles were made for pyinterpret-0.1.1.tar.gz:
Publisher:
publish.yml on mowne67/pyinterpret
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyinterpret-0.1.1.tar.gz -
Subject digest:
1a6eaa39aa9d8017b2125c84185b9e870f8ed0ea35d97ae91ae551d65fff774d - Sigstore transparency entry: 2617618246
- Sigstore integration time:
-
Permalink:
mowne67/pyinterpret@e8bc986a02a0e4aa67e24cfe61a59bcc57aa1033 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/mowne67
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e8bc986a02a0e4aa67e24cfe61a59bcc57aa1033 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pyinterpret-0.1.1-py3-none-any.whl.
File metadata
- Download URL: pyinterpret-0.1.1-py3-none-any.whl
- Upload date:
- Size: 31.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b11128a1ed7887b8c69696bf85ae07e8af752f5ba0dc9c55eea239ad2ce0abf5
|
|
| MD5 |
d0dfadea19832cc9473353f37fe74509
|
|
| BLAKE2b-256 |
8c1291c6e7a953bf589f67dbb98a01f9b1c15789b41efbc05e72800bfc7a43e2
|
Provenance
The following attestation bundles were made for pyinterpret-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on mowne67/pyinterpret
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyinterpret-0.1.1-py3-none-any.whl -
Subject digest:
b11128a1ed7887b8c69696bf85ae07e8af752f5ba0dc9c55eea239ad2ce0abf5 - Sigstore transparency entry: 2617618253
- Sigstore integration time:
-
Permalink:
mowne67/pyinterpret@e8bc986a02a0e4aa67e24cfe61a59bcc57aa1033 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/mowne67
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e8bc986a02a0e4aa67e24cfe61a59bcc57aa1033 -
Trigger Event:
release
-
Statement type: