Nohafx commited on
Commit
0c96590
Β·
verified Β·
1 Parent(s): e240886

Upload streamlit_app.py

Browse files
Files changed (1) hide show
  1. streamlit_app.py +48 -0
streamlit_app.py ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import requests
3
+
4
+ API_URL = "https://nohafx-superkart-predictor.hf.space/predict"
5
+
6
+ st.title("πŸ›’ SuperKart Product Sales Predictor")
7
+ st.write("Enter product and store details to predict sales.")
8
+
9
+ product_weight = st.number_input("Product Weight", min_value=0.0, value=12.5)
10
+ product_sugar = st.selectbox("Product Sugar Content", ["Low Fat", "Regular", "Low Sugar"])
11
+ product_area = st.number_input("Product Allocated Area", min_value=0.0, max_value=1.0, value=0.05)
12
+ product_type = st.selectbox("Product Type", [
13
+ "Snack Foods", "Dairy", "Fruits and Vegetables",
14
+ "Frozen Foods", "Household", "Baking Goods",
15
+ "Canned", "Health and Hygiene", "Soft Drinks",
16
+ "Meat", "Breads", "Hard Drinks", "Others",
17
+ "Starchy Foods", "Breakfast", "Seafood"
18
+ ])
19
+ product_mrp = st.number_input("Product MRP", min_value=0.0, value=150.75)
20
+ store_size = st.selectbox("Store Size", ["Small", "Medium", "High"])
21
+ store_location = st.selectbox("Store Location City Type", ["Tier 1", "Tier 2", "Tier 3"])
22
+ store_type = st.selectbox("Store Type", [
23
+ "Supermarket Type1", "Supermarket Type2",
24
+ "Supermarket Type3", "Grocery Store"
25
+ ])
26
+ store_age = st.number_input("Store Age (Years)", min_value=0, value=15)
27
+
28
+ if st.button("πŸ” Predict Sales"):
29
+ input_data = {
30
+ "Product_Weight": product_weight,
31
+ "Product_Sugar_Content": product_sugar,
32
+ "Product_Allocated_Area": product_area,
33
+ "Product_Type": product_type,
34
+ "Product_MRP": product_mrp,
35
+ "Store_Size": store_size,
36
+ "Store_Location_City_Type": store_location,
37
+ "Store_Type": store_type,
38
+ "Store_Age": store_age
39
+ }
40
+ try:
41
+ response = requests.post(API_URL, json=input_data)
42
+ if response.status_code == 200:
43
+ prediction = response.json()["prediction"]
44
+ st.success(f"βœ… Predicted Sales: **${prediction:,.2f}**")
45
+ else:
46
+ st.error(f"❌ Error: {response.text}")
47
+ except Exception as e:
48
+ st.error(f"❌ Connection Error: {str(e)}")