Skip to content

ENH Added warning for ndcg_score when used w/ negative y_true values - #23461

Merged
jeremiedbb merged 31 commits into
scikit-learn:mainfrom
Micky774:ndcg-score
Jun 22, 2022
Merged

jeremiedbb merged 31 commits into
scikit-learn:mainfrom
Micky774:ndcg-score

Conversation

@Micky774

Copy link
Copy Markdown
Contributor

Reference Issues/PRs

Resolves #22710
Fixes #17639

What does this implement/fix? Explain your changes.

Adds warning for ndcg_score when used w/ negative y_true values

Any other comments?

Comment thread sklearn/metrics/_ranking.py Resolved
Comment thread sklearn/metrics/_ranking.py Resolved
Comment thread sklearn/metrics/_ranking.py Resolved
Comment thread sklearn/metrics/_ranking.py Resolved
Comment thread doc/whats_new/v1.2.rst Resolved

@thomasjpfan thomasjpfan 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.

I have not looked into the literature. Is there a valid use case for y_true < 0?

Comment thread sklearn/metrics/_ranking.py Resolved
Comment thread doc/whats_new/v1.2.rst Resolved
@Micky774

Micky774 commented Jun 7, 2022

Copy link
Copy Markdown
Contributor Author

I have not looked into the literature. Is there a valid use case for y_true < 0?

There was a bit of discussion about this in the original issue #17639. I'm largely basing this off of Wang et. al. 2013 which has ~250 citations (details) and affirms the expectation that NDCG is contained within $[0,1]$. More directly, this survey paper on information-retrieval methods also uses relevance values (y_true) no less than 0.

Indeed, with the idea of relevance in document retrieval where NDCG was first formulated, it makes more sense for an additional document to offer no information and have no relevance, than to remove information or relevance from the overall query. From what I've read so far, including this additional survey paper talking about IR methods overall, cumulative gain (CG) is assumed to be monotone non-decreasing, so I don't think that y_true<0 is a valid use case, at the very least not for what it was designed to do.

@thomasjpfan thomasjpfan 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.

Minor nit, otherwise LGTM.

Comment thread sklearn/metrics/_ranking.py Resolved
@thomasjpfan thomasjpfan added the Quick Review For PRs that are quick to review label Jun 7, 2022
@glemaitre
glemaitre self-requested a review June 13, 2022 18:35

@jeremiedbb jeremiedbb 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.

LGTM. I just fixed the what's new entry that was not in the appropriate section.
Thanks @Micky774

@jeremiedbb
jeremiedbb merged commit 9bb2098 into scikit-learn:main Jun 22, 2022
ogrisel pushed a commit to ogrisel/scikit-learn that referenced this pull request Jul 11, 2022
…ues (scikit-learn#23461)

Co-authored-by: trinhcon <[email protected]>
Co-authored-by: Victor Ko <[email protected]>
Co-authored-by: Thomas J. Fan <[email protected]>
Co-authored-by: Jérémie du Boisberranger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module:metrics Quick Review For PRs that are quick to review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ndcg_score fails for negative scores

5 participants