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 ApproximateMath

From Leeroopedia
Revision as of 15:16, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Interpretml_Interpret_ApproximateMath.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 fast approximate implementations of exp() and log() functions for use in EBM gradient boosting, based on the Schraudolph algorithm.

Description

The approximate_math.hpp header implements fast approximate versions of the exponential and logarithm functions, primarily based on the Schraudolph algorithm described in "A Fast, Compact Approximation of the Exponential Function." These approximations exploit the IEEE 754 floating-point representation by directly manipulating the bit patterns of floats and doubles. The approximate functions trade a small amount of numerical accuracy for significant performance gains, which is acceptable in the context of gradient boosting where small errors in individual gradient computations average out over many samples. The header includes detailed documentation of IEEE 754 correct rounding guarantees and their implications for cross-platform reproducibility. It also references alternative approaches including the Paul Mineiro Pade approximant variants and AVX-512 table-based implementations.

Usage

Used when the EBM model is configured with approximate math enabled (the default for classification). The approximate exp and log are called millions of times per boosting round for computing logistic sigmoid values, making their performance critical to overall training speed.

Code Reference

Source Location

Signature

// Approximate exp function using Schraudolph's algorithm
// Template parameters control edge-case handling:
//   bNegateInput - negate input before computing
//   bNaNPossible - whether NaN inputs are possible
//   bUnderflowPossible - whether underflow is possible
//   bOverflowPossible - whether overflow is possible
template<bool bNegateInput = false, bool bNaNPossible = true,
    bool bUnderflowPossible = true, bool bOverflowPossible = true>
inline TFloat ExpApprox(const TFloat& val) noexcept;

// Approximate log function
template<bool bNegateOutput = false, bool bNaNPossible = true,
    bool bNegativePossible = true, bool bZeroPossible = true,
    bool bPositiveInfinityPossible = true>
inline TFloat LogApprox(const TFloat& val) noexcept;

I/O Contract

Function Input Output Description
ExpApprox TFloat value TFloat result Fast approximate e^x
LogApprox TFloat value TFloat result Fast approximate ln(x)

Usage Examples

# Called internally via native bindings
from interpret.glassbox import ExplainableBoostingClassifier
ebm = ExplainableBoostingClassifier()
ebm.fit(X, y)  # Approximate math is used in sigmoid computations during boosting

Related Pages

Page Connections

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