SHAP Interaction Values decompose a model's prediction into contributions from individual features and all pairwise feature interactions, ensuring the sum of all main effects and interaction effects equals the difference between the prediction and the baseline. This is achieved by extending the Shapley value from cooperative game theory to a Shapley-Taylor index, which allocates credit fairly among coalitions of features. The resulting interaction matrix quantifies the synergistic or antagonistic effect between any two features for a specific prediction.
Glossary
SHAP Interaction Values

What is SHAP Interaction Values?
SHAP Interaction Values extend the standard SHAP framework to capture pairwise feature interaction effects by distributing credit among all pairs of features, not just individual features.
Computationally, exact interaction values require evaluating the model on all subsets of features, which is exponentially expensive. TreeSHAP provides an exact, polynomial-time algorithm for tree-based models by exploiting their internal structure. For other model types, approximations are necessary. A SHAP Dependence Plot visualizes these interactions by coloring points by a second feature, revealing how the relationship between a feature's value and its SHAP value changes depending on the interacting feature's state.
Key Properties of SHAP Interaction Values
SHAP Interaction Values extend the standard additive SHAP framework by decomposing a model's prediction into main effects and pairwise interaction effects, revealing how features work together to influence outputs.
Symmetry of Interactions
The interaction value between feature i and feature j is symmetric, meaning Φ_{i,j} = Φ_{j,i}. This property ensures that the captured interaction effect is a shared, undirected contribution. The total interaction effect is split equally between the two features in the decomposition, preventing double-counting and providing a consistent attribution of the joint effect.
Efficiency with Interactions
The sum of all main effects and all pairwise interaction effects exactly equals the difference between the model's prediction f(x) and the baseline value. This extends the standard SHAP efficiency property:
- Main effects capture independent feature contributions
- Interaction effects capture the remaining joint contributions
- The decomposition is exhaustive with no unexplained residual
Interaction Detection via Dependence Plots
SHAP dependence plots reveal interactions through vertical dispersion. When a scatter plot of feature value vs. SHAP value shows spread rather than a clean curve, an interaction is present. Coloring points by a second feature's value exposes the interacting variable:
- Clustered colors indicate strong interaction
- Vertical spread at fixed x quantifies interaction magnitude
- Enables discovery of non-linear feature synergies
Combinatorial Foundation
Interaction values are computed by considering all coalitions of features that exclude both feature i and feature j. The interaction effect is the marginal contribution of adding the pair together, minus their individual marginal contributions. This requires evaluating the model on 2^(M-2) subsets for M features, making exact computation exponentially expensive and necessitating sampling approximations.
Zero Interaction Under Independence
If two features contribute to the model's output completely independently—meaning their joint effect equals the sum of their individual effects—their SHAP interaction value is zero. This property makes interaction values a precise detector of non-additive model behavior, distinguishing between models that treat features independently and those that learn complex feature conjunctions.
TreeSHAP Interaction Computation
For tree-based models, TreeSHAP computes exact interaction values in O(TLD^2) time, where T is the number of trees, L is the maximum number of leaves, and D is the maximum tree depth. The algorithm tracks how pairs of features are split across tree paths simultaneously, avoiding the exponential complexity of model-agnostic methods and providing exact, deterministic interaction matrices.
Frequently Asked Questions
Clear, technically precise answers to the most common questions about capturing and interpreting pairwise feature interactions using the SHAP framework.
SHAP interaction values are an extension of the standard SHAP framework that decompose a model's prediction not only into main effects for individual features but also into pairwise interaction effects between features. While a standard SHAP value distributes the prediction credit among N features, SHAP interaction values distribute the credit among all N × N feature pairs, represented as a matrix Φ[i, j]. The diagonal elements Φ[i, i] represent the main effect of feature i, and the off-diagonal elements Φ[i, j] capture the residual interaction effect between feature i and feature j that remains after accounting for their individual main effects. This decomposition is guaranteed by the Shapley-Taylor interaction index, which extends the game-theoretic axioms of efficiency, symmetry, and linearity to interactions. The total prediction is reconstructed as the sum of all matrix elements: f(x) = baseline + Σ_i Σ_j Φ[i, j].
SHAP Interaction Values vs. Other Interaction Methods
Comparing SHAP Interaction Values against alternative methods for detecting and quantifying pairwise feature interactions in machine learning models.
| Feature | SHAP Interaction Values | Friedman's H-Statistic | Partial Dependence Interactions |
|---|---|---|---|
Theoretical Foundation | Game-theoretic Shapley values | Variance decomposition | Partial dependence function differences |
Captures Directionality | |||
Model-Agnostic | |||
Handles Correlated Features | |||
Computational Complexity | O(M^2 * 2^M) exact | O(M^2) with sampling | O(M^2) grid evaluations |
Provides Instance-Level Interactions | |||
Decomposes Prediction Additively | |||
Visualization Support | Dependence plots, summary plots | Bar charts, heatmaps | 2D partial dependence plots |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
Master the core concepts surrounding SHAP interaction values, which decompose a prediction into not just main effects but also the pure pairwise synergies between features.
Shapley-Taylor Index
The mathematical generalization of SHAP interaction values to arbitrary orders of feature interactions. While standard SHAP values capture main effects and pairwise interactions, the Shapley-Taylor index quantifies the importance of interactions among any specified number of features (e.g., three-way or four-way interactions).
- Order 1: Equivalent to standard Shapley values (main effects).
- Order 2: Equivalent to SHAP interaction values (pairwise effects).
- Higher Orders: Captures complex synergistic effects in deep models.
This framework allocates credit fairly among all interaction sets, ensuring the efficiency property holds at each interaction order.
SHAP Dependence Plot
The primary visualization for detecting and analyzing SHAP interaction values. This scatter plot displays a feature's value on the x-axis against its SHAP value on the y-axis, with an optional color axis for a second interacting feature.
- Vertical dispersion at a given x-value indicates interaction effects—if no interactions existed, all points would lie on a single curve.
- Color gradients reveal the direction of the interaction: a systematic shift from blue to red shows how the interacting feature modulates the main effect.
- Pattern recognition: Clustered color bands suggest threshold interactions where the effect of one feature flips based on another's value.
Coalitional Game Theory
The mathematical foundation underlying SHAP interaction values. In cooperative game theory, the Shapley value answers how to fairly distribute a coalition's total payout among players. SHAP extends this by treating features as players and the model prediction as the payout.
For interaction values, the game is reformulated to consider pairs of players joining coalitions together, measuring their joint marginal contribution beyond their individual effects.
- Coalition: A subset of features present in the model.
- Characteristic function: The model's prediction given a specific feature subset.
- Marginal contribution: The change in prediction when a feature pair joins a coalition.
TreeSHAP Interaction Algorithm
A highly optimized algorithm that computes exact SHAP interaction values for tree-based models in O(TLD^2) time, where T is the number of trees, L is the maximum number of leaves, and D is the maximum tree depth.
Unlike model-agnostic methods that require sampling, TreeSHAP exploits the internal structure of decision trees:
- It tracks how pairs of features split the data down each tree path.
- It computes the conditional expectation of the model output given any feature subset analytically.
- It produces exact values without sampling variance, making it the gold standard for XGBoost, LightGBM, and random forest models.
Pure Interaction vs. Total Effect
A critical distinction in SHAP interaction values is decomposing a feature's total effect into its main effect and its pure interaction effects.
- Main effect: The isolated contribution of a feature, averaged over all possible values of other features.
- Pure interaction effect: The additional contribution arising specifically from the synergy between two features, beyond the sum of their individual main effects.
- Total effect: The sum of the main effect and all interaction effects involving that feature.
The SHAP interaction value matrix is symmetric, with diagonal entries representing main effects and off-diagonal entries representing pure pairwise interactions.
Interaction Value Matrix
The output structure of SHAP interaction values is an M×M matrix for each prediction, where M is the number of features. This matrix decomposes the prediction into additive components:
- Diagonal elements (Φᵢ,ᵢ): The main effect of feature i, representing its contribution in isolation.
- Off-diagonal elements (Φᵢ,ⱼ): The pure interaction effect between features i and j, split equally between them.
- Sum property: The total prediction equals the baseline plus the sum of all matrix elements.
This matrix can be aggregated across instances to produce a global interaction summary, revealing which feature pairs consistently interact across the dataset.

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us