Skip to content

Instantly share code, notes, and snippets.

@horiacristescu
Last active December 9, 2019 18:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save horiacristescu/ebf6ab41ed4054639d7d02c857d97b36 to your computer and use it in GitHub Desktop.
Save horiacristescu/ebf6ab41ed4054639d7d02c857d97b36 to your computer and use it in GitHub Desktop.
Ranking by dot product
def inner_product_rank(self, vecs, threshold=0.5):
sims_mat = np.dot(vecs, vecs.transpose())
sims_mat = sims_mat - threshold
sims_mat[sims_mat<0] = 0
ranks = np.sum(sims_mat, axis=0)
return ranks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment