Skip to content

feat: add ROC and PR curve pane types with Python API helpers - #1478

Merged
Saksham-Sirohi merged 27 commits into
fossasia:devfrom
Manik-Khajuria-5:ROC/PR-curve-implementation
Jul 8, 2026
Merged

feat: add ROC and PR curve pane types with Python API helpers#1478
Saksham-Sirohi merged 27 commits into
fossasia:devfrom
Manik-Khajuria-5:ROC/PR-curve-implementation

Conversation

@Manik-Khajuria-5

Copy link
Copy Markdown
Member

Description

Add vis.roc_curve() and vis.pr_curve() methods that accept either raw labels/scores or precomputed arrays. Both compute AUC automatically and render as Plotly lineplots with a baseline reference line.


Motivation and Context

Closes #1225. Users currently have to manually compute curve points and use vis.line(). Built-in helpers lower friction and improve consistency.


Screenshot

screenshot-2026-06-17_17-01-40

How Has This Been Tested?

  • Tested both methods with raw labels/scores and precomputed arrays using send=False mode
  • Ran python pr-roc.py against a local visdom server and verified both pane types render correctly
  • Verified npm run build compiles without errors
  • Validated edge cases: missing inputs, mismatched sizes, out-of-range values

Types of changes

  • New feature (non-breaking change which adds functionality)

Checklist:

  • I adapted the version number under py/visdom/VERSION according to Semantic Versioning
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @Manik-Khajuria-5, your pull request is larger than the review limit of 150000 diff characters

@Manik-Khajuria-5
Manik-Khajuria-5 force-pushed the ROC/PR-curve-implementation branch from ab1eee5 to 93711b0 Compare June 18, 2026 09:19
@Manik-Khajuria-5
Manik-Khajuria-5 marked this pull request as ready for review June 18, 2026 12:24

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @Manik-Khajuria-5, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@tonypzy tonypzy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we switch the PR-AUC from the trapezoidal rule to the average-precision form, Σ (R_n − R_{n-1}) · P_n? Becasue scikit-learn explicitly advises against the trapezoidal approach for PR curves.

Image

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds first-class ROC and Precision–Recall curve pane types to Visdom, including Python helpers that compute curve points + AUC (or accept precomputed points) and render them as Plotly line plots, with frontend pane registration so they display correctly.

Changes:

  • Add Visdom.roc_curve() and Visdom.pr_curve() helpers (raw labels/scores or precomputed arrays) with automatic AUC titles and baseline traces.
  • Allow plot windows to set a custom pane type (pane_type) so the frontend can distinguish ROC/PR panes from generic plots.
  • Register roc_curve / pr_curve as pane types in the React frontend and add a demo example component.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
README.md Documents the new vis.roc_curve and vis.pr_curve APIs and supported opts.
py/visdom/utils/server_utils.py Lets plot windows specify a custom pane type via pane_type.
py/visdom/init.pyi Adds typing stubs for roc_curve / pr_curve.
py/visdom/init.py Implements ROC/PR curve computation + rendering and sends pane_type to the server.
js/settings.js Registers roc_curve and pr_curve pane types (mapped to PlotPane) and sizes.
example/demo.py Wires the new ROC/PR demos into the main demo runner.
example/components/plot_roc_pr.py Adds example usage for ROC and PR curves (raw + precomputed ROC).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread py/visdom/utils/server_utils.py
Comment thread py/visdom/__init__.py Outdated
@Manik-Khajuria-5

Copy link
Copy Markdown
Member Author

@tonypzy Thanks I have appliead the trap formula Can u please review this PR again

@Manik-Khajuria-5
Manik-Khajuria-5 requested a review from tonypzy June 19, 2026 10:07

@tonypzy tonypzy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution! Since this PR introduces two new types (roc_curve and pr_curve), I think the code below in js/template/exportTemplate.js will cause a bug:

if ((t === 'plot' || t === 'surface') && c && c.data) {

This means these two new types of panels will be skipped entirely when exporting to HTML.

@tonypzy

tonypzy commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

I think we just need to change that line of code and open another issue and PR to solve the problem where the CI tests failed to discover that exported files are unexpected.
image

@Manik-Khajuria-5

Copy link
Copy Markdown
Member Author

@tonypzy Okay I am workung on it once this PR is merged I will raise a new PR for that or will add a fix within this PR only soon

@Manik-Khajuria-5

Copy link
Copy Markdown
Member Author

@tonypzy done PLease review again

@Manik-Khajuria-5
Manik-Khajuria-5 requested a review from tonypzy June 20, 2026 12:36
@Manik-Khajuria-5
Manik-Khajuria-5 requested a review from tonypzy June 30, 2026 11:39
@Manik-Khajuria-5

Copy link
Copy Markdown
Member Author

@rajnisht7 @vedansh-5 @tonypzy @Jayantparashar10 Please review this PR

@rajnisht7

Copy link
Copy Markdown
Contributor

@Manik-Khajuria-5 @tonypzy the failed html export can be corrected by replacing this line with
if ((t === 'plot' || t === 'surface' || t === 'roc_curve' || t === 'pr_curve') && c && c.data) {

hence kindly add this in this PR as well

@rajnisht7 rajnisht7 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Manik-Khajuria-5 the code works fine just a few suggestions

  • add cypress test atleast in integrartion/pane.js
  • remove roc_curve and pr_curve from settings.js as it is not maintained for each and every graph but is defined for all the plots, dimension for these plots can be added to integration/pane.js as well and then correct server_utils.py accordingly

@Jayantparashar10 Jayantparashar10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think changes in js/panes/ImageComparePane.js related to this PR

Comment thread py/visdom/__init__.py
@Manik-Khajuria-5

Copy link
Copy Markdown
Member Author

@rajnisht7 @Jayantparashar10 All necessary and relevant suggestion has been applied

@vedansh-5 vedansh-5 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

works fine, tested locally - please address the comments from Rajnish and Jayant.

@tonypzy

tonypzy commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

@Manik-Khajuria-5 @tonypzy the failed html export can be corrected by replacing this line with if ((t === 'plot' || t === 'surface' || t === 'roc_curve' || t === 'pr_curve') && c && c.data) {

hence kindly add this in this PR as well

I run locally and you are correct

@tonypzy tonypzy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please resolve @rajnisht7 's comments. except that, lgtm

@Manik-Khajuria-5

Copy link
Copy Markdown
Member Author

@rajnisht7 @Jayantparashar10 @tonypzy Please review this PR again I have made all suggestion properly

@tonypzy tonypzy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please resolve conflicts

@Manik-Khajuria-5
Manik-Khajuria-5 requested a review from tonypzy July 7, 2026 09:47
@Manik-Khajuria-5

Copy link
Copy Markdown
Member Author

@rajnisht7 @Jayantparashar10 @tony please review PR

@Jayantparashar10 Jayantparashar10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested it locally its working fine and also one thing that js/panes/ImageComparePane.js is unrelated to this PR

@Saksham-Sirohi
Saksham-Sirohi merged commit 6f8af32 into fossasia:dev Jul 8, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add PR/ROC curve panes + Python API helpers

8 participants