Repository navigation
1259: Match observed and predicted_label by label in logs_categorical() - #1277
Draft
nikosbosse wants to merge 2 commits into
Draft
nikosbosse wants to merge 2 commits into
nikosbosse wants to merge 2 commits into
Conversation
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1277 +/- ##
=======================================
Coverage 99.18% 99.18%
=======================================
Files 41 41
Lines 2331 2331
=======================================
Hits 2312 2312
Misses 19 19 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
CLAUDE:
Description
This PR closes #1259.
logs_categorical()reordered the columns ofpredictedby the level codes ofpredicted_label, but then picked the observed outcome by the level codes ofobserved. Nominal forecasts only require both factors to have the same set of levels, so with a different level order the log score of the wrong category was returned without an error (2.30 instead of 0.36 in the issue's example).The observed outcome is now matched to the probabilities by label.
rps_ordinal()is not affected, because ordinal forecasts require identical levels in the same order.Checklist
score()); I ran them against the unfixed code first, where they fail with 3 failed expectations, and they pass with the fix.lintr::lint_package()to check for style issues introduced by my changes. Linted the changed files, no lints.Adversarial review
An independent agent reviewed the PR. It compared the branch with a reference that matches by name on 2,000 random cases (random level orders, permuted columns, n = 1,
NAinobserved): 0 mismatches on the branch, 1,521 onmain.score(example_nominal)is identical onmainand the branch, and two deliberately wrong fixes were both caught by the new tests. No defects found.Not applied (optional suggestions): matching directly against
as.character(predicted_label)and dropping the column reorder. I kept the reorder becauserps_ordinal()uses the same idiom; and mentioning the level order in the argument docs.🤖 Generated with Claude Code