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 35/optimize personalization calculation #36

Conversation

ibuda
Copy link
Contributor

@ibuda ibuda commented Oct 26, 2021

This relates to #35.
As the cosine similarity metric is symmetric, we don't need the upper triangle indices to calculate the mean of the matrix.
Just subtract the diagonal (all ones) and divide by the number of distances (without the diagonal).
This way the performance is increased and is noticeable on matrices over 50k x 50k.
All tests passed.
Performance before and after the modification (skipping make_rec_matrix):
performance

@statisticianinstilettos
Copy link
Owner

Hello @ibuda thanks for this contribution. Great improvement to the code!

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.

2 participants