FeatureInteractionExplainer<T>

Models & Types · AiDotNet.Interpretability.Explainers

Model-agnostic Feature Interaction detector using Friedman’s H-statistic.

Implements: IGlobalExplainer<T, FeatureInteractionResult<T>>

For Beginners

The H-statistic measures how much features interact with each other.

What is a feature interaction?

  • When the effect of one feature depends on the value of another feature
  • Example: “Education increases salary, but more so for people with more Experience”
  • This means Education and Experience interact

How to interpret H-statistic values:

  • H = 0: No interaction (features act independently)
  • H = 1: Pure interaction (entire effect comes from interaction)
  • H between 0 and 1: Partial interaction

Typical thresholds:

  • H < 0.05: Negligible interaction
  • H 0.05-0.20: Weak interaction
  • H 0.20-0.50: Moderate interaction
  • H > 0.50: Strong interaction

This implementation computes:

  1. Pairwise H-statistics (between two specific features)
  2. Overall H-statistic (one feature vs all others)

Constructors

Constructor Summary
FeatureInteractionExplainer(Func<Matrix<T>, Vector<T>> predictFunction, Matrix<T> data, int gridSize, string[] featureNames) Initializes a new Feature Interaction explainer.

Properties

Property Summary
bool SupportsGlobalExplanations { get; }
bool SupportsLocalExplanations { get; }
string MethodName { get; }

Methods

Method Summary
FeatureInteractionResult<T> ExplainGlobal(Matrix<T> data)
List<ValueTuple<int, int, T>> GetTopInteractions(int topK) Gets the top interacting feature pairs.
T ComputeOverallHStatistic(int featureIndex) Computes the overall H-statistic for a single feature vs all others.
T ComputePairwiseHStatistic(int feature1Index, int feature2Index) Computes the pairwise H-statistic between two features.