Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Interpretml Interpret PartitionMultiDimensionalStraight

From Leeroopedia
Revision as of 15:17, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Interpretml_Interpret_PartitionMultiDimensionalStraight.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


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:

  1. Computes bin sums for all four quadrants using TensorTotalsSum
  2. Checks minimum sample count requirements (cSamplesLeafMin) in each quadrant
  3. Checks minimum hessian requirements in each quadrant
  4. Calculates the gain for each quadrant considering regularization (alpha, lambda) and step size constraints
  5. 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

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

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment