statisticianinstilettos / recmetrics

A library of metrics for evaluating recommender systems
MIT License
561 stars 99 forks source link

Fix 35/optimize personalization calculation #36

Closed ibuda closed 2 years ago

ibuda commented 2 years ago

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 commented 2 years ago

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