Redesign calibration loss as capped weighted MAPE#96
Merged
Conversation
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
Redesigns Populace calibration loss from squared bounded relative error to capped weighted MAPE:
This fixes the a912 failure mode where zero-valued/tiny fiscal rows dominated the objective and prevented meaningful movement on major targets like CTC.
Changes
populace.calibrate, defaulting tomax(abs(target), abs(initial_estimate), 1)after matrix compilation.0.02, which is better behaved for absolute-loss gradients.-1guard from matrix compilation; the new loss has no(target + 1)denominator.Sanity check
On the published a912 diagnostics, the old objective's top 10 rows accounted for ~99.9999989% of total loss. Under the new capped MAPE scoring on the same final estimates, the top 10 rows account for ~0.6%, so loss is no longer owned by a handful of zero/tiny rows.
Verification
uv run python -m pytest -qpasseduv run ruff check ...passed on changed Python filesgit diff --checkpassed/cyclereview: first pass found state rows were still getting national role boosts; fixed with regression coverage. Second pass found no actionable issues.