Abstract
The Shapley Value (SV) is a cornerstone of feature attribution in machine learning, yet it often fails to capture how features interact to produce a prediction. We present shapiq, an open-source Python library that enables the computation and visualization of any-order Shapley Interactions (SIs). By providing a unified interface for 14 approximation algorithms and a comprehensive benchmarking suite of over 2,000 pre-computed games, shapiq facilitates both research and practical application of high-order feature interactions across diverse ML domains.
Introduction
While feature attribution methods like SV identify which features contribute to a model's output, they often obscure the underlying synergies and redundancies. For instance, in spatial data, individual coordinates may have limited meaning compared to their joint interaction. Shapley Interactions extend the SV framework to groups of features, but their exponential computational complexity has historically limited their use. shapiq addresses this by consolidating fragmented algorithms and providing tools to make high-order interactions interpretable.
The shapiq Framework
shapiq is designed as a modular ecosystem for game-theoretic model explanations. It supports tree-based models, model-agnostic tabular data, and arbitrary value functions.
The library includes:
- Unified Approximator Interface: Implements 14 methods, including SHAP-IQ, SVARM-IQ, and KernelSHAP-IQ, allowing for direct comparison of algorithm performance.
- Specialized Explainers: Features
TreeSHAP-IQfor efficient processing of tree ensembles (e.g., XGBoost, LightGBM) andTabularExplainerfor model-agnostic explanations. - Exact Computer: Provides ground-truth values for 18 game-theoretic concepts for small-scale validation.
- Visualization Suite: Offers network plots and bar charts to translate high-order interactions into human-readable insights.
Benchmarking and Datasets
To accelerate research, shapiq includes a massive benchmarking suite covering 11 machine learning domains, including local/global XAI, data valuation, and uncertainty quantification. The library leverages five primary real-world datasets: AdultCensus, BikeSharing, CaliforniaHousing, MovieReview, and ImageClassification. A key contribution is the provision of 2,042 pre-computed game configurations with ground-truth values, significantly reducing the computational burden for researchers developing new approximation techniques.
Key Insights and Results
Empirical evaluation using shapiq reveals several critical insights into model behavior and explanation quality:
- The Pairwise Jump: Moving from 1st-order (SV) to 2nd-order (pairwise) interactions significantly improves the "faithfulness" of an explanation—the degree to which it accurately reflects the model's internal logic.
- Domain-Specific Algorithm Performance: No single approximation algorithm dominates. Kernel-based methods are often superior for local XAI, while stratification-based methods like SVARM-IQ perform better in data valuation tasks.
- Faithfulness vs. Complexity: Higher interaction orders increase explanation faithfulness but also complexity.
shapiqallows users to identify the optimal order for their specific application.
The library's versatility is demonstrated across architectures ranging from decision trees to Vision Transformers. For example, network plots can reveal how a model's prediction for an image is driven by the interaction between specific visual patches.
Limitations and Future Directions
While shapiq provides a powerful toolkit, challenges remain. The current Python implementation of TreeSHAP-IQ could be further optimized with C++ for greater speed. Additionally, as interaction orders increase, there is a risk of "information overload" for human users. Future work should focus on human-centric evaluations to determine how these complex explanations best support practical decision-making and model debugging.
Summary updated