Skip to content

Map metric#71

Open
beeva-ramiromanso wants to merge 2 commits intomaciejkula:masterfrom
Rmwak:MAP_metric
Open

Map metric#71
beeva-ramiromanso wants to merge 2 commits intomaciejkula:masterfrom
Rmwak:MAP_metric

Conversation

@beeva-ramiromanso
Copy link
Copy Markdown

From #58

Wanted to add the MAP metric to the evaluation.py script.

Same interface as mrr_score. If the training dataset is provided, scores of known interactions are set to very low values to discard them.

Next step: Tweak it to calculate MAP@K

Copy link
Copy Markdown
Owner

@maciejkula maciejkula left a comment

Choose a reason for hiding this comment

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

Thanks a lot!

In addition to my inline comments, would you mind adding a test for the functionality as well?

Comment thread spotlight/evaluation.py

prec = []
ranking = np.sort(st.rankdata(predictions)[row.indices])
for index, value in enumerate(ranking):
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Could probably do prec = np.arange(1, len(ranking) + 1) / ranking or something similar to make use of vectorized numpy operations?

Comment thread spotlight/evaluation.py
prec.append((index + 1) / value)
ap.append(sum(prec) / len(ranking))

return np.mean(ap)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

The other metrics return raw arrays, leaving the averaging (or getting other descriptive statistics) down to the user. Could we do it this way here as well?

@beeva-ramiromanso
Copy link
Copy Markdown
Author

I'll try to create a small test for the metric. I have a controlled test with a set scoring instead of model.predict for the metric so I'll devise something.

As for the inline comments, sure, no problem.

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.

3 participants