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 LogLossBinaryObjective

From Leeroopedia


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

Overview

Implements the binary cross-entropy (log loss) objective function for binary classification in EBM, with a specialized InjectedApplyUpdate method.

Description

The LogLossBinaryObjective.hpp defines the LogLossBinaryObjective struct which implements the binary classification loss function using the logit link function. Unlike most other objectives, LogLoss for binary classification is "special" -- it provides a custom InjectedApplyUpdate method that directly handles the full forward pass including sigmoid computation, metric calculation, and gradient/hessian updates in a single fused loop, rather than relying on the generic CalcMetric/CalcGradient/CalcGradientHessian methods (which are present but marked as signal-only stubs). The objective uses MINIMIZE_METRIC direction, logit link function, and supports both approximate and exact math modes. The InjectedApplyUpdate processes bit-packed feature data, applies score updates from the tensor, computes the sigmoid, and calculates log-loss metrics and gradients/hessians in a single pass through the data.

Usage

Used automatically when training a binary classification EBM (ExplainableBoostingClassifier with 2 classes). Registered under the "log_loss" tag, shared with multiclass, with a check that config.cOutputs==1 to distinguish the binary case.

Code Reference

Source Location

Signature

template<typename TFloat> struct LogLossBinaryObjective : BinaryObjective {
   OBJECTIVE_CONSTANTS_BOILERPLATE(LogLossBinaryObjective, MINIMIZE_METRIC,
       Objective_LogLossBinary, Link_logit, true, true, 64, 1)

   inline LogLossBinaryObjective(const Config& config);
   inline double LinkParam() const noexcept;
   inline double LearningRateAdjustmentDifferentialPrivacy() const noexcept;
   inline double LearningRateAdjustmentGradientBoosting() const noexcept;
   inline double LearningRateAdjustmentHessianBoosting() const noexcept;
   inline double GainAdjustmentGradientBoosting() const noexcept;
   inline double GainAdjustmentHessianBoosting() const noexcept;
   inline double GradientConstant() const noexcept;
   inline double HessianConstant() const noexcept;
   inline double FinishMetric(const double metricSum) const noexcept;

   GPU_DEVICE inline TFloat CalcMetric(const TFloat& score, const TFloat& target) const noexcept;
   GPU_DEVICE inline TFloat CalcGradient(const TFloat& score, const TFloat& target) const noexcept;
   GPU_DEVICE inline GradientHessian<TFloat> CalcGradientHessian(
       const TFloat& score, const TFloat& target) const noexcept;

   template<bool bCollapsed, bool bValidation, bool bWeight, bool bHessian,
       bool bUseApprox, size_t cCompilerScores, int cCompilerPack>
   GPU_DEVICE NEVER_INLINE void InjectedApplyUpdate(ApplyUpdateBridge* const pData) const;
};

I/O Contract

Parameter Description
Config.cOutputs Must be 1 for binary classification (throws SkipRegistrationException otherwise)
Link function logit (sigmoid)
Metric direction MINIMIZE_METRIC
Output (via ApplyUpdateBridge) Description
m_aSampleScores Updated sample scores
m_aGradientsAndHessians Computed gradients and hessians
m_metricOut Accumulated log-loss metric

Usage Examples

# Called internally via native bindings
from interpret.glassbox import ExplainableBoostingClassifier
ebm = ExplainableBoostingClassifier()
ebm.fit(X, y)  # Uses LogLossBinaryObjective for binary classification

Related Pages

Page Connections

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