Spaces:
Runtime error
Runtime error
samarthagarwal23
commited on
Commit
·
dd37b3a
1
Parent(s):
68e961d
Update app.py
Browse files
app.py
CHANGED
@@ -26,18 +26,26 @@ def user_query_recommend(query, price_rng):
|
|
26 |
# Recommend
|
27 |
recommendations = reviews.copy()
|
28 |
recommendations['sim'] = sim_scores.T
|
29 |
-
recommendations = recommendations.sort_values('sim', ascending=False)
|
30 |
if price_rng == "$0-$50":
|
31 |
min_p, max_p = 0, 50
|
32 |
if price_rng == "$50-$100":
|
33 |
min_p, max_p = 50, 100
|
34 |
if price_rng == "$100+":
|
35 |
min_p, max_p = 100, 10000
|
36 |
-
|
37 |
-
|
38 |
-
|
|
|
|
|
|
|
39 |
|
40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
interface = gr.Interface(
|
43 |
user_query_recommend,
|
|
|
26 |
# Recommend
|
27 |
recommendations = reviews.copy()
|
28 |
recommendations['sim'] = sim_scores.T
|
|
|
29 |
if price_rng == "$0-$50":
|
30 |
min_p, max_p = 0, 50
|
31 |
if price_rng == "$50-$100":
|
32 |
min_p, max_p = 50, 100
|
33 |
if price_rng == "$100+":
|
34 |
min_p, max_p = 100, 10000
|
35 |
+
|
36 |
+
op=recommendations\
|
37 |
+
.groupby("name")\
|
38 |
+
.agg({"sim":"max"})\
|
39 |
+
.reset_index()\
|
40 |
+
.set_axis(["name","sim"],axis='columns')
|
41 |
|
42 |
+
op = pd.merge(op,
|
43 |
+
recommendations[['name', 'category', 'price', 'description','description_sent','sim']],
|
44 |
+
how="left",on=["name",'sim'])
|
45 |
+
|
46 |
+
op = op.loc[(op.price >= min_p) & (op.price <= max_p), ['Name', 'Price', 'Description', 'Sim']]
|
47 |
+
|
48 |
+
return op.sort_values('sim',ascending=False).reset_index(drop=True).head(10)
|
49 |
|
50 |
interface = gr.Interface(
|
51 |
user_query_recommend,
|