Implementation:Interpretml Interpret Objective Framework
| Knowledge Sources | |
|---|---|
| Domains | Machine_Learning, EBM_Core |
| Last Updated | 2026-02-07 12:00 GMT |
Overview
Defines the base Objective class and supporting infrastructure for all EBM loss functions, providing the framework for gradient/hessian computation and score updates.
Description
The Objective.hpp header is the central framework for all objective (loss) functions in the EBM library. It defines the GradientHessian template class for pairing gradient and hessian values, factory functions like MakeGradientHessian, and the template dispatch machinery for DoneBitpacking and ChooseBitPack which select the appropriate bit-packing specialization at runtime. The header also declares objective category marker structs (SingletaskObjective, BinaryObjective, MulticlassObjective, RegressionObjective) and their multitask counterparts. The heavy template metaprogramming enables compile-time specialization across multiple boolean flags (collapsed, validation, weight, hessian, approximate) and integer parameters (scores, pack size), producing highly optimized code paths for each combination.
Usage
Serves as the base class and dispatch framework for all concrete objective implementations (LogLossBinary, LogLossMulticlass, RMSE, Poisson, etc.). Each objective inherits from one of the marker structs and implements CalcMetric, CalcGradient, and optionally CalcGradientHessian methods.
Code Reference
Source Location
- Repository: Interpretml_Interpret
- File: shared/libebm/compute/Objective.hpp
Signature
template<typename TFloat> class alignas(alignof(TFloat)) GradientHessian {
GPU_DEVICE inline TFloat GetGradient() const noexcept;
GPU_DEVICE inline TFloat GetHessian() const noexcept;
};
template<typename TFloat>
GPU_DEVICE inline GradientHessian<TFloat> MakeGradientHessian(
const TFloat& gradient, const TFloat& hessian);
struct SingletaskObjective;
struct BinaryObjective;
struct MulticlassObjective;
struct RegressionObjective;
template<typename TObjective, bool bCollapsed, bool bValidation, bool bWeight,
bool bHessian, bool bUseApprox, size_t cCompilerScores, int cCompilerPack>
GPU_DEVICE INLINE_RELEASE_TEMPLATED static void DoneBitpacking(
const Objective* const pObjective, ApplyUpdateBridge* const pData);
template<typename TFloat>
static const std::vector<std::shared_ptr<const Registration>> RegisterObjectives();
I/O Contract
| Component | Input | Output |
|---|---|---|
| GradientHessian | gradient value, hessian value | Paired gradient-hessian struct |
| DoneBitpacking | Objective pointer, ApplyUpdateBridge data | Updated scores, metrics, gradients |
| RegisterObjectives | (none) | Vector of registered objective implementations |
Usage Examples
# Called internally via native bindings
from interpret.glassbox import ExplainableBoostingClassifier
ebm = ExplainableBoostingClassifier()
ebm.fit(X, y) # Objective functions compute gradients/hessians each round