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 ExampleRegressionObjective

From Leeroopedia
Revision as of 15:16, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Interpretml_Interpret_ExampleRegressionObjective.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 a documented example/template for implementing custom regression objective functions in the EBM framework.

Description

The ExampleRegressionObjective.hpp file defines the ExampleRegressionObjective struct as a reference implementation showing how to create a new regression objective. It demonstrates all required methods: the constructor accepting Config and custom parameters (param0, param1), CheckRegressionTarget for validation, LinkParam for link function parameters, learning rate and gain adjustment methods, GradientConstant/HessianConstant for factoring out constant multipliers, FinishMetric for post-processing the accumulated metric, and the three computation methods CalcMetric, CalcGradient, and CalcGradientHessian. The example uses an identity link function and implements a basic MSE-like objective where gradient = 2 * error and hessian = 2. It uses the OBJECTIVE_BOILERPLATE macro and explains each method's purpose in comments.

Usage

Serves as documentation and a template for developers adding new objective functions to the EBM library. Not intended for production use, but provides a complete working example of the objective interface.

Code Reference

Source Location

Signature

template<typename TFloat> struct ExampleRegressionObjective : RegressionObjective {
   OBJECTIVE_BOILERPLATE(ExampleRegressionObjective, MINIMIZE_METRIC,
       Objective_Other, Link_identity, true)

   TFloat m_param0;
   TFloat m_param1;
   static constexpr double Two = 2.0;

   inline ExampleRegressionObjective(const Config& config,
       const double param0, const double param1);
   inline bool CheckRegressionTarget(const double target) const noexcept;
   inline double LinkParam() 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;
};

I/O Contract

Method Input Output
CalcMetric score, target (prediction - target)^2
CalcGradient score, target 2 * (prediction - target)
CalcGradientHessian score, target gradient=2*error, hessian=2

Usage Examples

# This is a template objective - not directly called by users.
# Developers use it as a reference when creating new objectives.
from interpret.glassbox import ExplainableBoostingRegressor
ebm = ExplainableBoostingRegressor()
ebm.fit(X, y)  # Production code uses RmseRegressionObjective instead

Related Pages

Page Connections

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