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 LogLossMulticlassObjective

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

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

Description

The LogLossMulticlassObjective.hpp defines the LogLossMulticlassObjective struct which implements multiclass classification loss using the multinomial logit (mlogit/softmax) link function. Like its binary counterpart, it is a "special" objective with a custom InjectedApplyUpdate method that fuses softmax computation, metric calculation, and gradient/hessian updates into a single pass. The objective computes a hessian factor of K/(K-1) per the Ping Li paper and the formulation in arxiv:1810.09092v2 (formula 5) for Newton boosting. It rejects binary classification (cOutputs==1, sharing the "log_loss" tag with binary), rejects non-positive output counts, and does not support differential privacy. The InjectedApplyUpdate handles the numerically stable softmax computation with max-score subtraction.

Usage

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

Code Reference

Source Location

Signature

template<typename TFloat> struct LogLossMulticlassObjective : MulticlassObjective {
   OBJECTIVE_CONSTANTS_BOILERPLATE(LogLossMulticlassObjective, MINIMIZE_METRIC,
       Objective_LogLossMulticlass, Link_mlogit, true, true,
       k_cItemsPerBitPackUndefined, k_cItemsPerBitPackUndefined)

   double m_hessianFactor;

   inline LogLossMulticlassObjective(const Config& config);
   inline double LinkParam() const noexcept;
   inline double GradientConstant() const noexcept;
   inline double HessianConstant() const noexcept;  // returns m_hessianFactor
   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 multiclass (throws SkipRegistrationException if 1)
Config.isDifferentialPrivacy Must be false (throws NonPrivateRegistrationException)
Link function mlogit (softmax)
m_hessianFactor K/(K-1) for Newton boosting correction
Output (via ApplyUpdateBridge) Description
m_aSampleScores Updated per-class sample scores
m_aGradientsAndHessians Per-class gradient and hessian values
m_metricOut Accumulated multiclass log-loss metric

Usage Examples

# Called internally via native bindings
from interpret.glassbox import ExplainableBoostingClassifier
ebm = ExplainableBoostingClassifier()
ebm.fit(X_multiclass, y_multiclass)  # Uses LogLossMulticlassObjective for 3+ classes

Related Pages

Page Connections

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