sachithcheruvaturfynd commited on
Commit
de3f53e
·
verified ·
1 Parent(s): 2c0f282

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -6
app.py CHANGED
@@ -14,11 +14,13 @@ corrected_fp_growth_results_sephora = read_pickle_files("sephora_corrected_fp_gr
14
  all_products_with_names_sephora = read_pickle_files ("item_catalog.pkl")
15
  dictionary_of_transactions_sephora = read_pickle_files("transaction_metadata.pkl")
16
  images_sephora = read_pickle_files("uid_url_map.pkl")
 
 
17
 
18
  # Load digital pickle files
19
- corrected_fp_growth_results = read_pickle_files("reliance_digital_fpgrowth_results_demo.pkl")
20
- all_products_with_names = read_pickle_files ("all_products_with_names_demo.pkl")
21
- dictionary_of_transactions = read_pickle_files("reliance_digital_transactions_demo.pkl")
22
  item_costs_digital_data = read_pickle_files("avg_item_costs_reliance_digital_wa.pkl")
23
 
24
  # Dropdown for selecting the dataset
@@ -41,6 +43,7 @@ if dataset_choice == "Sephora Order Complete Dataset":
41
  query_id = name_to_id[selected_product_name]
42
  url = "https://www.sephora.com/"
43
  st.write("Created using the clickstream order-completed and catalog data from [Sephora.com](%s)" % url)
 
44
  query_url = images_sephora[int(query_id)]
45
  st.image(query_url, width=500)
46
 
@@ -60,7 +63,7 @@ if dataset_choice == "Reliance Digital Order Complete Dataset":
60
  url = "https://www.reliancedigital.in/"
61
  st.write("Created using the clickstream order-completed data from [reliancedigital.com](%s)" % url)
62
  st.write("An item is only recommended if it costs less than the chosen item.")
63
- st.write("Cost of chosen item:", str(round(item_costs_digital_data[query_id], 3)))
64
 
65
 
66
 
@@ -107,7 +110,8 @@ with tab2:
107
  # Separate the sorted items into IDs and counts
108
  item_ids = [item for item in corrected_fp_growth_results_sephora[query_id]]
109
  item_counts = [corrected_fp_growth_results_sephora[query_id][item] for item in corrected_fp_growth_results_sephora[query_id]]
110
-
 
111
  item_image = []
112
  for item in corrected_fp_growth_results_sephora[query_id]:
113
  try:
@@ -146,12 +150,14 @@ with tab2:
146
  count_info = f"Co-purchased {copurchase_count[index]}/{transactions_with_query_item} times"
147
  item_counts_info = f"item-count {item_counts[index]} "
148
  confidence_info = f"Confidence: {round(confidence_list[index], 3)}"
 
 
149
 
150
  # Use <br> to display each line separately
151
  mid_section += f"""<div class="item">
152
  <div id="image-container"><img src='{item_image[index]}' /></div>
153
  <p style="font-size: 16px; font-weight: bold; white-space: normal; word-wrap: break-word;">{str(product_names[index])}</p>
154
- <p>{count_info}<br>{confidence_info}<br></p>
155
  </div>"""
156
 
157
  mid_html = html2 + mid_section + """</div></div></body>"""
 
14
  all_products_with_names_sephora = read_pickle_files ("item_catalog.pkl")
15
  dictionary_of_transactions_sephora = read_pickle_files("transaction_metadata.pkl")
16
  images_sephora = read_pickle_files("uid_url_map.pkl")
17
+ item_costs_sephora_data = read_pickle_files("wavg_item_costs_sephora.pkl")
18
+
19
 
20
  # Load digital pickle files
21
+ corrected_fp_growth_results = read_pickle_files("corrected_fp_growth_results.pkl")
22
+ all_products_with_names = read_pickle_files ("all_products_with_names.pkl")
23
+ dictionary_of_transactions = read_pickle_files("reliance_digital_transactions.pkl")
24
  item_costs_digital_data = read_pickle_files("avg_item_costs_reliance_digital_wa.pkl")
25
 
26
  # Dropdown for selecting the dataset
 
43
  query_id = name_to_id[selected_product_name]
44
  url = "https://www.sephora.com/"
45
  st.write("Created using the clickstream order-completed and catalog data from [Sephora.com](%s)" % url)
46
+ st.write("Cost of chosen item:", str(round(item_costs_sephora_data[query_id], 2)))
47
  query_url = images_sephora[int(query_id)]
48
  st.image(query_url, width=500)
49
 
 
63
  url = "https://www.reliancedigital.in/"
64
  st.write("Created using the clickstream order-completed data from [reliancedigital.com](%s)" % url)
65
  st.write("An item is only recommended if it costs less than the chosen item.")
66
+ st.write("Cost of chosen item:", str(round(item_costs_digital_data[query_id], 2)))
67
 
68
 
69
 
 
110
  # Separate the sorted items into IDs and counts
111
  item_ids = [item for item in corrected_fp_growth_results_sephora[query_id]]
112
  item_counts = [corrected_fp_growth_results_sephora[query_id][item] for item in corrected_fp_growth_results_sephora[query_id]]
113
+ item_costs_sephora = [item_costs_sephora_data.get(item, "cost missing") for item in corrected_fp_growth_results_sephora[query_id]]
114
+
115
  item_image = []
116
  for item in corrected_fp_growth_results_sephora[query_id]:
117
  try:
 
150
  count_info = f"Co-purchased {copurchase_count[index]}/{transactions_with_query_item} times"
151
  item_counts_info = f"item-count {item_counts[index]} "
152
  confidence_info = f"Confidence: {round(confidence_list[index], 3)}"
153
+ item_cost_info_sephora = f"Cost: {round(item_costs_sephora[index],2)}"
154
+
155
 
156
  # Use <br> to display each line separately
157
  mid_section += f"""<div class="item">
158
  <div id="image-container"><img src='{item_image[index]}' /></div>
159
  <p style="font-size: 16px; font-weight: bold; white-space: normal; word-wrap: break-word;">{str(product_names[index])}</p>
160
+ <p>{count_info}<br>{confidence_info}<br>{item_cost_info_sephora}</p>
161
  </div>"""
162
 
163
  mid_html = html2 + mid_section + """</div></div></body>"""