Spaces:
Runtime error
Runtime error
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -104,50 +104,57 @@ st.title("ποΈ Advanced E-Commerce Price Predictor")
|
|
| 104 |
with st.container():
|
| 105 |
c1, c2 = st.columns([2, 1])
|
| 106 |
with c1:
|
| 107 |
-
p_name = st.text_input("Product Name", "
|
| 108 |
-
p_desc = st.text_area("Description", "
|
| 109 |
with c2:
|
| 110 |
-
|
| 111 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
condition = st.radio("Condition", ["New", "Used"], horizontal=True)
|
| 113 |
|
| 114 |
c_left, c_right = st.columns(2)
|
| 115 |
|
| 116 |
with c_left:
|
| 117 |
with st.expander("π¦ Physical, Stock & Shipping", expanded=True):
|
| 118 |
-
col1, col2 = st.columns(
|
| 119 |
weight = col1.number_input("Weight (g)", value=500)
|
| 120 |
-
stock = col2.number_input("Stock", value=
|
|
|
|
|
|
|
| 121 |
min_order = col1.number_input("Min Order", value=1)
|
| 122 |
-
max_order = col2.number_input("Max Order", value=
|
| 123 |
|
| 124 |
st.caption("Shipping Options")
|
| 125 |
sc1, sc2, sc3 = st.columns(3)
|
| 126 |
ship_inst = sc1.checkbox("Instant", False)
|
| 127 |
-
ship_same = sc2.checkbox("Same Day",
|
| 128 |
ship_next = sc3.checkbox("Next Day", False)
|
| 129 |
ship_reg = sc1.checkbox("Regular", True)
|
| 130 |
ship_cargo = sc2.checkbox("Cargo", False)
|
| 131 |
-
ship_eco = sc3.checkbox("Economy",
|
|
|
|
| 132 |
|
| 133 |
is_preorder = st.checkbox("Preorder?", False)
|
| 134 |
-
is_discount = st.checkbox("Discounted?",
|
| 135 |
|
| 136 |
with st.expander("πͺ Shop Performance", expanded=False):
|
| 137 |
shop_age = st.number_input("Shop Age (Days)", 365)
|
| 138 |
shop_pop = st.number_input("Shop Popularity Score", 100)
|
| 139 |
shop_city_pop = st.number_input("City Popularity", 1)
|
| 140 |
-
resp_time = st.number_input("Response Time (mins)",
|
| 141 |
date_shop_open = st.date_input("Shop Open Since", datetime(2020, 1, 1))
|
| 142 |
|
| 143 |
with st.expander("βοΈ Advanced Shop Setup (Detailed Ratings)", expanded=False):
|
| 144 |
st.caption("Input exact review counts for the entire shop")
|
| 145 |
ac1, ac2, ac3, ac4, ac5 = st.columns(5)
|
| 146 |
-
shop_r5 = ac1.number_input("Shop 5β
", value=
|
| 147 |
-
shop_r4 = ac2.number_input("Shop 4β
", value=
|
| 148 |
-
shop_r3 = ac3.number_input("Shop 3β
", value=
|
| 149 |
-
shop_r2 = ac4.number_input("Shop 2β
", value=
|
| 150 |
-
shop_r1 = ac5.number_input("Shop 1β
", value=
|
| 151 |
|
| 152 |
shop_total_rating = shop_r5 + shop_r4 + shop_r3 + shop_r2 + shop_r1
|
| 153 |
|
|
@@ -160,49 +167,45 @@ with c_left:
|
|
| 160 |
with c_right:
|
| 161 |
with st.expander("β Product Ratings & Reviews", expanded=True):
|
| 162 |
c1, c2, c3, c4, c5 = st.columns(5)
|
| 163 |
-
r5 = c1.number_input("Prod 5β
", value=
|
| 164 |
-
r4 = c2.number_input("Prod 4β
", value=
|
| 165 |
-
r3 = c3.number_input("Prod 3β
", value=
|
| 166 |
-
r2 = c4.number_input("Prod 2β
", value=
|
| 167 |
-
r1 = c5.number_input("Prod 1β
", value=
|
| 168 |
|
| 169 |
total_rating_count = r5 + r4 + r3 + r2 + r1
|
| 170 |
weighted_sum = (r5*5 + r4*4 + r3*3 + r2*2 + r1*1)
|
| 171 |
avg_rating = weighted_sum / total_rating_count if total_rating_count > 0 else 0.0
|
| 172 |
st.info(f"Avg Rating: {avg_rating:.2f} ({total_rating_count} ratings)")
|
| 173 |
|
| 174 |
-
total_reviews = st.number_input("Total Written Reviews", value=
|
| 175 |
-
reviews_w_img = st.number_input("Reviews w/ Images", value=
|
| 176 |
-
satisfaction = st.slider("Buyer Satisfaction %", 0, 100,
|
| 177 |
|
| 178 |
-
with st.expander("π¬ Review Topics", expanded=False):
|
| 179 |
tc1, tc2 = st.columns(2)
|
| 180 |
-
rev_qual = tc1.number_input("Quality",
|
| 181 |
-
rev_srv = tc2.number_input("Service",
|
| 182 |
-
rev_pack = tc1.number_input("Packaging",
|
| 183 |
-
rev_price = tc2.number_input("Price",
|
| 184 |
-
rev_desc = tc1.number_input("Description",
|
| 185 |
-
rev_ship = tc2.number_input("Shipping",
|
| 186 |
|
| 187 |
with st.expander("πΈ Media & Listing Date", expanded=False):
|
| 188 |
mc1, mc2 = st.columns(2)
|
| 189 |
-
vid_count = mc1.number_input("Videos",
|
| 190 |
-
img_count = mc2.number_input("Images",
|
| 191 |
-
date_listing = st.date_input("Listing Created", datetime
|
| 192 |
|
| 193 |
feat_created = get_date_features(date_listing, "created_at")
|
| 194 |
feat_shop = get_date_features(date_shop_open, "shop_open_since")
|
| 195 |
listing_age_calc = (datetime.now().date() - date_listing).days
|
| 196 |
|
| 197 |
-
shipping_flags = [ship_inst, ship_same, ship_reg, ship_cargo, ship_eco, ship_next]
|
| 198 |
-
total_shipping = sum(shipping_flags)
|
| 199 |
-
|
| 200 |
base_input = {
|
| 201 |
'product_name': p_name, 'description': p_desc, 'category': category,
|
| 202 |
'condition_encoded': 1 if condition == 'New' else 0,
|
| 203 |
'weight_grams': weight, 'min_order': min_order, 'max_order': max_order,
|
| 204 |
-
|
| 205 |
-
|
| 206 |
'is_preorder': 1 if is_preorder else 0,
|
| 207 |
'is_discount': 1 if is_discount else 0,
|
| 208 |
'is_regular_merchant': 1 if shop_tier == "Regular Merchant" else 0,
|
|
@@ -255,7 +258,7 @@ base_input = {
|
|
| 255 |
}
|
| 256 |
|
| 257 |
base_input['Log_stock'] = np.log1p(stock)
|
| 258 |
-
base_input['Log_sold'] = np.log1p(
|
| 259 |
|
| 260 |
st.divider()
|
| 261 |
st.subheader("π° Price Prediction")
|
|
|
|
| 104 |
with st.container():
|
| 105 |
c1, c2 = st.columns([2, 1])
|
| 106 |
with c1:
|
| 107 |
+
p_name = st.text_input("Product Name", "IBOX iP 13 128GB 256GB Second BEKAS ORIGINAL 100% Seken Apple | MULUS 13 NORMAL FULLSET")
|
| 108 |
+
p_desc = st.text_area("Description", "Sinyal ALL Oprator Quality Check Sebelum Mengirimkan Produk Garansi HP Dibantu Sampai Selesai Region : Usa Singapur China Korea Dll οΈοΈHARAP DICATAT: Sinyal ALL Oprator ICould aman asli 100% οΈInformasi yg Sering Ditanyakan 3utools Sinyal On Face id True Tone Kami pasti Quality Check sebelum mengirimkan pesanan. Bila produk sudah sampai test fungsi keseluruhan sebelum selesaikan transaksi. Jangan menyelesaikan pesanan sebelum unit benar benar di test fungsi keseluruhan untuk menjaga-jaga supaya tidak terjadi hal yang tidak diinginkan dan untuk claim garansi unit. ULAS DENGAN BIJAK Mohon untuk tidak langsung memberikan ulasan negatif dan bintang rendah sebelum komplain terselesaikan - BAD REVEW GARANSI HANGUS. Kelengkapan - Box (Ada kemungkinan Tidak ada stiker IMEI di Box) - Cable Tidak ada adaptor - Tidak ada garansi untuk Aksesoris Battery Health : 90%++ Request BH 95% Up to 100% : Bisa Silhakan Chat Tanya Admin Caranya KONDISI PRODUK : * ALL UNIT MULUS 98-99% * ALL OPERATOR (BISA SEMUA KARTU) * ALL UNIT ICLOUD AMAN * GARANSI 1 BULAN * TIDAK BISA REQUEST BATRE HEALTH SEGINI SEGINI . SILAHKAN TULIS DICATATAN, KITA USAHAKAN KIRIM BH 95+++. KETENTUAN RETUR BARANG : - Segel garansi harus utuh - Jangan terkena air atau cairan lainnya - Jangan terjatuh, retak, pecah - Jangan dibongkar / service sendiri - Tidak lock ICloud (Log out sebelum retur)")
|
| 109 |
with c2:
|
| 110 |
+
categories_list = get_categories()
|
| 111 |
+
category = st.selectbox("Category", categories_list, index=categories_list.index('Handphone & Tablet'))
|
| 112 |
+
shop_tier = st.selectbox(
|
| 113 |
+
"Shop Tier",
|
| 114 |
+
["Regular Merchant", "Power Merchant", "Official Store"]
|
| 115 |
+
)
|
| 116 |
condition = st.radio("Condition", ["New", "Used"], horizontal=True)
|
| 117 |
|
| 118 |
c_left, c_right = st.columns(2)
|
| 119 |
|
| 120 |
with c_left:
|
| 121 |
with st.expander("π¦ Physical, Stock & Shipping", expanded=True):
|
| 122 |
+
col1, col2, col3 = st.columns(3)
|
| 123 |
weight = col1.number_input("Weight (g)", value=500)
|
| 124 |
+
stock = col2.number_input("Stock", value=37)
|
| 125 |
+
sold = col3.number_input("Sold", value=584)
|
| 126 |
+
|
| 127 |
min_order = col1.number_input("Min Order", value=1)
|
| 128 |
+
max_order = col2.number_input("Max Order", value=38)
|
| 129 |
|
| 130 |
st.caption("Shipping Options")
|
| 131 |
sc1, sc2, sc3 = st.columns(3)
|
| 132 |
ship_inst = sc1.checkbox("Instant", False)
|
| 133 |
+
ship_same = sc2.checkbox("Same Day", False)
|
| 134 |
ship_next = sc3.checkbox("Next Day", False)
|
| 135 |
ship_reg = sc1.checkbox("Regular", True)
|
| 136 |
ship_cargo = sc2.checkbox("Cargo", False)
|
| 137 |
+
ship_eco = sc3.checkbox("Economy", False)
|
| 138 |
+
total_shipping = st.number_input("Total Shipping Types", value=2)
|
| 139 |
|
| 140 |
is_preorder = st.checkbox("Preorder?", False)
|
| 141 |
+
is_discount = st.checkbox("Discounted?", True)
|
| 142 |
|
| 143 |
with st.expander("πͺ Shop Performance", expanded=False):
|
| 144 |
shop_age = st.number_input("Shop Age (Days)", 365)
|
| 145 |
shop_pop = st.number_input("Shop Popularity Score", 100)
|
| 146 |
shop_city_pop = st.number_input("City Popularity", 1)
|
| 147 |
+
resp_time = st.number_input("Response Time (mins)", 360)
|
| 148 |
date_shop_open = st.date_input("Shop Open Since", datetime(2020, 1, 1))
|
| 149 |
|
| 150 |
with st.expander("βοΈ Advanced Shop Setup (Detailed Ratings)", expanded=False):
|
| 151 |
st.caption("Input exact review counts for the entire shop")
|
| 152 |
ac1, ac2, ac3, ac4, ac5 = st.columns(5)
|
| 153 |
+
shop_r5 = ac1.number_input("Shop 5β
", value=254)
|
| 154 |
+
shop_r4 = ac2.number_input("Shop 4β
", value=12)
|
| 155 |
+
shop_r3 = ac3.number_input("Shop 3β
", value=6)
|
| 156 |
+
shop_r2 = ac4.number_input("Shop 2β
", value=3)
|
| 157 |
+
shop_r1 = ac5.number_input("Shop 1β
", value=28)
|
| 158 |
|
| 159 |
shop_total_rating = shop_r5 + shop_r4 + shop_r3 + shop_r2 + shop_r1
|
| 160 |
|
|
|
|
| 167 |
with c_right:
|
| 168 |
with st.expander("β Product Ratings & Reviews", expanded=True):
|
| 169 |
c1, c2, c3, c4, c5 = st.columns(5)
|
| 170 |
+
r5 = c1.number_input("Prod 5β
", value=58)
|
| 171 |
+
r4 = c2.number_input("Prod 4β
", value=1)
|
| 172 |
+
r3 = c3.number_input("Prod 3β
", value=2)
|
| 173 |
+
r2 = c4.number_input("Prod 2β
", value=2)
|
| 174 |
+
r1 = c5.number_input("Prod 1β
", value=6)
|
| 175 |
|
| 176 |
total_rating_count = r5 + r4 + r3 + r2 + r1
|
| 177 |
weighted_sum = (r5*5 + r4*4 + r3*3 + r2*2 + r1*1)
|
| 178 |
avg_rating = weighted_sum / total_rating_count if total_rating_count > 0 else 0.0
|
| 179 |
st.info(f"Avg Rating: {avg_rating:.2f} ({total_rating_count} ratings)")
|
| 180 |
|
| 181 |
+
total_reviews = st.number_input("Total Written Reviews", value=52)
|
| 182 |
+
reviews_w_img = st.number_input("Reviews w/ Images", value=28)
|
| 183 |
+
satisfaction = st.slider("Buyer Satisfaction %", 0, 100, 85)
|
| 184 |
|
| 185 |
+
with st.expander("π¬ Count Review Topics", expanded=False):
|
| 186 |
tc1, tc2 = st.columns(2)
|
| 187 |
+
rev_qual = tc1.number_input("Quality", 47)
|
| 188 |
+
rev_srv = tc2.number_input("Service", 10)
|
| 189 |
+
rev_pack = tc1.number_input("Packaging", 4)
|
| 190 |
+
rev_price = tc2.number_input("Price", 11)
|
| 191 |
+
rev_desc = tc1.number_input("Description", 2)
|
| 192 |
+
rev_ship = tc2.number_input("Shipping", 5)
|
| 193 |
|
| 194 |
with st.expander("πΈ Media & Listing Date", expanded=False):
|
| 195 |
mc1, mc2 = st.columns(2)
|
| 196 |
+
vid_count = mc1.number_input("Videos", 1)
|
| 197 |
+
img_count = mc2.number_input("Images", 12)
|
| 198 |
+
date_listing = st.date_input("Listing Created", datetime(2025, 7, 28, 9, 11, 10))
|
| 199 |
|
| 200 |
feat_created = get_date_features(date_listing, "created_at")
|
| 201 |
feat_shop = get_date_features(date_shop_open, "shop_open_since")
|
| 202 |
listing_age_calc = (datetime.now().date() - date_listing).days
|
| 203 |
|
|
|
|
|
|
|
|
|
|
| 204 |
base_input = {
|
| 205 |
'product_name': p_name, 'description': p_desc, 'category': category,
|
| 206 |
'condition_encoded': 1 if condition == 'New' else 0,
|
| 207 |
'weight_grams': weight, 'min_order': min_order, 'max_order': max_order,
|
| 208 |
+
|
|
|
|
| 209 |
'is_preorder': 1 if is_preorder else 0,
|
| 210 |
'is_discount': 1 if is_discount else 0,
|
| 211 |
'is_regular_merchant': 1 if shop_tier == "Regular Merchant" else 0,
|
|
|
|
| 258 |
}
|
| 259 |
|
| 260 |
base_input['Log_stock'] = np.log1p(stock)
|
| 261 |
+
base_input['Log_sold'] = np.log1p(sold)
|
| 262 |
|
| 263 |
st.divider()
|
| 264 |
st.subheader("π° Price Prediction")
|