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 DebugEbm

From Leeroopedia


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

Overview

DebugEbm is a C++ module that provides glass-box testing for internal EBM library functions, validating correctness of transpose, log, exp, and softmax approximation functions at library load time in debug builds.

Description

This module implements several self-tests that run automatically when the library is loaded in debug builds (or in release builds when INCLUDE_TESTS_IN_RELEASE is defined). These tests provide glass-box validation of internal functions that are difficult to test through the public API alone.

The tests include:

  • TestTranspose: Validates the Transpose function by generating random multi-dimensional tensors (1-5 dimensions, 1-5 bins per dimension), applying random dimension permutations, transposing forward and backward, and verifying that the restored tensor matches the original. Tests handle missing and unseen categories correctly. Runs 100,000 random test configurations.
  • TestLogSumErrors: Validates the LogApproxSchraudolph approximation function against std::log. Verifies NaN/infinity handling and measures the maximum relative error across all representable float32 values. Also tests LogForLogLoss.
  • TestExpSumErrors: Validates the ExpApproxSchraudolph approximation function against std::exp. Tests edge cases (NaN, infinity, zero) and measures maximum relative error across representative float32 values.
  • TestSoftmaxSumErrors: Validates the softmax approximation functions against reference implementations. Tests both SoftmaxApproxSchraudolph and SoftmaxForLogLoss with random multi-class scenarios.

All tests use static assertion macros (static_assert) for compile-time checks and EBM_ASSERT for runtime checks. Test results are stored in global variables (g_TestTranspose, etc.) to prevent the optimizer from eliminating the test code.

Usage

This module runs automatically at library load time in debug builds. It serves as a continuous integration test for internal mathematical functions and data layout transformations. No user interaction is required.

Code Reference

Source Location

Signature

// Compile-time checks
static_assert(COUNT_BITS(uint8_t) == 8, "automated test with compiler");
static_assert(COUNT_BITS(uint16_t) == 16, "automated test with compiler");
static_assert(COUNT_BITS(uint32_t) == 32, "automated test with compiler");
static_assert(COUNT_BITS(uint64_t) == 64, "automated test with compiler");

// Runtime tests (conditional compilation)
#ifdef ENABLE_TRANSPOSE
static double TestTranspose();
extern double g_TestTranspose;
#endif

#ifdef ENABLE_TEST_LOG_SUM_ERRORS
static double TestLogSumErrors();
extern double g_TestLogSumErrors;
#endif

#ifdef ENABLE_TEST_EXP_SUM_ERRORS
static double TestExpSumErrors();
extern double g_TestExpSumErrors;
#endif

#ifdef ENABLE_TEST_SOFTMAX_SUM_ERRORS
static double TestSoftmaxSumErrors();
extern double g_TestSoftmaxSumErrors;
#endif

I/O Contract

Inputs

Name Type Required Description
(none) - - No external inputs; tests run at library initialization

Outputs

Name Type Description
g_TestTranspose double Non-zero value to prevent optimizer elimination (debug only)
g_TestLogSumErrors double Maximum error metric from log approximation tests
g_TestExpSumErrors double Maximum error metric from exp approximation tests
g_TestSoftmaxSumErrors double Maximum error metric from softmax approximation tests

Usage Examples

Pipeline Context

# This C++ module runs automatically at library load time in debug builds
# No direct user interaction is needed
from interpret.glassbox import ExplainableBoostingClassifier
# Loading the library triggers debug self-tests in debug builds

Related Pages

Page Connections

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