Created
February 8, 2018 19:15
-
-
Save flaviovdf/3d085f8fe4a9951698925e786b89629a to your computer and use it in GitHub Desktop.
This file contains 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
def precision10(A_true, A_pred, k=10): | |
res = 0.0 | |
tmp = 0 | |
for i in range(A_true.shape[0]): | |
x = set(A_true[i].argsort()[::-1][:k]) | |
y = set(A_pred[i].argsort()[::-1][:k]) | |
res += len(x.intersection(y)) / len(x) | |
tmp += 1 | |
return res / tmp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment