Registry / ai-ml / eli5
library0.16.0pypypi✓ verified 81d ago

eli5 (Explain Like I'm 5) is a Python library that helps to debug machine learning classifiers and explain their predictions. It provides a unified API for inspecting weights and predictions of various ML models, including scikit-learn, Keras, LightGBM, XGBoost, and more. The current version is 0.16.0. Development is active, with releases typically tied to feature development and bug fixes.

pip install eli5
INSTALL
IMPORT
SIG · ELI5
E
eli5
ai-mlpythonv0.16.0
Install
10.3s avg
Import
3976ms
Disk
284MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.16.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
build_error
glibc
py 3.103.920 runs
installs and imports cleanly · install 10.3s · import 3.976s · 273MB
284MB installed
● package 284MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

show_weights
from eli5 import explain_weights
from eli5 import show_weights
show_prediction
from eli5 import explain_prediction
from eli5 import show_prediction
format_as_text
from eli5 import format_as_text

This example demonstrates how to train a RandomForestRegressor on the California Housing dataset and then use `eli5.show_weights` to explain global feature importances and `eli5.show_prediction` to explain a specific prediction. Note the use of `feature_names` for clearer output.

import eli5 from sklearn.datasets import fetch_california_housing from sklearn.ensemble import RandomForestRegressor from sklearn.model_selection import train_test_split # Load a modern dataset with feature names housing = fetch_california_housing(as_frame=True) X, y = housing.data, housing.target X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42) # Train a simple model model = RandomForestRegressor(random_state=42, n_estimators=10) model.fit(X_train, y_train) print("\n--- Feature Importances (Weights) ---") # Explain feature importances (weights) # In a Jupyter notebook, this would render as HTML. # For console output, the string representation is printed. print(eli5.show_weights(model, feature_names=X.columns.tolist())) print("\n--- Prediction Explanation for First Test Sample ---") # Explain a single prediction print(eli5.show_prediction(model, X_test.iloc[0], feature_names=X.columns.tolist()))
Debug
Known issues
breakingThe old backend-specific explanation functions like `eli5.sklearn.explain_weights` and `eli5.sklearn.explain_prediction` were removed and replaced by generic `eli5.show_weights` and `eli5.show_prediction`.
fix
Update your code to use `eli5.show_weights(...)` for global explanations and `eli5.show_prediction(...)` for individual predictions.
affects: <0.10.0 (removed in 0.10.0)
gotcha`eli5.show_weights` and `eli5.show_prediction` return `IPython.display.HTML` objects in Jupyter notebooks for rich display. In a standard Python console, a string representation (often HTML source) is printed. If you need programmatic access (e.g., as a DataFrame or plain text), you must explicitly use formatters.
fix
For DataFrame output: `from eli5.formatters import as_dataframe; df = as_dataframe(eli5.show_weights(...))`. For plain text: `from eli5.formatters import as_text; text = as_text(eli5.show_weights(...))`.
affects: All versions
gotchaMany `scikit-learn` datasets (e.g., `load_boston`) are deprecated or removed in newer `scikit-learn` versions (1.2+). Code relying on these datasets will cause `ImportError` or `FutureWarning`.
fix
Use modern datasets like `fetch_california_housing` or `load_diabetes` (the non-deprecated version) for compatibility.
affects: scikit-learn >= 1.2.0 (affects examples using old datasets)
Upgrade
Version history
0.16.0latest on PyPI · released Apr 20, 2025
Audit
Dependencies
numpyrequiredCore numerical operations for array handling.
scipyrequiredScientific computing functionalities, used by various ML models and eli5 internally.
scikit-learnrequiredPrimary supported machine learning library for model explanations (required >=0.20).
pandasrequiredData manipulation, especially for handling DataFrames and feature names.
tabulaterequiredUsed for formatting tabular data output in text mode.
lightgbmoptionalOptional: Required for explaining LightGBM models. Install with `pip install eli5[lightgbm]`.
xgboostoptionalOptional: Required for explaining XGBoost models. Install with `pip install eli5[xgboost]`.
kerasoptionalOptional: Required for explaining Keras/TensorFlow models. Install with `pip install eli5[keras]`.
Agent activity
37 hits · last 30 days
node
36
OpenAI (training)
1
Resources
eli5 — pip install eli5 · libregistry