TL;DR
shapiq is a new open-source Python package that extends explainable AI beyond simple feature attributions by efficiently computing any-order Shapley Interactions. It unifies state-of-the-art approximation algorithms into an application-agnostic framework and provides a comprehensive benchmarking suite of 11 machine learning domains with pre-computed ground truths.
What Problem Does This Paper Address?
While the classic Shapley Value (SV) has become a cornerstone of machine learning interpretability (powering popular tools like shap), it suffers from a fundamental limitation: it treats features as independent contributors. In the real world, features act in synergy or redundancy—for example, knowing a house's latitude or longitude individually tells you very little, but knowing both together pinpoints its exact location.
Shapley Interactions (SIs) naturally extend SVs to capture these joint contributions among groups of entities. However, calculating SIs scales exponentially, making exact computation impossible for complex models. Until now, research into SIs has been fragmented, lacking a unified software ecosystem, standardized visualization tools, or a rigorous benchmarking framework to compare approximation algorithms across different machine learning tasks.
Methods
The authors introduce shapiq, an application-agnostic Python library designed to bridge the gap between game theory and practical machine learning.
The package is built around four core pillars:
- Unified Approximator Interface: Implements 7 state-of-the-art algorithms for approximating SIs (such as SHAP-IQ and SVARM-IQ) and 7 algorithms for standard SVs.
- Exact Computer: Provides exact calculations for 18 different interaction indices and game-theoretic concepts (e.g., Möbius interactions, Banzhaf values) for smaller feature sizes.
- Explanation API: Features
TabularExplainer(model-agnostic via marginal/conditional imputation) andTreeExplainer(leveraging the efficient TreeSHAP-IQ algorithm for tree ensembles like XGBoost and LightGBM). - Visualization Suite: Includes custom network plots to map out complex feature interactions visually.
Datasets
To rigorously evaluate SI algorithms, the authors established a benchmark suite spanning 11 distinct machine learning applications across 5 domains:
- Explainable AI (XAI): Local, Global, and Tree-based feature importance.
- Uncertainty Quantification: Explaining predictive entropy.
- Model Selection: Feature selection and ensemble selection.
- Valuation: Data valuation and dataset valuation.
- Unsupervised Learning: Cluster explanation and unsupervised feature importance.
These applications utilize five public datasets: AdultCensus (tabular classification), BikeSharing (tabular regression), CaliforniaHousing (spatial regression), MovieReview (IMDb text sentiment), and ImageClassification (ImageNet test subsets). Crucially, the authors pre-computed and shared exact ground-truth values for 2,042 benchmark game configurations, drastically reducing the computational barrier for future algorithmic research.
Key Insights and Ideas
- The Pairwise Power Jump: Moving from an explanation order of $k=1$ (standard SHAP feature attribution) to $k=2$ (pairwise interactions) provides a massive, non-linear boost in explanation faithfulness. For many real-world models, capturing just the pairwise interactions accounts for the vast majority of model synergy.
- No "One-Size-Fits-All" Approximator: The performance of approximation algorithms depends heavily on the underlying structure of the task.
- Kernel-based estimators (like KernelSHAP-IQ) dominate in local explanation tasks where sudden prediction jumps occur and coalition size doesn't strictly dictate the output value.
- Stratification-based estimators (like SVARM-IQ) excel in data valuation and ensemble selection, where the sheer size of the coalition (e.g., the number of training points or base learners) naturally dictates its worth.
Key Results
The authors conducted an extensive empirical evaluation across 100 unique benchmark games to validate the library's utility:
- Faithfulness Trade-off: As shown in the figure above, increasing the explanation order systematically improves the Shapley-weighted $R^2$ faithfulness metric, culminating in an exact decomposition at the highest order ($k=n$).
- Computational Sustainability: By providing pre-computed games for configurations up to $n=16$,
shapiqsaves researchers from executing up to $2^{16} = 65,536$ model evaluations per experiment run, ensuring highly reproducible and green benchmarking.
Limitations and Future Work
The authors highlight three main areas for improvement:
- Python Bottleneck: The current implementation of TreeSHAP-IQ is written in pure Python. Porting this to low-level languages like C++ (similar to the original TreeSHAP implementation) would yield significant speedups.
- Cognitive Overload: Visualizing higher-order interactions (beyond pairwise) remains a significant human-computer interaction challenge. Presenting too many interactions can overwhelm users, risking misinterpretation.
- Index Selection Guidance: With 18 different interaction indices available, practitioners face a steep learning curve in choosing the right mathematical concept for their specific application scenario.
Summary updated