Skip to content

🚀 feat(metric): added PGn, PBn metrics#2889

Merged
rajeshgangireddy merged 9 commits intoopen-edge-platform:mainfrom
abc-125:feat/metric/add-pg-pb
Sep 5, 2025
Merged

🚀 feat(metric): added PGn, PBn metrics#2889
rajeshgangireddy merged 9 commits intoopen-edge-platform:mainfrom
abc-125:feat/metric/add-pg-pb

Conversation

@abc-125
Copy link
Copy Markdown
Contributor

@abc-125 abc-125 commented Aug 16, 2025

📝 Description

Added PGn and PBn metrics for binary image-level classification tasks.
This module provides two metrics for evaluating binary image-level classification performance
on assumption that bad (anomalous) samples are considered to be positive class:

  • PGn: Presorted good with n% bad samples missed, can be interpreted as true negative rate
    at a fixed false negative rate (TNR@nFNR).
  • PBn: Presorted bad with n% good samples misclassified, can be interpreted as true positive rate
    at a fixed false positive rate (TPR@nFPR).

These metrics emphasize the practical applications of anomaly detection models by showing their potential
to reduce human operator workload while maintaining an acceptable level of misclassification.

More details can be found in this paper.

✨ Changes

  • Added metrics in src/anomalib/metrics/pg_pb.py
  • Updated src/anomalib/metrics/__init__.py
  • Added tests in tests/unit/metrics/test_pg_pb.py

Select what type of change your PR is:

  • 🚀 New feature (non-breaking change which adds functionality)
  • 🐞 Bug fix (non-breaking change which fixes an issue)
  • 🔄 Refactor (non-breaking change which refactors the code base)
  • ⚡ Performance improvements
  • 🎨 Style changes (code style/formatting)
  • 🧪 Tests (adding/modifying tests)
  • 📚 Documentation update
  • 📦 Build system changes
  • 🚧 CI/CD configuration
  • 🔧 Chore (general maintenance)
  • 🔒 Security update
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)

✅ Checklist

Before you submit your pull request, please make sure you have completed the following steps:

  • 📚 I have made the necessary updates to the documentation (if applicable).
  • 🧪 I have written tests that support my changes and prove that my fix is effective or my feature works (if applicable).
  • 🏷️ My PR title follows conventional commit format.

For more information about code review checklists, see the Code Review Checklist.

@rajeshgangireddy rajeshgangireddy self-requested a review August 18, 2025 13:13
Copy link
Copy Markdown
Contributor

@samet-akcay samet-akcay left a comment

Choose a reason for hiding this comment

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

Thanks @abc-125. Just a single minor comment. The rest looks great!

Copy link
Copy Markdown
Contributor

@rajeshgangireddy rajeshgangireddy left a comment

Choose a reason for hiding this comment

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

Thank you for the contribution.
Could you please add the URL to the paper in src/anomalib/metrics/pg_pb.py

@abc-125
Copy link
Copy Markdown
Contributor Author

abc-125 commented Sep 2, 2025

Thank you for the contribution. Could you please add the URL to the paper in src/anomalib/metrics/pg_pb.py

Yes, I have added the reference information.

@abc-125 abc-125 requested a review from samet-akcay September 2, 2025 16:50
Copy link
Copy Markdown
Contributor

@rajeshgangireddy rajeshgangireddy left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution. LGTM.

samet-akcay
samet-akcay previously approved these changes Sep 3, 2025
@samet-akcay samet-akcay enabled auto-merge (squash) September 3, 2025 08:14
auto-merge was automatically disabled September 3, 2025 18:13

Head branch was pushed to by a user without write access

@abc-125 abc-125 dismissed stale reviews from samet-akcay and rajeshgangireddy via 92865b9 September 3, 2025 18:13
Copy link
Copy Markdown
Contributor

@samet-akcay samet-akcay left a comment

Choose a reason for hiding this comment

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

lgtm thanks

@codecov-commenter
Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@rajeshgangireddy rajeshgangireddy merged commit fb7d494 into open-edge-platform:main Sep 5, 2025
11 checks passed
alexriedel1 pushed a commit to alexriedel1/anomalib that referenced this pull request Oct 6, 2025
* added pg and pb metrics

* fixed typos

* Update __init__.py

* Update __init__.py - removed duplicate

* Update pg_pb.py

* Fixed pre-commit checks

---------

Co-authored-by: Samet Akcay <samet.akcay@intel.com>
Co-authored-by: Rajesh Gangireddy <rajesh.gangireddy@intel.com>
@abc-125 abc-125 deleted the feat/metric/add-pg-pb branch March 22, 2026 15:07
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.

4 participants