Implementation:Interpretml Interpret PartitionMultiDimensionalStraight
| Knowledge Sources | |
|---|---|
| Domains | Machine_Learning, EBM_Core |
| Last Updated | 2026-02-07 12:00 GMT |
Overview
PartitionMultiDimensionalStraight is a C++ module that finds optimal axis-aligned (straight) splits in multi-dimensional tensor space during EBM interaction detection.
Description
This module implements a straight (axis-aligned planar) splitting algorithm primarily used for scoring feature interactions. For a 2-dimensional interaction, it exhaustively searches all possible pairs of axis-aligned splits, dividing the 2D space into four quadrants. For each candidate split pair, it:
- Computes bin sums for all four quadrants using
TensorTotalsSum - Checks minimum sample count requirements (
cSamplesLeafMin) in each quadrant - Checks minimum hessian requirements in each quadrant
- Calculates the gain for each quadrant considering regularization (alpha, lambda) and step size constraints
- Compares the total gain (sum of four quadrant gains minus parent gain) against the current best
The algorithm uses stack-allocated bins when the number of scores is known at compile time (via template parameter), or heap-allocated auxiliary bins for dynamic score counts, to optimize cache performance.
The current implementation is templated for 2 dimensions (cCompilerDimensions = 2) with a note that it should be modified to return boosting updates for use in both boosting and interaction detection.
Usage
This module is primarily used during interaction detection to score the interaction strength between pairs of features. The gain returned represents how much predictive improvement is achieved by modeling the feature interaction compared to treating the features independently.
Code Reference
Source Location
- Repository: Interpretml_Interpret
- File:
shared/libebm/PartitionMultiDimensionalStraight.cpp
Signature
template<bool bHessian, size_t cCompilerScores>
class PartitionMultiDimensionalStraightInternal final {
public:
static double Func(
InteractionCore* const pInteractionCore,
const size_t cRuntimeRealDimensions,
const size_t* const acBins,
const CalcInteractionFlags flags,
const size_t cSamplesLeafMin,
const FloatCalc hessianMin,
const FloatCalc regAlpha,
const FloatCalc regLambda,
const FloatCalc deltaStepMax,
BinBase* const aAuxiliaryBinsBase,
BinBase* const aBinsBase
#ifndef NDEBUG
,
const BinBase* const aDebugCopyBinsBase,
const BinBase* const pBinsEndDebug
#endif
);
};
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| pInteractionCore | InteractionCore* | Yes | The interaction detection context |
| cRuntimeRealDimensions | size_t | Yes | Number of dimensions with more than 1 bin |
| acBins | const size_t* | Yes | Array of bin counts per dimension |
| flags | CalcInteractionFlags | Yes | Interaction calculation flags (e.g., DisableNewton) |
| cSamplesLeafMin | size_t | Yes | Minimum samples required per leaf region |
| hessianMin | FloatCalc | Yes | Minimum hessian sum per leaf region |
| regAlpha | FloatCalc | Yes | L1 regularization parameter |
| regLambda | FloatCalc | Yes | L2 regularization parameter |
| deltaStepMax | FloatCalc | Yes | Maximum step size constraint |
| aBinsBase | BinBase* | Yes | Pre-computed histogram bins |
Outputs
| Name | Type | Description |
|---|---|---|
| return value | double | Best interaction gain found (0 if no valid split exists) |
Usage Examples
Pipeline Context
# This C++ module is called internally via the native bindings
# during interaction detection to score feature pairs
from interpret.glassbox import ExplainableBoostingClassifier
ebm = ExplainableBoostingClassifier(interactions=10)
ebm.fit(X, y) # Internally calls PartitionMultiDimensionalStraight for pair scoring