Tirath5504
commited on
Commit
•
f6796fc
1
Parent(s):
5043c87
Update app.py
Browse files
app.py
CHANGED
@@ -6,6 +6,7 @@ from sklearn.metrics.pairwise import cosine_similarity
|
|
6 |
|
7 |
pt = pd.read_pickle('pt.pkl')
|
8 |
user_similarity_scores = cosine_similarity(pt.T)
|
|
|
9 |
|
10 |
def recommend_books_for_user(user_id):
|
11 |
|
@@ -23,7 +24,11 @@ def recommend_books_for_user(user_id):
|
|
23 |
|
24 |
recommended_books.extend(unrated_books.index)
|
25 |
|
26 |
-
|
|
|
|
|
|
|
|
|
27 |
|
28 |
def recommend_books_gradio(user_id):
|
29 |
"""Recommends books for a user based on collaborative filtering"""
|
|
|
6 |
|
7 |
pt = pd.read_pickle('pt.pkl')
|
8 |
user_similarity_scores = cosine_similarity(pt.T)
|
9 |
+
books = pd.read_pickle("books.pkl")
|
10 |
|
11 |
def recommend_books_for_user(user_id):
|
12 |
|
|
|
24 |
|
25 |
recommended_books.extend(unrated_books.index)
|
26 |
|
27 |
+
recommended_books_set = set(recommended_books)
|
28 |
+
|
29 |
+
ans = [(book_title, image_url) for book_title, image_url in zip(books["Book-Title"], books["Image-URL-M"]) if book_title in recommended_books_set]
|
30 |
+
|
31 |
+
return ans
|
32 |
|
33 |
def recommend_books_gradio(user_id):
|
34 |
"""Recommends books for a user based on collaborative filtering"""
|