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 EbmStats

From Leeroopedia
Revision as of 15:16, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Interpretml_Interpret_EbmStats.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

Provides statistical utility functions for EBM boosting including L1/L2 regularization, negative update computation, and partial gain calculation.

Description

The ebm_stats.hpp header defines inline static functions for the core statistical computations used in EBM split finding and model updates. ApplyL1 applies L1 (Lasso) regularization by soft-thresholding the gradient sum. ApplyL2 applies L2 (Ridge) regularization by adding the lambda penalty to the hessian sum. CalcNegUpdate computes the negative Newton step (-gradient/hessian) with regularization and delta step capping, returning 0 for near-zero hessians. CalcPartialGain computes the squared-gradient-over-hessian gain for a single bin, which is the fundamental quantity used for finding optimal splits. CalcGradientUpdate returns the raw gradient sum for use in differential privacy mode. The header includes extensive documentation on IEEE 754 NaN/infinity propagation rules and their exploitation for efficient overflow detection.

Usage

Called during every split evaluation in the boosting process. CalcPartialGain is called for each candidate split to compute the improvement in the objective. CalcNegUpdate is called to compute the actual model update once the best split is found.

Code Reference

Source Location

Signature

static constexpr FloatCalc k_gainMin = std::numeric_limits<FloatCalc>::min();

INLINE_ALWAYS static FloatCalc ApplyL1(
    const FloatCalc sumGradient, const FloatCalc regAlpha);

INLINE_ALWAYS static FloatCalc ApplyL2(
    const FloatCalc sumHessian, const FloatCalc regLambda);

INLINE_ALWAYS static FloatCalc CalcGradientUpdate(const FloatCalc sumGradient);

template<bool bCheckHessian>
INLINE_ALWAYS static FloatCalc CalcNegUpdate(
    const FloatCalc sumGradient, const FloatCalc sumHessian,
    const FloatCalc regAlpha, const FloatCalc regLambda,
    const FloatCalc deltaStepMax);

template<bool bCheckHessian>
INLINE_ALWAYS static FloatCalc CalcPartialGain(
    const FloatCalc sumGradient, const FloatCalc sumHessian,
    const FloatCalc regAlpha, const FloatCalc regLambda,
    const FloatCalc deltaStepMax);

I/O Contract

Function Input Output Description
ApplyL1 gradient sum, alpha regularized gradient Soft-thresholded L1 regularization
ApplyL2 hessian sum, lambda regularized hessian L2 penalty added to hessian
CalcNegUpdate gradient, hessian, alpha, lambda, deltaStepMax FloatCalc step Newton step with capping
CalcPartialGain gradient, hessian, alpha, lambda, deltaStepMax FloatCalc gain Split gain for one bin

Usage Examples

# Called internally via native bindings
from interpret.glassbox import ExplainableBoostingClassifier
ebm = ExplainableBoostingClassifier(reg_alpha=0.01, reg_lambda=0.01)
ebm.fit(X, y)  # EbmStats functions compute regularized gains and updates

Related Pages

Page Connections

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