I am building a book recommendation system using word2vec model. Where the outcome is the top 10 recommended books.
Training data
| Book_id | Book_Name | Description |
|---|---|---|
| 10201 | A Scanner Darkly | some description |
| 10210 | Absalom, Absalom! | some description |
from genism.models import Word2Vec
df=pd.read_csv("books.csv")
sentences=[i.split(" ") for i in df['Description']]
model=Word2Vec(sentences,min_count=1,workers=4,epochs=5,window=20)
model.wv.most_similar('scanner',topn=2)
Output -
[
('scanner',0.87455466655556666),
('absalom',0.71455466655556666),
]
The code predicted the correct keywords. Now I need to extract the course_id for the given keywords from dataframe. so the output will be
[
(10201,'A Scanner Darkly','scanner',0.87455466655556666),
('10210','Absalom, Absalom!','absalom',0.71455466655556666),
]
I tried using model.wv.index_to_key but it's incorrect. I can find index in Doc2Vec by using TaggedDocument but how can perform the same in Word2Vec to get the index of keyword in dataframe.