Spaces:
Configuration error
Configuration error
🔥 Replace default demo with SuperKart UI
Browse files- streamlit_app.py +0 -55
streamlit_app.py
DELETED
|
@@ -1,55 +0,0 @@
|
|
| 1 |
-
import streamlit as st
|
| 2 |
-
import pandas as pd
|
| 3 |
-
import requests, os
|
| 4 |
-
|
| 5 |
-
# Page config
|
| 6 |
-
st.set_page_config(page_title="SuperKart Forecast", layout="centered")
|
| 7 |
-
st.title("🛒 SuperKart Quarterly Sales Forecast")
|
| 8 |
-
|
| 9 |
-
# Point to your Flask backend
|
| 10 |
-
BACKEND_URL = os.getenv("BACKEND_URL", "$BACKEND_URL")
|
| 11 |
-
|
| 12 |
-
# Input form
|
| 13 |
-
with st.form("forecast_form"):
|
| 14 |
-
c1, c2 = st.columns(2)
|
| 15 |
-
with c1:
|
| 16 |
-
pw = st.number_input("Product Weight (kg)", 0.0, 100.0, 12.5, 0.1)
|
| 17 |
-
pa = st.number_input("Allocated Area Ratio", 0.0, 1.0, 0.08, 0.005)
|
| 18 |
-
mrp = st.number_input("Product MRP (₹)", 0.0, 1000.0,50.0, 1.0)
|
| 19 |
-
year = st.number_input("Store Established Year",1900,2025,2015,1)
|
| 20 |
-
size = st.selectbox("Store Size", ["low","medium","high"])
|
| 21 |
-
with c2:
|
| 22 |
-
city = st.selectbox("City Tier", ["Tier 1","Tier 2","Tier 3"])
|
| 23 |
-
stype = st.selectbox("Store Type", [
|
| 24 |
-
"Departmental Store","Supermarket Type 1",
|
| 25 |
-
"Supermarket Type 2","Food Mart"
|
| 26 |
-
])
|
| 27 |
-
prefix = st.text_input("Product Prefix","FD")
|
| 28 |
-
pnum = st.number_input("Product Numeric ID", 0, 100000, 6114, 1)
|
| 29 |
-
age = st.number_input(
|
| 30 |
-
"Store Age (yrs)", 0, 50,
|
| 31 |
-
int(pd.Timestamp.now().year - year), 1
|
| 32 |
-
)
|
| 33 |
-
submitted = st.form_submit_button("🔮 Predict")
|
| 34 |
-
|
| 35 |
-
# Submit & show result
|
| 36 |
-
if submitted:
|
| 37 |
-
payload = {"data":[{
|
| 38 |
-
"Product_Weight":pw,
|
| 39 |
-
"Product_Allocated_Area":pa,
|
| 40 |
-
"Product_MRP":mrp,
|
| 41 |
-
"Store_Establishment_Year":year,
|
| 42 |
-
"Store_Size":size,
|
| 43 |
-
"Store_Location_City_Type":city,
|
| 44 |
-
"Store_Type":stype,
|
| 45 |
-
"Product_Prefix":prefix,
|
| 46 |
-
"Product_Num":pnum,
|
| 47 |
-
"Store_Age":age
|
| 48 |
-
}]}
|
| 49 |
-
try:
|
| 50 |
-
r = requests.post(f"{BACKEND_URL}/predict", json=payload, timeout=10)
|
| 51 |
-
r.raise_for_status()
|
| 52 |
-
pred = r.json()["predictions"][0]
|
| 53 |
-
st.success(f"🚀 Forecasted Sales: ₹{pred:,.2f}")
|
| 54 |
-
except Exception as e:
|
| 55 |
-
st.error(f"❌ Error: {e}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|