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 BoosterShell Hpp

From Leeroopedia


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

Overview

Defines the BoosterShell class which wraps a BoosterCore and manages temporary working memory used during boosting operations.

Description

The BoosterShell.hpp header declares the BoosterShell class, which serves as the per-call wrapper around a BoosterCore. While BoosterCore holds the persistent model state, BoosterShell manages transient working memory needed during individual boosting operations: temporary fast bins (m_aBoostingFastBinsTemp), main bins (m_aBoostingMainBins), multiclass midway temp buffer, tree nodes temp, and split positions temp. It includes handle verification using magic numbers (k_handleVerificationOk = 10995 and k_handleVerificationFreed = 25073) to detect use-after-free and invalid handle errors. The static GetBoosterShellFromHandle method validates the handle before returning the shell pointer. The class uses POD semantics (default constructor/destructor) and only malloc/free for memory management. It defines k_illegalTermIndex and k_interceptTermIndex as sentinel values.

Usage

Created when the Python layer creates a boosting session handle. Each call through the C API (GenerateTermUpdate, ApplyTermUpdate, etc.) retrieves the BoosterShell from the opaque handle, which provides access to both the BoosterCore and the temporary working memory.

Code Reference

Source Location

Signature

class BoosterShell final {
   static constexpr size_t k_handleVerificationOk = 10995;
   static constexpr size_t k_handleVerificationFreed = 25073;

   BoosterCore* m_pBoosterCore;
   size_t m_iTerm;
   Tensor* m_pTermUpdate;
   Tensor* m_pInnerTermUpdate;
   BinBase* m_aBoostingFastBinsTemp;
   BinBase* m_aBoostingMainBins;
   void* m_aMulticlassMidwayTemp;

   static constexpr size_t k_illegalTermIndex = std::numeric_limits<size_t>::max();
   static constexpr size_t k_interceptTermIndex = std::numeric_limits<size_t>::max() - size_t{1};

   INLINE_ALWAYS void InitializeUnfailing(BoosterCore* const pBoosterCore);
   static void Free(BoosterShell* const pBoosterShell);
   static BoosterShell* Create(BoosterCore* const pBoosterCore);
   ErrorEbm FillAllocations();
   INLINE_ALWAYS static BoosterShell* GetBoosterShellFromHandle(const BoosterHandle boosterHandle);
};

I/O Contract

Field Description
m_handleVerification Magic number to detect invalid/freed handles
m_pBoosterCore Pointer to the underlying BoosterCore
m_aBoostingFastBinsTemp Temporary bins for fast accumulation (SIMD-aligned)
m_aBoostingMainBins Main histogram bins for split finding
m_pTermUpdate Current term update tensor
m_pInnerTermUpdate Inner term update tensor for cyclic boosting

Usage Examples

# Called internally via native bindings
from interpret.glassbox import ExplainableBoostingClassifier
ebm = ExplainableBoostingClassifier()
ebm.fit(X, y)  # BoosterShell wraps the internal boosting handle

Related Pages

Page Connections

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