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 Term

From Leeroopedia


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

Overview

Defines the Term class representing a single term (feature or feature interaction) in the EBM generalized additive model.

Description

The Term.hpp header declares the Term class, which represents one additive term in the EBM model. Each term consists of one or more features (for main effects or interactions respectively) and tracks the total number of tensor bins (product of per-feature bin counts), the number of auxiliary bins needed, the minimum bits required for bit-packing, and logging counters. The TermFeature struct links each dimension to its FeatureBoosting pointer, stride, and transpose index. The term uses the struct hack pattern with a fixed-size m_aTermFeatures array of k_cDimensionsMax entries to co-locate feature references with the term data. The class provides static factory methods (Allocate, AllocateTerms, FreeTerms) and accessor methods for all properties.

Usage

Created during boosting initialization based on the term definitions provided by the Python layer. Terms define which features (or feature pairs) participate in the model. BoosterCore maintains an array of Term pointers that are used throughout boosting for histogram building, partition finding, and score updates.

Code Reference

Source Location

Signature

struct TermFeature {
   const FeatureBoosting* m_pFeature;
   size_t m_cStride;
   size_t m_iTranspose;
};

class Term final {
   size_t m_cDimensions;
   size_t m_cRealDimensions;
   size_t m_cTensorBins;
   size_t m_cAuxillaryBins;
   int m_cBitsRequiredMin;
   TermFeature m_aTermFeatures[k_cDimensionsMax];

   inline static size_t GetTermCountBytes(const size_t cDimensions) noexcept;
   inline static void Free(Term* const pTerm) noexcept;
   inline void Initialize(const size_t cDimensions) noexcept;
   static Term* Allocate(const size_t cDimensions) noexcept;
   static Term** AllocateTerms(const size_t cTerms) noexcept;
   static void FreeTerms(const size_t cTerms, Term** apTerms) noexcept;

   inline size_t GetCountDimensions() const noexcept;
   inline size_t GetCountRealDimensions() const noexcept;
   inline size_t GetCountTensorBins() const noexcept;
   inline const TermFeature* GetTermFeatures() const noexcept;
};

I/O Contract

Field Description
m_cDimensions Total number of feature dimensions in this term
m_cRealDimensions Number of dimensions with more than 1 bin
m_cTensorBins Product of all dimension bin counts
m_cAuxillaryBins Extra bins needed for computation
m_aTermFeatures Array of feature references with stride/transpose info

Usage Examples

# Called internally via native bindings
from interpret.glassbox import ExplainableBoostingClassifier
ebm = ExplainableBoostingClassifier(interactions=5)
ebm.fit(X, y)  # Terms are created for main effects and detected interactions

Related Pages

Page Connections

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