I created this book recommendation model by watching tutorials on youtube and searching articles online,now I want to use it for my react webapp. I have used TfidVectorizer to create a cosine similarity matrix to recommend books but I have no idea how to take that model and use it on my react webapp which is made using node.js and react.js.
def get_recommendations(book_title, cosine_sim=cosine_sim):
# Get the index of the movie that matches the title
idx = indices[book_title]
# Similarity scores
similarity_scores = list(enumerate(cosine_sim[idx]))
# Sort the books based on the similarity scores
similarity_scores = sorted(similarity_scores, key=lambda x: x[1], reverse=True)
# Get the scores of the six most similar books
similarity_scores = similarity_scores[1:6]
# Get the book indices
book_indices = [i[0] for i in similarity_scores]
# Return the top 5 most similar books
return book_summary['book_title'].iloc[book_indices]
This is the code for the recommendation function and I want to use this in my webapp