Skip to main content

TrustXAI: Diagnostic Benchmark Suite for Explainable AI

CI Python 3.10+ License: MIT

A diagnostic benchmark framework to audit machine learning models for Explanation Fragility, Statistical Uncertainty, and Out-of-Distribution (OOD) Vulnerability.


Key Pillars

  1. Explanation Fragility: Evaluates local Lipschitz sensitivity ($L_E$) under bounded perturbations ($\epsilon$-ball) to verify whether attribution vectors remain stable.
  2. Conformal Uncertainty Guarantees: Constructs non-empty prediction sets $C(x)$ using finite-sample distribution-free bounds guaranteeing: $$P(Y \in C(X)) \ge 1 - \alpha$$
  3. Out-of-Distribution Auditing: Rejects uncalibrated inferences on distributional shifts.
  4. Unified Trust Index (UTI): A composite metric classifying each instance as:
    • CERTIFIED: Stable explanation, valid conformal coverage, in-distribution.
    • FRAGILE: Confident prediction but unstable feature attributions.
    • AMBIGUOUS_OR_OOD: Prediction set exceeds single label or out-of-distribution.

Quickstart

Installation

git clone [https://github.com/mariam851/trustxai.git](https://github.com/mariam851/trustxai.git)
cd trustxai
pip install -e .[explainers]

Usage Example

from trustxai.core.benchmark import TrustBenchmark
from trustxai.explainers.wrappers import ShapWrapper
from trustxai.reporting.latex import AcademicReporter

# 1. Initialize explainer and diagnostic benchmark
explainer = ShapWrapper(model=model, explainer_type="tree", target_class=1)
benchmark = TrustBenchmark(
    explainer=explainer,
    alpha=0.10,          # 90% confidence target
    epsilon=0.05,        # 5% perturbation radius
    lipschitz_threshold=1.5
)

# 2. Conformal calibration on validation holdout
benchmark.calibrate(X_train=X_train, probs_cal=probs_cal, y_cal=y_cal)

# 3. Audit test data
results = benchmark.audit(X_test=X_test, probs_test=probs_test)

# 4. Generate publication-ready LaTeX table
latex_code = AcademicReporter.generate_summary_table({"Random Forest": results})
print(latex_code)

Benchmark Metrics & Interpretation

TrustXAI decomposes model trustworthiness into reproducible diagnostic indicators:

Status Mathematical Condition Interpretation
CERTIFIED $L_E \le \tau$, $\Vert{}C(x)\Vert{} = 1$, $D_{OOD}(x) \le 1.0$ Reliable prediction, bounded attribution shift, calibrated.
FRAGILE $L_E > \tau$, $\Vert{}C(x)\Vert{} = 1$, $D_{OOD}(x) \le 1.0$ Prediction is confident, but explanation flips under perturbation.
AMBIGUOUS_OR_OOD $\Vert{}C(x)\Vert{} > 1$ or $D_{OOD}(x) > 1.0$ High statistical uncertainty or shifted sample; explanations rejected.

Running Test Suite

Verify complete test coverage and stress resilience across all diagnostic layers:

# Run unit & stress tests with coverage report
pytest tests/ -v --cov=trustxai --cov-report=term-missing

Citation

If you use TrustXAI in your academic research or benchmarking pipelines, please cite:

@software{trustxai2026,
  author = {Mariam Zakaria},
  title = {TrustXAI: A Diagnostic Benchmark Suite for Auditing Explanation Stability and Conformal Uncertainty Guarantees},
  url = {[https://github.com/mariam851/trustxai](https://github.com/mariam851/trustxai)},
  year = {2026}
}

License

This project is open-sourced under the MIT License.

Metadata

Release files for trustxai 0.1.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 trustxai 0.1.0
File Size Uploaded
trustxai-0.1.0.tar.gz 16.9 kB Details

Built distribution (wheel)

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

Total release size: 34.1 kB

Release files / trustxai-0.1.0.tar.gz

Download URL trustxai-0.1.0.tar.gz
Size 16.9 kB
Tags Source
SHA-256 checksum
How to use checksums
a94ab6c4022fcf0074bb370b1d7998bd86d8d6c78a23b0e761d60630ea6bc2dd
BLAKE2b-256 checksum
How to use checksums
2caede8374cf8167335ed6e3c0176579b92f4683ada99310923933b2ea3f7969
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.5

Release files / trustxai-0.1.0-py3-none-any.whl

Download URL trustxai-0.1.0-py3-none-any.whl
Size 17.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
07ccd9807d5f7ef71c56f61910c8a5cbba6a7e2445957ea78b73ddb6d08b43c9
BLAKE2b-256 checksum
How to use checksums
d0f324210a9b44815fbb2dacd290fefcbd9141983a7218b195a4c95afdb54389
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.5

Release history Release notifications | RSS feed

This release

0.1.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