Skip to main content

PyInterpret: A Unified Python Library for Machine Learning Model Interpretation

Python Version License: MIT

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

pyinterpret-0.1.1.tar.gz (353.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyinterpret-0.1.1-py3-none-any.whl (31.9 kB view details)

Uploaded Python 3

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

Hashes for pyinterpret-0.1.1.tar.gz
Algorithm Hash digest
SHA256 1a6eaa39aa9d8017b2125c84185b9e870f8ed0ea35d97ae91ae551d65fff774d
MD5 d6230a53db4dbfc6a7dafe0aa11b65e7
BLAKE2b-256 00a4225145571cab032f97f1ad25e11fe0eb9a071c2baf22d0d0df4f7be87bbb

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyinterpret-0.1.1.tar.gz:

Publisher: publish.yml on mowne67/pyinterpret

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for pyinterpret-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b11128a1ed7887b8c69696bf85ae07e8af752f5ba0dc9c55eea239ad2ce0abf5
MD5 d0dfadea19832cc9473353f37fe74509
BLAKE2b-256 8c1291c6e7a953bf589f67dbb98a01f9b1c15789b41efbc05e72800bfc7a43e2

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyinterpret-0.1.1-py3-none-any.whl:

Publisher: publish.yml on mowne67/pyinterpret

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page