A model explainability toolkit with SHAP, LIME, scoring, summaries, and GUI sandbox
Project description
Model Explainability Toolkit
This toolkit provides SHAP and LIME-based explanations for scikit-learn models, along with visualization tools.
Features
- SHAP and LIME explainers
- Feature importance plots
- Modular design for easy extension
Installation
Install via pip:
pip install model-explain
API Reference
shap_explainer.shap_explainer(model, X)
Generates SHAP explanations for a fitted scikit-learn model.
model: Trained scikit-learn estimatorX: DataFrame of input features
lime_explainer.lime_explainer(model, X)
Generates LIME explanations for a fitted scikit-learn model.
model: Trained scikit-learn estimatorX: DataFrame of input features
Example
from model_explain.explainers import shap_explainer
from sklearn.ensemble import RandomForestClassifier
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
import pandas as pd
# Load data
data = load_iris()
X = pd.DataFrame(data.data, columns=data.feature_names)
y = pd.Series(data.target)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
# Train model
my_model = RandomForestClassifier()
my_model.fit(X_train, y_train)
# Explain model
shap_explainer.shap_explainer(my_model, X_test)
Usage
See examples/demo_notebook.ipynb for a walkthrough.
Support
For questions or issues, open an issue on GitHub or email the maintainer.
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
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 model_explain-0.2.0.tar.gz.
File metadata
- Download URL: model_explain-0.2.0.tar.gz
- Upload date:
- Size: 11.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e6e3f1a42aba383740ffc9bd4c3f17bbe04a1980e8f8808c4d469b06b4098f4c
|
|
| MD5 |
187e6f697c7e9e351e2a9a2bf62120df
|
|
| BLAKE2b-256 |
8f0fc1f92bbfb92201e3e2ec48f5615ba48c8b98b780e5f207a5b84af8b074ae
|
File details
Details for the file model_explain-0.2.0-py3-none-any.whl.
File metadata
- Download URL: model_explain-0.2.0-py3-none-any.whl
- Upload date:
- Size: 15.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d4b7042e9cc7ac6ce31485b69c2c3b7126574fdc59ce26a9e57f2baf56f6d03a
|
|
| MD5 |
1a814b21d7b4883412208f6fc2d1f800
|
|
| BLAKE2b-256 |
47d1e7d69f47b568749ebe9856ef34b9f366017f056998466c09478156dee6e8
|