Introduction
The rapid adoption of complex "black box" machine learning models, such as Deep Neural Networks, has necessitated the development of post-hoc explanation methods like SHAP and LIME. However, a significant "evaluation gap" exists: while these tools generate explanations, they often lack the quantitative metrics required to verify their reliability. In high-stakes domains like healthcare and finance, an unverified explanation can be as dangerous as no explanation at all. xai_evals is an open-source Python framework designed to bridge this gap by providing a unified interface for both generating and benchmarking local explanations.
The xai_evals Framework
The xai_evals library is structured to handle diverse data types and model architectures. It acts as a wrapper across common machine learning stacks, including Scikit-Learn, XGBoost, PyTorch, and TensorFlow.
As shown in the architecture, the framework bifurcates workflows based on data type (Tabular or Image) and model category (Machine Learning vs. Deep Learning). This standardization allows for a consistent API regardless of the underlying model implementation.
Core Pillars: Illustration and Evaluation
The functionality of xai_evals rests on two main pillars: Illustration (the generation of feature attributions) and Evaluation (the quantification of explanation quality).
1. Illustration (Generation)
The framework integrates popular local explanation methods such as SHAP, LIME, Grad-CAM, and Integrated Gradients, alongside newer methods like DlBacktrace. It supports models from major frameworks, ensuring broad applicability.
2. Evaluation (Metrics)
The core contribution of xai_evals is its suite of quantitative metrics designed to assess the truthfulness of an explanation:
- Faithfulness: Measures how well the attribution aligns with changes in model output when features are perturbed.
- Sensitivity/Robustness: Checks if the explanation remains stable when small amounts of random noise are added to the input.
- Comprehensiveness & Sufficiency: Evaluates if the "important" features identified are truly necessary and sufficient for the model to make its prediction.
- Complexity & Sparseness: Quantifies how "readable" an explanation is by measuring how many features are assigned non-zero importance.
Benchmarking and Results
The framework's utility was demonstrated using standard benchmarks: the IRIS dataset for tabular data (Random Forest) and Imagenette for image data (ResNet18).
In tabular evaluations, the framework revealed critical insights that qualitative inspection might miss. For instance, a SHAP attribution on the IRIS dataset showed high Monotonicity (0.97) but negative Faithfulness (-0.56). Such a discrepancy alerts practitioners that the explanation may not accurately reflect the model's internal logic for that specific instance. In image tasks, the framework calculated Mean Pixelwise Robustness (MPRT) for Grad-CAM heatmaps, helping to distinguish stable features from visual artifacts.
Conclusion and Future Directions
xai_evals provides the "audit trail" necessary for regulatory compliance with frameworks like the EU AI Act and GDPR, which grant individuals a "right to explanation." By standardizing the evaluation of interpretability, it moves the field toward more trustworthy AI. Future work will focus on expanding support to Natural Language Processing (NLP) and Graph Neural Networks (GNNs), as well as implementing GPU acceleration to handle the computational overhead of perturbation-based metrics.
Summary updated