A posthoc model-agnostic universal explainer for all machine learning models dealing with images that works in almost real-time is a long-lasting research effort in the image processing and computer vision community. One of the most stable and accurate solution is the KernelSHAP model that fulfills all the requirements but it is computationally intensive and resource‑demanding in practice. The method is based on the computation of Shapley values, and it has emerged as a principled approach for feature attribution in machine learning models, notably instantiated in the popular SHAP (SHapley Additive exPlanations) framework. However, the exact computation of the Shapley values is exponentially expensive, which motivated during time the development of faster approximation methods.
We introduce HarmonicSHAP, a completely different approach that uses spectral Fourier representations of the model to enable computations of the near-real-time Shapley value. Our framework is based on the inversion of a Gramian matrix arising from a chosen feature function basis, which yields a closed-form solution for Shapley values. We compare HarmonicSHAP to the well-known KernelSHAP and its subsequent accelerations versions in terms of computational complexity, implementation strategy, and performance. Our analysis shows that HarmonicSHAP can drastically reduce computations, applying a one-time model decomposition cost, enabling near real-time explanations even for complex models, while fulfilling the goal of remaining model agnostic and gradient independent.
