Repository navigation
Base the default error penalty on the scalar start value - #716
Open
hmgaudecker wants to merge 7 commits into
Open
hmgaudecker wants to merge 7 commits into
hmgaudecker wants to merge 7 commits into
Conversation
For least-squares and likelihood solvers the default penalty constant was built from the start criterion's residual or contribution vector, so it became an array: a least-squares penalty raised InvalidFunctionError and a likelihood penalty landed at the wrong level. The default now derives from the scalar start value for every aggregation level. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Hs8mfXPYyEa24KaAp6BwCW
Codecov Report✅ All modified and coverable lines are covered by tests.
... and 5 files with indirect coverage changes 🚀 New features to boost your workflow:
|
Member
|
Thanks! This bug was introduced during the major refactor in 2024. |
The default penalty constant is now always computed from the scalar start value, so constant and slope are floats for every aggregation level. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Split the explanation of the error penalty out of the how-to guide, state the two design constraints (finite values, implemented outside the solver) and add background on hidden constraints from the literature. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Cover all supported combinations of function type, solver type and direction, with numerical and closed-form derivatives. Extend the penalty unit tests to maximization and check that the default penalty is worse than the start value. bhhh cases are marked xfail because bhhh steps uphill when the derivative is consistent with the objective. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
Replace the toy problem by a Poisson regression for scalar and likelihood functions and a Gaussian nonlinear regression for least-squares functions, so that bhhh is tested on problems it is designed for. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Drop the tests for maximizing least-squares problems (already covered in test_function_formats_ls.py) and for incompatible solver types (moved to #720). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
janosg
approved these changes
Oct 19, 2026
janosg
left a comment
Member
There was a problem hiding this comment.
I reviewed the PR and the fix is correct.
I made two follow up changes:
- Split the documentation of error handling into How-To and Explanation and improve the explanation section.
- Add more comprehensive end-to-end tests for error handling with different solver types (which actually uncovered a few problems in BHHH).
I'm requesting a new review from @timmens. You can focus on the changes in documentation and tests.
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #715.
With
error_handling="continue", the default error penalty was built fromstart_criterion.internal_value(solver_type). For least-squares and likelihood solvers that is a vector, so:InvalidFunctionErrorinstead of being penalized;The default constant is now computed from the scalar start value for every aggregation level. The new test checks that, without explicit
error_penaltyoptions, the likelihood and least-squares penalties equal the scalar penalty of the same start value. It fails on main for both.https://claude.ai/code/session_01Hs8mfXPYyEa24KaAp6BwCW