Feature Interaction
An electric car may add $20,000. A luxury brand may add $40,000. If an electric luxury car adds $70,000, the extra $10,000 is an interaction.
Interactions matter because a feature's effect can depend on the value of another feature.
Find the Missing Cell
Set three car prices and compare the observed electric-luxury price with the price an additive model would predict.
Base
$30k
Additive expectation
$90k
Observed joint price
$100k
Interaction
+$10k
We use Friedman's H-statistic (2008) to measure feature interaction. There are two variants: the two-way H-statistic, which measures the interaction between two features and , and the total H-statistic, which measures the interaction between and all other features combined.
The math: H-statistic
At each data point, partial dependence is evaluated over all data points.
Two-way H-statistic (j vs. k):
Total H-statistic (j vs. all):
Partial dependence shows the effect of one or more features on the predicted outcome while averaging out all other features — the average effect of a feature on predictions, holding everything else constant.
Sound familiar?
Partial dependence is the average of ICE plots, which you saw in the Local Explanations chapter.
Computational cost is a real concern for feature interaction in practice:
- Two-way H-statistic (j vs. k) requires up to calls to the model's predict function in the worst case.
- Total H-statistic (j vs. all) requires up to calls.
- To speed things up, we can sample from the data points — but this increases the variance of the partial dependence estimates, which can make the H-statistic unstable.
Interpreting the H-statistic
Interpreting the H-statistic can be challenging, but the standard interpretation is:
- H-statistic = 0: No interaction between the features.
- Total H-statistic = 1: All variance of the function is explained by the sum of the individual partial dependence functions.
- Two-way H-statistic = 1: Each single PD function is constant — the effect on the prediction comes entirely through the interaction.
Interaction measures can be computationally heavy and unstable. Correlated features also create the same unrealistic combinations that trouble PDPs.
Use a statistic to rank candidate interactions, then inspect the underlying surface and the data density before writing a story about it.
Why should a high interaction score be followed by a data-density check?