subhankarfynd commited on
Commit
c3f3d16
·
1 Parent(s): b0a6a2a

Add initial files for Bougth Together Results

Browse files
bt_color.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8b47ec8cc1cb2a71cd307858c796d8995c6135dd0ab83d4d7856dab14c954699
3
+ size 34921428
bt_color_no_cat_order.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ccadd17b565b1d1b001f5b3993377d68e4cb98b8a7299d72a0e34ebbe307f741
3
+ size 34108444
bt_no_color.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:668b763870bba3c9a2c801f043dd70d1667d03ff399f0358ac9382352f1dcba9
3
+ size 34332666
entry.py ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pickle
3
+ from html_information import html
4
+
5
+
6
+ def load_pickle_file(file_name):
7
+ with open(file_name, 'rb') as f:
8
+ return pickle.load(f)
9
+
10
+
11
+ def streamlit_carousel(header_name: str, rec_item_url: list,
12
+ rec_item_name: list) -> None:
13
+ st.header(header_name)
14
+ mid_section = ""
15
+ for index, value in enumerate(rec_item_url):
16
+ mid_section += """<div class="item"><div id="image-container"><img src='""" + str(value) + """' /></div><p>""" + str(rec_item_name[index]) + """</p></div>"""
17
+
18
+ mid_html = html + mid_section + """</div></div></body>"""
19
+ st.markdown(mid_html, unsafe_allow_html=True)
20
+
21
+
22
+ def get_mapped_values(uid_list, uid_map_dict):
23
+ res = []
24
+ for val in uid_list:
25
+ res.append(uid_map_dict[val])
26
+ return res
27
+
28
+
29
+ uid_name_map = load_pickle_file('generalize_uid_name_map.pkl')
30
+ uid_media_map = load_pickle_file('generalize_uid_media_map.pkl')
31
+ bt_no_color_rec = load_pickle_file('bt_no_color.pkl')
32
+ bt_color_rec = load_pickle_file('bt_color.pkl')
33
+ bt_color_no_cat_order = load_pickle_file('bt_color_no_cat_order.pkl')
34
+
35
+
36
+
37
+ st.set_page_config(page_title="My App", page_icon=":guardsman:", layout="wide", initial_sidebar_state="auto")
38
+ st.header("Bought Together Recommendations")
39
+ uid_list = list(uid_name_map)
40
+ uid_name_list = get_mapped_values(uid_list, uid_name_map)
41
+ st.subheader("Choose a Product")
42
+ index = st.selectbox("Product List", range(len(uid_name_list)), format_func=lambda x: uid_name_list[x])
43
+ query_id = uid_list[index]
44
+ print(query_id)
45
+ print()
46
+ query_url = uid_media_map[query_id]
47
+ st.image(query_url, width=200)
48
+ for val in bt_no_color_rec:
49
+ if val["product_id"] == query_id:
50
+ text_rec_list = val["recommendations"]
51
+ print(text_rec_list)
52
+ if text_rec_list:
53
+ text_rec_url = []
54
+ text_rec_name = []
55
+ for val in text_rec_list:
56
+ text_rec_url.append(uid_media_map[val["product_id"]])
57
+ text_rec_name.append(uid_name_map[val["product_id"]])
58
+ streamlit_carousel("BT Recommendations No Color", text_rec_url, text_rec_name)
59
+ else:
60
+ st.write("No BT recommendations found")
61
+
62
+ for val in bt_color_rec:
63
+ if val["product_id"] == query_id:
64
+ text_rec_list = val["recommendations"]
65
+ print(text_rec_list)
66
+ if text_rec_list:
67
+ text_rec_url = []
68
+ text_rec_name = []
69
+ for val in text_rec_list:
70
+ text_rec_url.append(uid_media_map[val["product_id"]])
71
+ text_rec_name.append(uid_name_map[val["product_id"]])
72
+ streamlit_carousel("BT Recommendations Color", text_rec_url, text_rec_name)
73
+ else:
74
+ st.write("No BT recommendations found")
75
+
76
+ for val in bt_color_no_cat_order:
77
+ if val["product_id"] == query_id:
78
+ text_rec_list = val["recommendations"]
79
+ print(text_rec_list)
80
+ if text_rec_list:
81
+ text_rec_url = []
82
+ text_rec_name = []
83
+ for val in text_rec_list:
84
+ text_rec_url.append(uid_media_map[val["product_id"]])
85
+ text_rec_name.append(uid_name_map[val["product_id"]])
86
+ streamlit_carousel("BT Recommendations Color No Category Order", text_rec_url, text_rec_name)
87
+ else:
88
+ st.write("No BT recommendations found No Category Order")
89
+
90
+
91
+
92
+
generalize_uid_media_map.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2aaaaeb9ce0bada0ce217245d6d922cee8ac9ccb3aaa2f1274804384ab7404d0
3
+ size 1317791
generalize_uid_name_map.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c5fb8c2fc1814b5a30200a49da01cf8c3d56821ed372d71c56211749556f6bdc
3
+ size 466520
html_information.py ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ html = """
2
+ <style>
3
+ body{
4
+ font-family: sans-serif;
5
+ }
6
+ h1{
7
+ font-weight: 100;
8
+ }
9
+ .container{
10
+ width: 100%;
11
+ display:block;
12
+ overflow:hidden;
13
+ }
14
+ .carousel{
15
+ display:block;
16
+ width: 100%;
17
+ height: 320px;
18
+ background: white;
19
+ overflow-x: scroll;
20
+ padding: 10px;
21
+ margin: 0;
22
+ white-space: nowrap;
23
+ border-top: 2px solid rgba(0, 0, 0, 0.1);
24
+ border-bottom: 2px solid rgba(0, 0, 0, 0.1);
25
+ }
26
+ .item {
27
+ display: inline-block;
28
+ overflow: hidden;
29
+ width: 250px;
30
+ margin: 0 10px;
31
+ height: calc(100%);
32
+ background: rgba(0, 0, 0, 0.05) no-repeat center center;
33
+ background-size: cover;
34
+ position:relative;
35
+ border-radius: 20px;
36
+ box-shadow: 0 0 10px #dfdfdf;
37
+ }
38
+ .item p {
39
+ padding: 20px;
40
+ word-break: break-all;
41
+ white-space: break-spaces;
42
+ overflow: hidden;
43
+ display: -webkit-box;
44
+ -webkit-line-clamp: 4;
45
+ -webkit-box-orient: vertical;
46
+ margin: 0;
47
+ align: center;
48
+ }
49
+ #image-container{
50
+ width: 100%;
51
+ height: 60%;
52
+ text-align:center;
53
+ font-size: 9em;
54
+ color: white;
55
+ overflow: hidden;
56
+ }
57
+ #image-container img{
58
+ width: 100%;
59
+ height: 100%;
60
+ object-fit: contain;
61
+ }
62
+ </style>
63
+ </head>
64
+ <body>
65
+ <div class="container">
66
+ <div class="carousel">
67
+ """