Skip to content

Fix merge_ebms missing hyperparameters (#576)#661

Merged
paulbkoch merged 2 commits intointerpretml:mainfrom
ugbotueferhire:fix/merge-ebms-missing-hyperparameters
Apr 10, 2026
Merged

Fix merge_ebms missing hyperparameters (#576)#661
paulbkoch merged 2 commits intointerpretml:mainfrom
ugbotueferhire:fix/merge-ebms-missing-hyperparameters

Conversation

@ugbotueferhire
Copy link
Copy Markdown
Contributor


Description

This PR resolves Issue #576 where calling merge_ebms() produced broken EBM objects.
Because merge_ebms instantiates the merged EBM via __new__(), the __init__() method is bypassed. Consequently, the resulting EBM model lacked all fundamental hyperparameters (e.g., learning_rate, max_bins, outer_bags). This severely violated the scikit-learn estimator contract, causing operations like repr(merged_ebm), merged_ebm.get_params(), and sklearn.base.clone(merged_ebm) to raise an AttributeError.
Changes Made:

  1. Dynamic Parameter Initialization: Implemented _initialize_merged_model_params(merged_model, source_models) to dynamically copy hyperparameters from the first source model onto the newly initialized merged model using get_params(deep=False).
  2. Neutralize Callbacks: The callback parameter is a stateful training parameter that retains unwanted references post-merge. This is explicitly wiped (set to None) during initialization.
  3. Comprehensive Regression Suite: Added 7 robust regression tests to secure both Classifiers and Regressors against future edge-cases.

Code Snippet

The core surgical fix leverages get_params() to respect the scikit-learn constructor variables dynamically:

def _initialize_merged_model_params(merged_model, source_models):
    first_source_model = source_models[0]
    hyperparameters = first_source_model.get_params(deep=False)
    if "callback" in hyperparameters:
        hyperparameters["callback"] = None
    for parameter_name, parameter_value in hyperparameters.items():
        setattr(merged_model, parameter_name, parameter_value)

Testing Strategy

To prove the fix and guarantee zero regressions, a rigorous suite was added to test_merge_ebms.py:

  • test_merge_ebms_repr: Exactly reproduces and asserts the AttributeError: 'ExplainableBoostingClassifier' object has no attribute 'cyclic_progress' crash reported in merge_ebm produces broken classifiers #576.
  • test_merge_ebms_get_params / test_merge_ebms_sklearn_clone: Asserts strict downstream scikit-learn compliance.
  • test_merge_ebms_has_all_hyperparameters: Introspects the explicit __init__ signature to mathematically guarantee no hyperparameters are left undefined.
  • test_merge_ebms_predictions_unchanged: Asserts that updating scikit-learn metadata metadata doesn't shift original score distributions natively.

Verification (Test Execution)

✓ ruff passed (0 linting errors)
✓ 100% test coverage tracked on `_merge_ebms.py` added lines
============================= test session starts =============================
platform win32 -- Python 3.13.0, pytest-9.0.2
rootdir: /interpret/python/interpret-core
collected 9 items
python/interpret-core/tests/glassbox/ebm/test_merge_ebms.py 
  ✓ [ 11%] test_merge_ebms
  ✓ [ 22%] test_merge_ebms_multiclass
  ✓ [ 33%] test_merge_ebms_repr 
  ✓ [ 44%] test_merge_ebms_get_params
  ✓ [ 55%] test_merge_ebms_sklearn_clone 
  ✓ [ 66%] test_merge_ebms_has_all_hyperparameters 
  ✓ [ 77%] test_merge_ebms_callback_is_none
  ✓ [ 88%] test_merge_ebms_regressor_repr 
  ✓ [100%] test_merge_ebms_predictions_unchanged
=========================== 9 passed in 40.59s ===========================

@ugbotueferhire ugbotueferhire force-pushed the fix/merge-ebms-missing-hyperparameters branch 2 times, most recently from 5888c54 to 174e271 Compare April 9, 2026 21:55
@ugbotueferhire
Copy link
Copy Markdown
Contributor Author

Hi @paulbkoch,
I've submitted this PR to fix Issue #576. It resolves the bug where merge_ebms() produced models without hyperparameters, causing downstream scikit-learn failures like clone().
I corrected the missing initialization and added 7 comprehensive regression tests. All CI tests and formatting checks are completely green! I'd really appreciate it if you could take a quick look when you have a moment.

@paulbkoch
Copy link
Copy Markdown
Collaborator

Hi @ugbotueferhire -- The code change you made looks good, although this PR is on the develop branch, which is very old. Can you make this change on the main branch.

@ugbotueferhire
Copy link
Copy Markdown
Contributor Author

Hi @ugbotueferhire -- The code change you made looks good, although this PR is on the develop branch, which is very old. Can you make this change on the main branch.

alr thank you for the feedback

Signed-off-by: ugbotueferhire <ugbotueferhire@gmail.com>
@ugbotueferhire ugbotueferhire force-pushed the fix/merge-ebms-missing-hyperparameters branch from 174e271 to 5abc8e4 Compare April 10, 2026 06:36
@ugbotueferhire ugbotueferhire changed the base branch from develop to main April 10, 2026 06:38
Signed-off-by: ugbotueferhire <ugbotueferhire@gmail.com>
@ugbotueferhire
Copy link
Copy Markdown
Contributor Author

@paulbkoch I've updated to main branch

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.39%. Comparing base (412ca5c) to head (d8bc434).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #661      +/-   ##
==========================================
+ Coverage   66.32%   66.39%   +0.06%     
==========================================
  Files          75       75              
  Lines       11581    11589       +8     
==========================================
+ Hits         7681     7694      +13     
+ Misses       3900     3895       -5     
Flag Coverage Δ
bdist_linux_311_python 66.12% <100.00%> (+0.06%) ⬆️
bdist_linux_312_python 66.12% <100.00%> (+0.08%) ⬆️
bdist_linux_313_python 66.11% <100.00%> (+0.07%) ⬆️
bdist_linux_314_python 66.06% <100.00%> (+0.08%) ⬆️
bdist_linuxarm_311_python 66.14% <100.00%> (+0.08%) ⬆️
bdist_linuxarm_312_python 66.15% <100.00%> (+0.09%) ⬆️
bdist_linuxarm_313_python 66.15% <100.00%> (+0.10%) ⬆️
bdist_linuxarm_314_python 66.06% <100.00%> (+0.07%) ⬆️
bdist_mac_311_python 66.30% <100.00%> (+0.08%) ⬆️
bdist_mac_312_python 66.28% <100.00%> (+0.06%) ⬆️
bdist_mac_313_python 66.28% <100.00%> (+0.08%) ⬆️
bdist_mac_314_python 66.22% <100.00%> (+0.10%) ⬆️
bdist_win_311_python 66.32% <100.00%> (+0.08%) ⬆️
bdist_win_312_python 66.30% <100.00%> (+0.08%) ⬆️
bdist_win_313_python 66.30% <100.00%> (+0.06%) ⬆️
bdist_win_314_python 66.22% <100.00%> (+0.08%) ⬆️
sdist_linux_311_python 66.08% <100.00%> (+0.10%) ⬆️
sdist_linux_312_python 66.07% <100.00%> (+0.08%) ⬆️
sdist_linux_313_python 66.08% <100.00%> (+0.12%) ⬆️
sdist_linux_314_python 65.97% <100.00%> (+0.04%) ⬆️
sdist_linuxarm_311_python 66.07% <100.00%> (+0.09%) ⬆️
sdist_linuxarm_312_python 66.09% <100.00%> (+0.08%) ⬆️
sdist_linuxarm_313_python 66.07% <100.00%> (+0.07%) ⬆️
sdist_linuxarm_314_python 66.01% <100.00%> (+0.09%) ⬆️
sdist_mac_311_python 66.21% <100.00%> (+0.10%) ⬆️
sdist_mac_312_python 66.21% <100.00%> (+0.10%) ⬆️
sdist_mac_313_python 66.21% <100.00%> (+0.10%) ⬆️
sdist_mac_314_python 66.12% <100.00%> (+0.06%) ⬆️
sdist_win_311_python 66.30% <100.00%> (+0.08%) ⬆️
sdist_win_312_python 66.30% <100.00%> (+0.10%) ⬆️
sdist_win_313_python 66.32% <100.00%> (+0.08%) ⬆️
sdist_win_314_python 66.22% <100.00%> (+0.08%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@paulbkoch
Copy link
Copy Markdown
Collaborator

LGTM. The docs failure appears unrelated. Thanks @ugbotueferhire!

@paulbkoch paulbkoch merged commit fabf5a5 into interpretml:main Apr 10, 2026
62 of 63 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants