[Feature]: Add NDCG (Normalized Discounted Cumulative Gain) metric to rec_sys#3670
Closed
steaphenai wants to merge 17 commits intopytorch:masterfrom
Closed
[Feature]: Add NDCG (Normalized Discounted Cumulative Gain) metric to rec_sys#3670steaphenai wants to merge 17 commits intopytorch:masterfrom
steaphenai wants to merge 17 commits intopytorch:masterfrom
Conversation
Added ranx = pytest.importorskip(...) to make ranx optional Wrapped ranx validation checks with if ranx is not None Added pytest.skip() for tests that specifically require ranx Tests now pass without ranx installed while still validating against it when available. The NDCG metric implementation itself has no ranx dependency.
Use try/except to handle missing ranx dependency instead of pytest.importorskip
Removed try/except import and conditional checks for ranx. ranx is now a required dev dependency in requirements-dev.txt, so tests can use it directly without fallback logic.
Co-authored-by: vfdev <vfdev.5@gmail.com>
Add detailed explanation of relevance types for NDCG.
Updated import statements and modified y_true generation in tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3581
Refs #3568 #3569 #3610
Description: Implements NDCG (Normalized Discounted Cumulative Gain) metric for recommendation systems and ranking evaluation.
Implementation Details
HitRateandMRRmetricsranxlibrary for verification (addressing [Feature]: Add Mean Reciprocal Rank (MRR) metric to rec_sys #3569 feedback)relevance_thresholddefaults to 1.0 for binary labelsstable=Truefor reproducible tie-breakingMathematical Background
Formula:
NDCG@K = Σ(2^rel_i - 1) / log2(i + 1)Testing
Check list: