Created
July 28, 2019 18:43
-
-
Save prateekjoshi565/e72755f69f892c8eb395cd2c54dc7507 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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