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

Fix average precision at k calculation #54

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

raminqaf
Copy link

@raminqaf raminqaf commented May 10, 2021

This PR fixes #49
According to the Wikipedia page of Average Precision the equation is defined as follow:
image
where rel(k) is an indicator function equaling 1 if the item at rank k is a relevant document, zero otherwise. Note that the average is over all relevant documents, and the relevant documents not retrieved get a precision score of zero.
Before, the average was calculated over the minimum value between the length of the actual value and k. This doesn't seem right since the length of the actual list of k increases; the AP@K will decrease.
I fixed and cleaned up the code. Please consider merging this! This could lead to many mistakes.

Copy link

@resivalex resivalex left a comment

Choose a reason for hiding this comment

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

Your version is correct

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.

wrong ap@k
2 participants