Fix merge_ebms missing hyperparameters (#576)#661
Fix merge_ebms missing hyperparameters (#576)#661paulbkoch merged 2 commits intointerpretml:mainfrom
Conversation
5888c54 to
174e271
Compare
|
Hi @paulbkoch, |
|
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>
174e271 to
5abc8e4
Compare
Signed-off-by: ugbotueferhire <ugbotueferhire@gmail.com>
|
@paulbkoch I've updated to main branch |
Codecov Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
LGTM. The docs failure appears unrelated. Thanks @ugbotueferhire! |
Description
This PR resolves Issue #576 where calling
merge_ebms()produced broken EBM objects.Because
merge_ebmsinstantiates 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 likerepr(merged_ebm),merged_ebm.get_params(), andsklearn.base.clone(merged_ebm)to raise anAttributeError.Changes Made:
_initialize_merged_model_params(merged_model, source_models)to dynamically copy hyperparameters from the first source model onto the newly initialized merged model usingget_params(deep=False).callbackparameter is a stateful training parameter that retains unwanted references post-merge. This is explicitly wiped (set toNone) during initialization.Code Snippet
The core surgical fix leverages
get_params()to respect the scikit-learn constructor variables dynamically: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 theAttributeError: 'ExplainableBoostingClassifier' object has no attribute 'cyclic_progress'crash reported inmerge_ebmproduces 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)