Skip to content

Instantly share code, notes, and snippets.

@prateekjoshi565
Created July 28, 2019 18:43
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 prateekjoshi565/e72755f69f892c8eb395cd2c54dc7507 to your computer and use it in GitHub Desktop.
Save prateekjoshi565/e72755f69f892c8eb395cd2c54dc7507 to your computer and use it in GitHub Desktop.
def similar_products(v, n = 6):
# extract most similar products for the input vector
ms = model.similar_by_vector(v, topn= n+1)[1:]
# extract name and similarity score of the similar products
new_ms = []
for j in ms:
pair = (products_dict[j[0]][0], j[1])
new_ms.append(pair)
return new_ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment