[BUG] Fix incorrect UBRE score: bitwise NOT (~) used instead of logical NOT#572
Open
tarun-227 wants to merge 1 commit intodswah:mainfrom
Open
[BUG] Fix incorrect UBRE score: bitwise NOT (~) used instead of logical NOT#572tarun-227 wants to merge 1 commit intodswah:mainfrom
tarun-227 wants to merge 1 commit intodswah:mainfrom
Conversation
The UBRE formula used `~add_scale` (bitwise NOT) instead of `not add_scale` (logical NOT). In Python, `~True` evaluates to `-2` and `~False` to `-1`, rather than the intended `0` and `1`. This caused every UBRE score to be inflated by `2 * scale`, producing incorrect values in `statistics_["UBRE"]` for models with known scale (Poisson, Binomial). Model selection via gridsearch was unaffected since the offset is constant, but the reported scores were wrong. Reference: Wood 2006, section 4.5.1, pg 177-182.
cc801d9 to
1d5010a
Compare
Author
|
The |
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.
Summary
The UBRE (Un-Biased Risk Estimator) formula in
_estimate_GCV_UBREuses~add_scale(bitwise NOT) wherenot add_scale(logical NOT) was intended.In Python,
~Trueevaluates to-2and~Falseto-1, not0and1as expected:This causes the UBRE score to be inflated by
2 * scalefor every model with known scale (Poisson, Binomial). For Poisson models (scale=1), the reported UBRE is off by +2.0:Impact: While model selection via gridsearch is unaffected (constant offset doesn't change ranking), the UBRE values stored in
statistics_["UBRE"]are incorrect. This matters for users who inspect or compare UBRE scores directly.Fix: Replace
~add_scalewithnot add_scaleon line 1223.Test plan
test_UBRE_formula_matches_wood— verifies UBRE against the analytical formula from Wood 2006 for bothadd_scale=Trueandadd_scale=Falseruff format