Implementation:Interpretml Interpret Measure Interactions
| Field | Value |
|---|---|
| Sources | InterpretML, FAST |
| Domains | Feature_Engineering, Interpretability |
| Last Updated | 2026-02-07 12:00 GMT |
Overview
Measure_Interactions is a concrete tool for measuring pairwise feature interaction strengths provided by the InterpretML library.
Description
The measure_interactions function runs the FAST (Feature Alternating Statistical Testing) algorithm to rank all candidate feature pairs by interaction strength. It fits an internal EBM-like model to each pair and compares the 2D fit to the sum of 1D fits. This is the public API for interaction detection, used both internally during EBM fitting and as a standalone utility. The function supports custom objectives, regularization parameters, and can accept pre-trained model scores as initialization via the init_score parameter.
Usage
Import this function when you want to discover significant feature interactions before or during EBM training, or as a standalone tool for feature interaction analysis on any tabular dataset.
Code Reference
Source Location
- Repository
interpretml/interpret- File
python/interpret-core/interpret/utils/_measure_interactions.py- Lines
- 34--304
Signature
def measure_interactions(
X,
y,
interactions=None,
init_score=None,
sample_weight=None,
feature_names=None,
feature_types=None,
max_interaction_bins=64,
min_samples_leaf=4,
min_hessian=1e-4,
reg_alpha=0.0,
reg_lambda=0.0,
max_delta_step=0.0,
objective=None,
):
"""Run the FAST algorithm and return the ranked interactions and their strengths."""
Import
from interpret.utils import measure_interactions
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
X |
array-like | Yes | Feature matrix |
y |
array-like | Yes | Target values |
interactions |
int / list / None | No | Number of top interactions to return, or specific pairs to evaluate |
init_score |
model / array / None | No | Pre-trained model scores for initialization |
sample_weight |
array-like | No | Per-sample weights |
feature_names |
list | No | Names for each feature column |
feature_types |
list | No | Types for each feature |
max_interaction_bins |
int | No | Maximum bins for interaction terms (default: 64) |
min_samples_leaf |
int | No | Minimum samples per leaf (default: 4) |
min_hessian |
float | No | Minimum hessian for splits (default: 1e-4) |
reg_alpha |
float | No | L1 regularization (default: 0.0) |
reg_lambda |
float | No | L2 regularization (default: 0.0) |
max_delta_step |
float | No | Maximum delta step (default: 0.0) |
objective |
str | No | Learning objective (auto-detected if None) |
Outputs
| Name | Type | Description |
|---|---|---|
| return | list of tuples | List of ((feature_i, feature_j), interaction_strength) tuples, sorted in descending order by interaction strength
|
Usage Examples
Basic Usage
from interpret.utils import measure_interactions
from sklearn.datasets import make_classification
X, y = make_classification(n_samples=1000, n_features=10, n_informative=5)
# Measure top 5 interactions
results = measure_interactions(X, y, interactions=5)
for (feat_i, feat_j), strength in results:
print(f"Features ({feat_i}, {feat_j}): strength = {strength:.4f}")