Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:Interpretml Interpret Harmonize Tensor

From Leeroopedia


Field Value
Sources Repo: InterpretML
Domains Federated_Learning, Numerical_Methods
Updated 2026-02-07

Overview

Concrete tool for remapping EBM score tensors between different bin definitions provided by the InterpretML library.

Description

The _harmonize_tensor function remaps a score tensor from old bin definitions to new unified bin definitions. It handles both continuous (interpolation based on bin boundary overlap) and categorical (redistribution based on evidence weights) features. For interaction terms, it processes all dimensions.

Usage

This is an internal function called by merge_ebms. Not typically called directly.

Code Reference

Field Value
Source interpretml/interpret
File python/interpret-core/interpret/glassbox/_ebm/_merge_ebms.py
Lines 23-277

Signature:

def _harmonize_tensor(
    new_feature_idxs,
    new_bounds,
    new_bins,
    old_feature_idxs,
    old_bounds,
    old_bins,
    old_mapping,
    old_tensor,
    bin_evidence_weight,
):

Import:

from interpret.glassbox._ebm._merge_ebms import _harmonize_tensor

I/O Contract

Inputs:

Parameter Type Required Description
new_feature_idxs list Yes Feature indices in the new merged model
new_bounds list Yes New bin boundaries for each feature
new_bins list Yes Target bin definitions
old_feature_idxs list Yes Feature indices in the source model
old_bounds list Yes Old bin boundaries for each feature
old_bins list Yes Source bin definitions
old_mapping list Yes Mapping from old to new bin indices
old_tensor ndarray Yes Score tensor to remap
bin_evidence_weight ndarray or None No Evidence weights for redistribution

Outputs:

Type Description
np.ndarray Tensor remapped to new bin dimensions

Usage Examples

# _harmonize_tensor is called internally by merge_ebms:
# new_tensor = _harmonize_tensor(
#     new_feature_idxs, new_bounds, new_bins,
#     old_feature_idxs, old_bounds, old_bins,
#     old_mapping, old_tensor, bin_evidence_weight
# )
# See merge_ebms() for the standard entry point.

Related Pages

Page Connections

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