Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

FIX ensure proper point dropping in roc_curve with drop_interm…#31647

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
imran4444shaik wants to merge11 commits intoscikit-learn:main
base:main
Choose a base branch
Loading
fromimran4444shaik:main

Conversation

imran4444shaik
Copy link

@imran4444shaikimran4444shaik commentedJun 24, 2025
edited
Loading

Fixes#31635

BUG Fix two issues in roc_curve with drop_intermediate=True

  1. Fix incorrect ordering of point dropping vs prepending (0,0):

    • Now prepends (0,0) and inf threshold BEFORE dropping intermediates
  2. Replace faulty collinearity heuristic with geometric check:

    • Uses vector cross-products to properly detect collinear points
    • Fixes cases where redundant points weren't being dropped

Examples fixed:

  • y_true = [0,0,0,0,1,1,1,1], y_score = [0,1,2,3,4,5,6,7]
    Now correctly returns 3 points instead of 4

@github-actionsGitHub Actions
Copy link

github-actionsbot commentedJun 24, 2025
edited
Loading

✔️ Linting Passed

All linting checks passed. Your pull request is in excellent shape! ☀️

Generated for commit:44f9242. Link to the linter CI:here

@imran4444shaikimran4444shaikforce-pushed themain branch 3 times, most recently fromb131ea0 to7bf5946CompareJune 24, 2025 17:59
@Vishal-sys-code
Copy link

Vishal-sys-code commentedJun 28, 2025
edited
Loading

Thanks for this. The introduction ofcollinear_free_mask() is a particularly elegant solution. Using the geometric cross product to detect collinearity is a robust and generalizable method, and it correctly avoids the limitations of the previous second-difference heuristic, which could miss redundant points in many realistic ROC segments.

One minor suggestion: ensure thatfps is also prepended with0 before thedrop_intermediate logic (as is done fortps andthresholds), in case it's not already handled earlier in the flow. This keeps all arrays aligned and avoids subtle mismatches during masking.

Some minor linting issues remain; once those are resolved, this should be good to go. Do squash your commits also...

Only drops truly redundant points where both FPR and TPR are unchangedFIX ensure proper point dropping in roc_curve by prepending (0,0) before drop_intermediate and maintaining current heuristic for test compatibilityUpdated the test caseUpdated commitImprove roc_curve's drop_intermediate with geometric collinearity
@imran4444shaikimran4444shaikforce-pushed themain branch 3 times, most recently froma0af0e9 to9f9154dCompareJune 29, 2025 17:52
…d use cross‑product collinearity mask (always keeping the first finite threshold)
@imran4444shaikimran4444shaikforce-pushed themain branch 5 times, most recently fromcb076fb toac436b1CompareJune 30, 2025 13:25
@imran4444shaikimran4444shaikforce-pushed themain branch 3 times, most recently from88e5bc2 toeaa8aedCompareJuly 1, 2025 07:51
@imran4444shaikimran4444shaikforce-pushed themain branch 2 times, most recently from5e3f77d tof098d43CompareJuly 1, 2025 11:22
@imran4444shaikimran4444shaik changed the title#31635 FIX ensure proper point dropping in roc_curve with drop_interm…FIX ensure proper point dropping in roc_curve with drop_interm…Jul 1, 2025
@imran4444shaik
Copy link
Author

imran4444shaik commentedJul 4, 2025
edited
Loading

Hi !

This PR fixes two key bugs insklearn.metrics.roc_curve whendrop_intermediate=True:

  1. Incorrect point retention due to prepending (0,0) after dropping intermediates
  2. Faulty collinearity checks that only removed perfectly midway points

Bug 1: Incorrect Order of Operations
Before Fix:

Thresholds: [inf, 7, 4, 0]FPR: [0.0, 0.0, 0.0, 1.0]  ❌TPR: [0.0, 0.25, 1.0, 1.0] ❌ROC Curve:TPR1.0 |             ● (1,1)     |          /     |        ● (0,1)     |      /      |     ● (0,0.25)   ← Redundant point     |    /     |   ● (0,0)     +------------------ FPR        0.0          1.0

After Fix:

Thresholds: [inf, 4, 0] ✓FPR: [0.0, 0.0, 1.0] ✓TPR: [0.0, 1.0, 1.0] ✓ROC Curve:TPR1.0 |          ● (1,1)    |         /    |        ● (0,1)   ← Direct jump from (0,0)    |           |   ● (0,0)    +------------------ FPR     0.0              1.0

Problem: Intermediate points were dropped before adding (0,0), causing redundant points to remain.
Fix: We now add (0,0) FIRST before checking for intermediates.

Bug 2: Faulty Collinearity Detection
Before Fix (Horizontal Segment):

TPR1.0 |          ● (1,1)     |          |      |          ● (0.6,1)  ← Should be removed     |          |      |          ● (0.3,1)  ← Should be removed     |          |      |          ● (0.1,1)  ← Should be removed     |          |      |       ● (0,1)     |   ● (0,0)     +------------------ FPR      0.0  0.1 0.3 0.6 1.0

After Fix:

TPR1.0 |          ● (1,1)   |          |   |          |   |          |   |       ● (0,1)   ← Only essential points remain   |   ● (0,0)   +------------------ FPR    0.0              1.0

Problem: Old method only removed points exactly midway between neighbors.
Fix: New geometric test detects ANY collinear points using vector cross-product:

Before Fix (Diagonal Segment):

TPR1.0 |                  ● (1,1)     |               ● (0.9,0.9)     |           ● (0.7,0.7)     |       ● (0.4,0.4)     |   ● (0,0)     +------------------ FPR      0.0              1.0

After Fix:

TPR1.0 |                  ● (1,1)    |               /    |             /    |           /    |         /    |       /    |     /    |   ● (0,0)    +------------------ FPR     0.0              1.0

Thanks !

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Two bugs insklearn.metrics.roc_curve:drop_intermediate=True option
2 participants
@imran4444shaik@Vishal-sys-code

[8]ページ先頭

©2009-2025 Movatter.jp