Spaces:
Sleeping
Sleeping
update
Browse files- app.py +1 -1
- preprocessing.py +2 -0
- processed/summary_book.csv +0 -0
- recommend.py +1 -4
- weight/W.npy +1 -1
- weight/X.npy +1 -1
- weight/b.npy +1 -1
- weight/predicted.npy +1 -1
app.py
CHANGED
@@ -33,7 +33,7 @@ def recommend_books(user_id):
|
|
33 |
book_df = pd.read_csv(info_path)
|
34 |
book_df = book_df[book_df["Num-Rating"] > lb]
|
35 |
book_df['predict'] = book_df["ISBN"].map(predict_dict)
|
36 |
-
df = book_df.nlargest(num, "predict").reset_index(drop=True)
|
37 |
df["context"] = df.apply(
|
38 |
lambda book: f"{book['Book-Title']} ({book['Year-Of-Publication']}) - by {book['Book-Author']}", axis=1
|
39 |
)
|
|
|
33 |
book_df = pd.read_csv(info_path)
|
34 |
book_df = book_df[book_df["Num-Rating"] > lb]
|
35 |
book_df['predict'] = book_df["ISBN"].map(predict_dict)
|
36 |
+
df = book_df.nlargest(num, ["predict", "Mean-Rating"]).reset_index(drop=True)
|
37 |
df["context"] = df.apply(
|
38 |
lambda book: f"{book['Book-Title']} ({book['Year-Of-Publication']}) - by {book['Book-Author']}", axis=1
|
39 |
)
|
preprocessing.py
CHANGED
@@ -68,9 +68,11 @@ def main(
|
|
68 |
}
|
69 |
|
70 |
book_df = pd.read_csv(book_path, delimiter=';', encoding='ISO-8859-1', on_bad_lines='skip')
|
|
|
71 |
summary_rating = data.groupby("ISBN").agg(function, axis=0)
|
72 |
summary_rating = summary_rating.rename(columns={"Book-Rating": "Mean-Rating", "User-ID": "Num-Rating"})
|
73 |
df = book_df.merge(summary_rating, how="left", left_on="ISBN", right_on="ISBN")
|
|
|
74 |
df.drop(columns=["Image-URL-S", "Image-URL-M", "Image-URL-L"], inplace=True)
|
75 |
df.to_csv(f"{out_dir_path}/summary_book.csv", index=False)
|
76 |
|
|
|
68 |
}
|
69 |
|
70 |
book_df = pd.read_csv(book_path, delimiter=';', encoding='ISO-8859-1', on_bad_lines='skip')
|
71 |
+
book_df = book_df[book_df["ISBN"].isin(book_id_map.keys())]
|
72 |
summary_rating = data.groupby("ISBN").agg(function, axis=0)
|
73 |
summary_rating = summary_rating.rename(columns={"Book-Rating": "Mean-Rating", "User-ID": "Num-Rating"})
|
74 |
df = book_df.merge(summary_rating, how="left", left_on="ISBN", right_on="ISBN")
|
75 |
+
df = df.dropna()
|
76 |
df.drop(columns=["Image-URL-S", "Image-URL-M", "Image-URL-L"], inplace=True)
|
77 |
df.to_csv(f"{out_dir_path}/summary_book.csv", index=False)
|
78 |
|
processed/summary_book.csv
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
recommend.py
CHANGED
@@ -44,10 +44,7 @@ def main(
|
|
44 |
book_df = pd.read_csv(info_path)
|
45 |
book_df = book_df[book_df["Num-Rating"] > lb]
|
46 |
book_df['predict'] = book_df["ISBN"].map(predict_dict)
|
47 |
-
recommendations = book_df.nlargest(num, "predict").reset_index(drop=True)
|
48 |
-
recommendations["context"] = recommendations.apply(
|
49 |
-
lambda book: f"{book['Book-Title']} ({book['Year-Of-Publication']}) - by {book['Book-Author']}", axis=1
|
50 |
-
)
|
51 |
print(recommendations)
|
52 |
|
53 |
|
|
|
44 |
book_df = pd.read_csv(info_path)
|
45 |
book_df = book_df[book_df["Num-Rating"] > lb]
|
46 |
book_df['predict'] = book_df["ISBN"].map(predict_dict)
|
47 |
+
recommendations = book_df.nlargest(num, ["predict", "Mean-Rating"]).reset_index(drop=True)
|
|
|
|
|
|
|
48 |
print(recommendations)
|
49 |
|
50 |
|
weight/W.npy
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
size 13248
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:0e1757d82be4290dd18219aed88c0bf5df6953b2f3af4cf338e29b0c93a70f64
|
3 |
size 13248
|
weight/X.npy
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
size 79008
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:8ebb19a4f9774534e5775ea46fe36703eb3d48d8e277dff23e7a86e6d67bcf2c
|
3 |
size 79008
|
weight/b.npy
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
size 1440
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ab2d9d72e616728b7060219a68f925d533deade86b437b115c4eed1b44d36e71
|
3 |
size 1440
|
weight/predicted.npy
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
size 1293760
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:5d660b11ee4be0eee7f7a66d1b5bfebef5bdc50d253454c30a5c83334e7c3784
|
3 |
size 1293760
|