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 Transpose

From Leeroopedia


Knowledge Sources
Domains Machine_Learning, EBM_Core
Last Updated 2026-02-07 12:00 GMT

Overview

Implements the Transpose function that copies score data between the increment (external/Python) and stride (internal/C++) tensor orderings, handling missing and unseen bin adjustments.

Description

The Transpose.hpp header defines the Transpose template function which converts between two tensor orderings: the "increment" order used by the Python layer (where the first dimension varies fastest) and the "stride" order used internally by the C++ code. The function handles dimension reordering via the m_iTranspose field of TermFeature, and also manages the addition or removal of missing-value and unseen-category bins at the boundaries of each dimension (bDropFirst for missing, bDropLast for unseen). The TransposeDimension struct tracks per-dimension state including bin counts, reduced bin counts, stride bytes, and flags for dropping boundary bins. The template parameter bCopyToIncrement controls the copy direction.

Usage

Called when transferring tensor data between the Python layer and the C++ internals. The Python layer uses a different bin ordering and may not include missing/unseen sentinel bins, so the Transpose function handles this mapping in both directions.

Code Reference

Source Location

Signature

struct TransposeDimension {
   size_t cBins;
   bool bDropFirst;
   bool bDropLast;
   size_t cBinsReduced;
   size_t iBinsRemaining;
   size_t cBytesStride;
};

template<bool bCopyToIncrement, typename TIncrement, typename TStride>
extern void Transpose(
    const Term* const pTerm,
    const size_t cScores,
    TIncrement* pIncrement,
    TStride* pStride);

I/O Contract

Input Description
pTerm Term defining the feature dimensions and transpose mapping
cScores Number of scores per tensor cell
pIncrement Pointer to increment-ordered (Python) tensor data
pStride Pointer to stride-ordered (C++) tensor data
Template Parameter Description
bCopyToIncrement true: copy from stride to increment; false: copy from increment to stride

Usage Examples

# Called internally via native bindings
from interpret.glassbox import ExplainableBoostingClassifier
ebm = ExplainableBoostingClassifier()
ebm.fit(X, y)  # Transpose is used when transferring model scores to/from Python

Related Pages

Page Connections

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