sachithcheruvaturfynd commited on
Commit
d511e29
1 Parent(s): d83f3e1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -3
app.py CHANGED
@@ -14,6 +14,8 @@ cross_sell_data = read_pickle_files("fynd.cross_sell_recommendations-00000000000
14
  upsell_data = read_pickle_files("fynd.up_sell_recommendations_000000000000000000000002s.pkl")
15
  uid_name_pairs = read_pickle_files("uid_name_pairs.pkl")
16
  uid_image_html_pairs = read_pickle_files("uid_image_html_pairs.pkl")
 
 
17
 
18
  # Create a mapping from product_id to product name for dropdown
19
  product_name_to_id = {name: uid for name, uid in uid_name_pairs.items()}
@@ -61,13 +63,18 @@ if selected_product_id:
61
  if selected_product_id in uid_image_html_pairs:
62
  image_url = uid_image_html_pairs[selected_product_id]
63
  st.image(image_url, use_column_width=False, width=450) # Set width to make image smaller
 
 
64
 
65
  # Display recommendations for the selected product
66
  if selected_product_id:
67
  recommendations = get_recommendations(selected_product_id, recommendations_data)
68
  reccomendation_names = []
69
  reccomendation_images = []
70
-
 
 
 
71
  if recommendations:
72
  #st.subheader(f"Recommendations:")
73
  if len(recommendations)>10:
@@ -78,6 +85,7 @@ if selected_product_id:
78
  for recommendation in recommendations:
79
  product_name = recommendation.get('product_name')
80
  recommended_product_id = recommendation.get('product_id')
 
81
 
82
  # Display the image of each recommended product using the image URL
83
  if recommended_product_id in uid_image_html_pairs:
@@ -86,6 +94,7 @@ if selected_product_id:
86
 
87
  reccomendation_names.append(product_name)
88
  reccomendation_images.append(recommended_image_url)
 
89
 
90
  # Display the product name
91
  #st.write(f"Product Name: {product_name}")
@@ -99,7 +108,7 @@ if selected_product_id:
99
  mid_section += f"""<div class="item">
100
  <div id="image-container"><img src='{reccomendation_images[index]}' /></div>
101
  <p style="font-size: 16px; font-weight: bold; white-space: normal; word-wrap: break-word;">{str(reccomendation_names[index])}</p>
 
102
  </div>"""
103
  mid_html = html2 + mid_section + """</div></div></body>"""
104
- st.markdown(mid_html, unsafe_allow_html=True)
105
-
 
14
  upsell_data = read_pickle_files("fynd.up_sell_recommendations_000000000000000000000002s.pkl")
15
  uid_name_pairs = read_pickle_files("uid_name_pairs.pkl")
16
  uid_image_html_pairs = read_pickle_files("uid_image_html_pairs.pkl")
17
+ item_costs_sephora_data = read_pickle_files("wavg_item_costs_sephora.pkl")
18
+
19
 
20
  # Create a mapping from product_id to product name for dropdown
21
  product_name_to_id = {name: uid for name, uid in uid_name_pairs.items()}
 
63
  if selected_product_id in uid_image_html_pairs:
64
  image_url = uid_image_html_pairs[selected_product_id]
65
  st.image(image_url, use_column_width=False, width=450) # Set width to make image smaller
66
+ st.write("Cost of chosen item:", str(round(item_costs_sephora_data[selected_product_id], 2)))
67
+
68
 
69
  # Display recommendations for the selected product
70
  if selected_product_id:
71
  recommendations = get_recommendations(selected_product_id, recommendations_data)
72
  reccomendation_names = []
73
  reccomendation_images = []
74
+ reccomendation_costs = []
75
+ # reccomendation_ids = [recommendations.get("product_id","item missing") for item in recommendations]
76
+ # item_costs_sephora = [item_costs_sephora_data.get(item, "cost missing") for item in reccomendation_ids]
77
+
78
  if recommendations:
79
  #st.subheader(f"Recommendations:")
80
  if len(recommendations)>10:
 
85
  for recommendation in recommendations:
86
  product_name = recommendation.get('product_name')
87
  recommended_product_id = recommendation.get('product_id')
88
+ recommended_product_cost = item_costs_sephora_data.get(recommended_product_id, "item missing")
89
 
90
  # Display the image of each recommended product using the image URL
91
  if recommended_product_id in uid_image_html_pairs:
 
94
 
95
  reccomendation_names.append(product_name)
96
  reccomendation_images.append(recommended_image_url)
97
+ reccomendation_costs.append(recommended_product_cost)
98
 
99
  # Display the product name
100
  #st.write(f"Product Name: {product_name}")
 
108
  mid_section += f"""<div class="item">
109
  <div id="image-container"><img src='{reccomendation_images[index]}' /></div>
110
  <p style="font-size: 16px; font-weight: bold; white-space: normal; word-wrap: break-word;">{str(reccomendation_names[index])}</p>
111
+ <p>{round(reccomendation_costs[index],2)}</p>
112
  </div>"""
113
  mid_html = html2 + mid_section + """</div></div></body>"""
114
+ st.markdown(mid_html, unsafe_allow_html=True)