Skip to content

Conversation

VijayVignesh1
Copy link

@VijayVignesh1 VijayVignesh1 commented Sep 19, 2025

What does this PR do?

Fixes #3096

Before submitting
  • Was this discussed/agreed via a Github issue? (no need for typos and docs improvements)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure to update the docs?
  • Did you write any new necessary tests?
PR review
Added MaskedBinaryAUROC class implementation which updates the preds and target list with the corresponding mask. The other methods (compute, plot) remain the same.
Added all the relavant testcases.

Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in Github issues there's a high chance it will not be merged.

Did you have fun?

Make sure you had fun coding 🙃


📚 Documentation preview 📚: https://torchmetrics--3268.org.readthedocs.build/en/3268/

@VijayVignesh1 VijayVignesh1 marked this pull request as ready for review September 19, 2025 17:26
@Borda Borda requested a review from Copilot September 19, 2025 19:48
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements MaskedBinaryAUROC metric to support masked labels in binary classification tasks, addressing issue #3096. This allows users to exclude certain predictions/targets from AUROC computation using a boolean mask.

Key changes include:

  • Added MaskedBinaryAUROC class that extends BinaryAUROC with mask support
  • Enhanced the AUROC wrapper to support the new "maskedbinary" task type
  • Comprehensive test coverage for the new masked functionality

Reviewed Changes

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

Show a summary per file
File Description
src/torchmetrics/classification/auroc.py Core implementation of MaskedBinaryAUROC class and AUROC wrapper updates
src/torchmetrics/classification/init.py Export the new MaskedBinaryAUROC class
src/torchmetrics/utilities/enums.py Added "maskedbinary" classification task enum
tests/unittests/classification/test_auroc.py Comprehensive test suite for masked binary AUROC functionality
tests/unittests/classification/_inputs.py Test input data structures for masked binary cases
CHANGELOG.md Documentation of the new feature

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Adding optional type for mask

Co-authored-by: Copilot <[email protected]>
Copy link

codecov bot commented Sep 22, 2025

Codecov Report

❌ Patch coverage is 33.33333% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 37%. Comparing base (3eb05bf) to head (8f311a7).

❌ Your project check has failed because the head coverage (37%) is below the target coverage (95%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #3268    +/-   ##
=======================================
- Coverage      37%     37%    -1%     
=======================================
  Files         364     349    -15     
  Lines       20096   19916   -180     
=======================================
- Hits         7520    7331   -189     
- Misses      12576   12585     +9     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@VijayVignesh1
Copy link
Author

@Borda The unittest error seems to be coming from TestMultilabelLogAUC, an unrelated file to this PR. Similarly, the build docs error seems to be coming from logauc.py. This file was not touched.
/home/runner/work/torchmetrics/torchmetrics/src/torchmetrics/functional/classification/logauc.py:52: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.detach().clone() or sourceTensor.detach().clone().requires_grad_(True), rather than torch.tensor(sourceTensor).

@VijayVignesh1
Copy link
Author

@Borda The unittest error seems to be coming from TestMultilabelLogAUC, an unrelated file to this PR. Similarly, the build docs error seems to be coming from logauc.py. This file was not touched. /home/runner/work/torchmetrics/torchmetrics/src/torchmetrics/functional/classification/logauc.py:52: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.detach().clone() or sourceTensor.detach().clone().requires_grad_(True), rather than torch.tensor(sourceTensor).

There was a bug in _inputs.py. It should be clear now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide BinaryAUROC support for Masked/Sparse Labels
1 participant