You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Refinements to the sequence forms of smoothing_rounds and interaction_smoothing_rounds.
Changes
Per-bag counters:boost() decrements the per-term smoothing counters in place, so it now works on its own copy. Every outer bag starts with its full budget, including when bags run in-process (n_jobs=1).
Constant-time smoothing checks: whether smoothing is still active is cached in a flag that is refreshed only when the counters change, instead of scanning every counter on each boosting step. Models fit with a scalar smoothing_rounds are unchanged.
Validation before boosting: a sequence interaction_smoothing_rounds is checked against the cleaned interactions list before any boosting starts. One-shot iterables such as itertools.combinations(...) work too.
Input types: any integer-valued scalar or 1-D array-like is accepted, including range, pandas.Series, and NumPy scalars. Whole-number checks use each value's own precision, including extended-precision longdouble. Booleans, strings, and values beyond the int64 range are rejected.
JSON export:to_json writes the smoothing parameters as built-in integers, or lists of them, so NumPy inputs such as longdouble serialize.
Docs: the smoothing_rounds and interaction_smoothing_rounds docstrings describe the sequence forms consistently across estimators: entries for excluded features, or for duplicate or excluded interactions, are ignored, and features that finish smoothing early are not boosted until smoothing ends.
Tests
New cases in tests/glassbox/ebm/test_smoothing_rounds.py cover scalar/sequence equivalence with several outer bags, exclusion versus dropping the column, duplicate and excluded interaction entries, validation before boosting, array-like and NumPy scalar inputs (including longdouble), booleans, values beyond the int64 range, and JSON export.
- Copy the per-term smoothing counters in boost() so every outer bag
starts with its full budget, including when bags run in-process.
- Cache whether smoothing is active instead of scanning all counters
on each boosting step.
- Validate a sequence interaction_smoothing_rounds against the cleaned
interactions list before boosting starts.
- Accept any integer-valued scalar or 1-D array-like; reject booleans
and strings.
- Write array-valued smoothing parameters as lists in to_json.
- Describe the sequence forms consistently in the estimator docs.
- Add tests for multiple outer bags, exclusion alignment, validation
before boosting, array-like inputs, and JSON export.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Values of 2**63 or more, such as a list containing 2**63 or floats like
1e19, now raise a ValueError instead of wrapping to negative counters.
Scalars that large raise the same error up front instead of an
OverflowError inside boost().
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Converting to Python float before checking integrality loses precision for extended-precision NumPy scalars. On platforms with wider longdouble, np.longdouble("1.0000000000000001") becomes 1.0 here, so this fractional input is accepted and silently truncated to 1. Check integrality in the original dtype, as the sequence branch does, before converting to int.
Convert longdouble smoothing parameters to serializable integers
tolist() does not always produce built-in scalars: for longdouble, it retains NumPy scalar objects. A newly supported value such as smoothing_rounds=np.longdouble(5) therefore fits successfully but still makes to_json() raise TypeError; the same applies to interaction_smoothing_rounds. Convert these integer-valued parameters to int64 or built-in integers before serialization, preserving None.
- Check a scalar smoothing_rounds for a fractional part in the input's
own dtype, as sequences already were. Converting to float first could
drop the fraction of an extended-precision longdouble.
- Convert sequence entries to exact Python ints before the int64 range
check. Comparing longdouble values with Python ints can round, or
raise TypeError or OverflowError, depending on the platform and NumPy
version.
- Write the smoothing parameters to JSON as built-in ints so longdouble
values serialize. None is still written as null.
- Skip the RuntimeWarning that inf entries triggered during the check.
- Add longdouble cases to the smoothing_rounds tests.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 67.78%. Comparing base (26780a6) to head (49e0b91). ⚠️ Report is 1 commits behind head on main.
❄️ 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refinements to the sequence forms of
smoothing_roundsandinteraction_smoothing_rounds.Changes
boost()decrements the per-term smoothing counters in place, so it now works on its own copy. Every outer bag starts with its full budget, including when bags run in-process (n_jobs=1).smoothing_roundsare unchanged.interaction_smoothing_roundsis checked against the cleanedinteractionslist before any boosting starts. One-shot iterables such asitertools.combinations(...)work too.range,pandas.Series, and NumPy scalars. Whole-number checks use each value's own precision, including extended-precisionlongdouble. Booleans, strings, and values beyond the int64 range are rejected.to_jsonwrites the smoothing parameters as built-in integers, or lists of them, so NumPy inputs such aslongdoubleserialize.smoothing_roundsandinteraction_smoothing_roundsdocstrings describe the sequence forms consistently across estimators: entries for excluded features, or for duplicate or excluded interactions, are ignored, and features that finish smoothing early are not boosted until smoothing ends.Tests
New cases in
tests/glassbox/ebm/test_smoothing_rounds.pycover scalar/sequence equivalence with several outer bags, exclusion versus dropping the column, duplicate and excluded interaction entries, validation before boosting, array-like and NumPy scalar inputs (includinglongdouble), booleans, values beyond the int64 range, and JSON export.Validation
pytest tests/glassbox/ebm/test_smoothing_rounds.py: 51 passedpytest -m "not slow and not selenium" tests/glassbox/ebm/: 383 passed, 42 skippedruff format --check/ruff checkon the changed files: no new findingsmypy: no new errors