Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Information Retrieval (3/5) #139

Merged
merged 8 commits into from
Mar 29, 2021
Merged

Information Retrieval (3/5) #139

merged 8 commits into from
Mar 29, 2021

Conversation

lucadiliello
Copy link
Contributor

Before submitting

  • Was this discussed/approved 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?

What does this PR do?

Implements Precision (@k) for Information Retrieval. More info here.

PR review

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 🙃

@codecov
Copy link

codecov bot commented Mar 27, 2021

Codecov Report

Merging #139 (fc75878) into master (165cff0) will increase coverage by 0.07%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #139      +/-   ##
==========================================
+ Coverage   96.68%   96.76%   +0.07%     
==========================================
  Files         152      156       +4     
  Lines        4762     4816      +54     
==========================================
+ Hits         4604     4660      +56     
+ Misses        158      156       -2     
Flag Coverage Δ
Linux 79.27% <87.50%> (+0.06%) ⬆️
Windows 79.27% <87.50%> (+0.06%) ⬆️
cpu 96.76% <100.00%> (+0.07%) ⬆️
gpu 96.76% <ø> (+0.07%) ⬆️
macOS 96.76% <100.00%> (+0.07%) ⬆️
pytest 96.76% <100.00%> (+0.07%) ⬆️
python3.6 96.75% <100.00%> (+0.07%) ⬆️
python3.8 96.76% <100.00%> (+0.07%) ⬆️
python3.9 96.76% <100.00%> (+0.07%) ⬆️
torch1.3.1 95.54% <100.00%> (+0.09%) ⬆️
torch1.4.0 95.68% <100.00%> (+0.09%) ⬆️
torch1.8.1 96.76% <100.00%> (+0.07%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...hmetrics/functional/retrieval/average_precision.py 100.00% <ø> (ø)
...rchmetrics/functional/retrieval/reciprocal_rank.py 100.00% <ø> (ø)
torchmetrics/__init__.py 100.00% <100.00%> (ø)
torchmetrics/functional/__init__.py 100.00% <100.00%> (ø)
torchmetrics/functional/retrieval/__init__.py 100.00% <100.00%> (ø)
torchmetrics/functional/retrieval/precision.py 100.00% <100.00%> (ø)
torchmetrics/retrieval/__init__.py 100.00% <100.00%> (ø)
torchmetrics/retrieval/mean_average_precision.py 100.00% <100.00%> (ø)
torchmetrics/retrieval/mean_reciprocal_rank.py 100.00% <100.00%> (ø)
torchmetrics/retrieval/retrieval_precision.py 100.00% <100.00%> (ø)
... and 11 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 165cff0...fc75878. Read the comment docs.

@lucadiliello
Copy link
Contributor Author

Changed also the test of MRR to compare against the sklearn implementation instead of mine.
For Precision, I didn't find a reliable implementation :(

@Borda Borda added enhancement New feature or request New metric labels Mar 27, 2021
Copy link
Member

@SkafteNicki SkafteNicki left a comment

Choose a reason for hiding this comment

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

smaller comments else LGTM

@Borda Borda added this to the 0.3 milestone Mar 28, 2021
@SkafteNicki
Copy link
Member

@lucadiliello tests seems to be failing (missing import I think). Could you look into it? :]

@@ -21,7 +20,7 @@
class RetrievalMRR(RetrievalMetric):
"""
Computes `Mean Reciprocal Rank
<https://en.wikipedia.org/wiki/Mean_reciprocal_rank>`_.
<https://en.wikipedia.org/wiki/Mean_reciprocal_rank>`__.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
<https://en.wikipedia.org/wiki/Mean_reciprocal_rank>`__.
<https://en.wikipedia.org/wiki/Mean_reciprocal_rank>`__.

is this the correct link formatting?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I receive an error when doing make docs if I use a single underscore. This is probably caused by having the same link to wikipedia 2 times: 1 link in the Metric class and one in the functional version.
The error is:

/Users/lucadiliello/development/metrics/torchmetrics/functional/retrieval/reciprocal_rank.py:docstring of torchmetrics.functional.retrieval.reciprocal_rank.retrieval_reciprocal_rank:22: WARNING: Duplicate explicit target name: "here".

So I found that by using 2 underscores it does work.

@Borda Borda added the ready label Mar 29, 2021
@Borda Borda merged commit fb587af into Lightning-AI:master Mar 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants