Skip to main content

uxplain

uxplain explains which features make a model more or less uncertain. It wraps scikit-learn compatible models with conformal prediction and uses SHAP, PDP/ICE or LIME to explain summaries of their prediction intervals or sets.

The package supports regression, through crepes and conformalized quantile regression (CQR), and classification, through crepes. A single pipeline handles model fitting, calibration and explanation.

Installation

Requires Python 3.10 or later.

pip install uxplain

Regression

Explain prediction interval width with SHAP. fit() automatically reserves a separate calibration sample.

from sklearn.datasets import make_regression
from sklearn.ensemble import RandomForestRegressor
from sklearn.model_selection import train_test_split
from uxplain import UncertaintyExplanationPipeline

X, y = make_regression(n_samples=300, n_features=4, noise=15, random_state=42)
X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42)

pipe = UncertaintyExplanationPipeline(
    model=RandomForestRegressor(n_estimators=50, random_state=42),
    confidence=0.9,
    xai_method="shap",
    uncertainty_metric="width",
    random_state=42,
)
pipe.fit(X_train, y_train)
result = pipe.explain(X_test[:5], show_plots=False)

print(result.interval_width)
print(result.explanation_values)

Classification

Use a classifier and set_size to explain how many labels enter the prediction set.

from sklearn.datasets import load_iris
from sklearn.ensemble import RandomForestClassifier

X, y = load_iris(return_X_y=True)
X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42)

pipe = UncertaintyExplanationPipeline(
    model=RandomForestClassifier(n_estimators=50, random_state=42),
    uncertainty_metric="set_size",
    random_state=42,
)
pipe.fit(X_train, y_train)
result = pipe.explain(X_test[:5], show_plots=False)

print(result.prediction_set)
print(result.explanation_values)

Learn more

The getting-started guide covers calibration, other uncertainty summaries and explainer options. See the notebooks for more examples and the release guide for development and publishing.

Coverage guarantees depend on the conformal method's statistical assumptions; they do not extend to the explanations themselves.

Authors

  • Tomas Rodriguez Taborda — Universidad Nacional de Colombia, Medellín
  • Veronica Seguro Varela — Universidad Nacional de Colombia, Medellín
  • Rafael Izbicki — Federal University of São Carlos
  • Johnatan Cardona Jimenez — Universidad Nacional de Colombia, Medellín

License

MIT.

Metadata

Release files for uxplain 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for uxplain 0.3.0
File Size Uploaded
uxplain-0.3.0.tar.gz 57.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for uxplain 0.3.0
File Interpreter ABI Platform
uxplain-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 108.0 kB

Release files / uxplain-0.3.0.tar.gz

Download URL uxplain-0.3.0.tar.gz
Size 57.9 kB
Tags Source
SHA-256 checksum
How to use checksums
634249b8f4ddc7c7cf11789c96c2d487ee88d0ad35cfa7efe3f5c5fd663b649f
BLAKE2b-256 checksum
How to use checksums
91468e140780f0fe17c597007f83bbe2802d0b8256b0ed14132b6011d8843bf9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.2

Release files / uxplain-0.3.0-py3-none-any.whl

Download URL uxplain-0.3.0-py3-none-any.whl
Size 50.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bf38268869db5c7072d4446755609bdb1d55bdc3f14d4cfe7a55a93085af7027
BLAKE2b-256 checksum
How to use checksums
c098d748df73575aa83b5c410adf4eb6c0cf56bf23f4bfe399b25d5ddc7294b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.2

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release 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