Repository navigation
[FIX] ROCCurve::cutoffNeg iterates negatives to match its denominator (#9488 ML-21) - #9617
Conversation
…OpenMS#9488 ML-21) Part of OpenMS#9488 (POLS high-severity checklist — **MATH / ML / COMPARISON**). ### [ML-21] `ROCCurve::cutoffNeg` — iterated positives but divided by the negative count `cutoffNeg()` walked only the **positive** samples (`if (cit->second)`) while dividing the running count by `neg_` (the number of negatives), so the returned cutoff was wrong (it mirrored the positive-side logic of `cutoffPos`). **Fix:** iterate over **negative** samples (`if (!cit->second)`) to match the `neg_` denominator, consistent with the sibling `cutoffPos`. **ABI:** none (function body only). **Test:** `ROCCurve_test` — `cutoffNeg` now returns a cutoff drawn from the negative score range. Co-Authored-By: Claude Opus 4.8 <[email protected]>
📝 WalkthroughWalkthroughFixed a logic bug in ChangescutoffNeg Bug Fix
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Adversarial review result: no blocking behavioral issue found in this pass. Required source cleanup before merge: the added implementation/test comments include tracker references. Please remove those references from source comments and keep the comments focused on the negative-sample iteration contract. I did not run the tests locally. |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/openms/source/ML/ROCCURVE/ROCCurve.cpp`:
- Around line 197-199: Remove the inline tracker reference from the ROCCurve
negative-sample comment and keep the wording focused on the iteration contract
only. Update the comment near the `cit->second` guard in `ROCCurve.cpp` so it
explains that the loop iterates over negative samples to match the division by
`neg_`, without mentioning `issue `#9488`` or `ML-21`.
In `@src/tests/class_tests/openms/source/ROCCurve_test.cpp`:
- Around line 81-93: Remove the tracker references from the comments in
ROCCurve_test so they no longer mention issue `#9488` or ML-21. Update the nearby
test comments around the ROCCurve::cutoffNeg setup to focus only on the behavior
being validated: that cutoffNeg(0.95) iterates over negatives and returns a
negative-class score, never a positive-class score.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 3a332468-0af1-4eb7-ad46-a33db3566132
📒 Files selected for processing (2)
src/openms/source/ML/ROCCURVE/ROCCurve.cppsrc/tests/class_tests/openms/source/ROCCurve_test.cpp
| // iterate over NEGATIVE samples (cit->second == false) to match the | ||
| // division by neg_; the guard was wrongly cit->second (issue #9488, ML-21) | ||
| if (!cit->second) |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
Drop the tracker reference from the code comment.
The comment cites issue #9488, ML-21 inline in source. Per the PR review feedback, tracker references should be removed and the comment kept focused on the negative-sample iteration contract.
✏️ Suggested comment cleanup
- // iterate over NEGATIVE samples (cit->second == false) to match the
- // division by neg_; the guard was wrongly cit->second (issue `#9488`, ML-21)
+ // iterate over NEGATIVE samples (cit->second == false) to match the
+ // division by neg_📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| // iterate over NEGATIVE samples (cit->second == false) to match the | |
| // division by neg_; the guard was wrongly cit->second (issue #9488, ML-21) | |
| if (!cit->second) | |
| // iterate over NEGATIVE samples (cit->second == false) to match the | |
| // division by neg_ | |
| if (!cit->second) |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/openms/source/ML/ROCCURVE/ROCCurve.cpp` around lines 197 - 199, Remove
the inline tracker reference from the ROCCurve negative-sample comment and keep
the wording focused on the iteration contract only. Update the comment near the
`cit->second` guard in `ROCCurve.cpp` so it explains that the loop iterates over
negative samples to match the division by `neg_`, without mentioning `issue
`#9488`` or `ML-21`.
| // deterministic check that cutoffNeg picks a NEGATIVE-class score (issue #9488, ML-21) | ||
| ROCCurve rc2; | ||
| // negatives at low scores, positives at high scores | ||
| rc2.insertPair(0.10, false); | ||
| rc2.insertPair(0.20, false); | ||
| rc2.insertPair(0.30, false); | ||
| rc2.insertPair(0.40, false); | ||
| rc2.insertPair(0.70, true); | ||
| rc2.insertPair(0.80, true); | ||
| rc2.insertPair(0.90, true); | ||
| rc2.insertPair(0.95, true); | ||
| // with the fix, cutoffNeg(0.95) walks negatives only and returns a | ||
| // negative-class score (<= 0.40), never a positive-class score (>= 0.70) |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
Drop the tracker reference from test comments.
Comments at Lines 81 and 92-93 cite issue #9488, ML-21. Per the PR review feedback, remove tracker references and keep the comments focused on the negative-sample iteration contract being tested.
✏️ Suggested comment cleanup
- // deterministic check that cutoffNeg picks a NEGATIVE-class score (issue `#9488`, ML-21)
+ // deterministic check that cutoffNeg picks a NEGATIVE-class score
ROCCurve rc2;
// negatives at low scores, positives at high scores
rc2.insertPair(0.10, false);
rc2.insertPair(0.20, false);
rc2.insertPair(0.30, false);
rc2.insertPair(0.40, false);
rc2.insertPair(0.70, true);
rc2.insertPair(0.80, true);
rc2.insertPair(0.90, true);
rc2.insertPair(0.95, true);
// with the fix, cutoffNeg(0.95) walks negatives only and returns a
- // negative-class score (<= 0.40), never a positive-class score (>= 0.70)
+ // negative-class score (<= 0.40), never a positive-class score (>= 0.70)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| // deterministic check that cutoffNeg picks a NEGATIVE-class score (issue #9488, ML-21) | |
| ROCCurve rc2; | |
| // negatives at low scores, positives at high scores | |
| rc2.insertPair(0.10, false); | |
| rc2.insertPair(0.20, false); | |
| rc2.insertPair(0.30, false); | |
| rc2.insertPair(0.40, false); | |
| rc2.insertPair(0.70, true); | |
| rc2.insertPair(0.80, true); | |
| rc2.insertPair(0.90, true); | |
| rc2.insertPair(0.95, true); | |
| // with the fix, cutoffNeg(0.95) walks negatives only and returns a | |
| // negative-class score (<= 0.40), never a positive-class score (>= 0.70) | |
| // deterministic check that cutoffNeg picks a NEGATIVE-class score | |
| ROCCurve rc2; | |
| // negatives at low scores, positives at high scores | |
| rc2.insertPair(0.10, false); | |
| rc2.insertPair(0.20, false); | |
| rc2.insertPair(0.30, false); | |
| rc2.insertPair(0.40, false); | |
| rc2.insertPair(0.70, true); | |
| rc2.insertPair(0.80, true); | |
| rc2.insertPair(0.90, true); | |
| rc2.insertPair(0.95, true); | |
| // with the fix, cutoffNeg(0.95) walks negatives only and returns a | |
| // negative-class score (<= 0.40), never a positive-class score (>= 0.70) |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/tests/class_tests/openms/source/ROCCurve_test.cpp` around lines 81 - 93,
Remove the tracker references from the comments in ROCCurve_test so they no
longer mention issue `#9488` or ML-21. Update the nearby test comments around the
ROCCurve::cutoffNeg setup to focus only on the behavior being validated: that
cutoffNeg(0.95) iterates over negatives and returns a negative-class score,
never a positive-class score.
, #9740 (#9744) Backfills changelog entries for a SQLite private-dependency change, a ROCCurve::cutoffNeg fix, a pyOpenMS Windows NO_DEPENDENCIES test fix, and the Ghostscript-to-MathJax documentation build change, none of which had CHANGELOG entries yet. Claude-Session: https://claude.ai/code/session_012hWmgLm1tVqhrwzBZsFN1X Co-authored-by: Claude <[email protected]>
Part of #9488 (POLS high-severity checklist — MATH / ML / COMPARISON).
[ML-21]
ROCCurve::cutoffNeg— iterated positives but divided by the negative countcutoffNeg()walked only the positive samples (if (cit->second)) while dividing the running count byneg_(the number of negatives), so the returned cutoff was wrong (it mirrored the positive-side logic ofcutoffPos).Fix: iterate over negative samples (
if (!cit->second)) to match theneg_denominator, consistent with the siblingcutoffPos.ABI: none (function body only).
Test:
ROCCurve_test—cutoffNegnow returns a cutoff drawn from the negative score range.🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Tests