Ansh91's picture
๐Ÿš€ Deploy working Streamlit frontend
9172dd6
import streamlit as st
import pandas as pd
import requests
st.set_page_config(page_title="SuperKart Forecaster", layout="wide")
st.title("๐Ÿš€ SuperKart Quarterly Sales Forecaster")
st.markdown("""
Use this interactive app to get **realโ€time sales forecasts** for products or entire store uploads.
Powered by a Dockerized Flask API on Hugging Face Spaces.
""")
# === Single Product Forecast ===
st.header("๐Ÿ” Single Product Forecast")
weight = st.number_input("Product Weight (kg)", min_value=0.1, value=12.65, step=0.1)
sugar = st.selectbox("Sugar Content", ["Low Sugar", "Regular", "No Sugar", "Unknown"])
area = st.number_input("Allocated Display Area (fraction)", min_value=0.001, max_value=1.0, value=0.0688, step=0.001)
p_type = st.text_input("Product Type", value="Fruits and Vegetables")
mrp = st.number_input("Product MRP (โ‚น)", min_value=0.0, value=147.03, step=1.0)
est_year = st.number_input("Store Establishment Year", min_value=1980, max_value=2025, value=2009, step=1)
store_size = st.selectbox("Store Size", ["Low", "Medium", "High"])
city_tier = st.selectbox("City Tier", ["Tier 1", "Tier 2", "Tier 3"])
store_type = st.selectbox("Store Type", ["Departmental Store", "Supermarket Type 1", "Supermarket Type 2", "Food Mart"])
if st.button("Predict Sales"):
payload = {
"Product_Weight": weight,
"Product_Sugar_Content": sugar,
"Product_Allocated_Area": area,
"Product_Type": p_type,
"Product_MRP": mrp,
"Store_Establishment_Year": est_year,
"Store_Size": store_size,
"Store_Location_City_Type": city_tier,
"Store_Type": store_type
}
API_URL = "https://ansh91--superkartpredictionbackend.hf.space/v1/forecast"
res = requests.post(API_URL, json=payload)
if res.status_code == 200:
result = res.json()
st.success(f"๐Ÿ›’ Predicted Quarterly Sales: โ‚น{result['Predicted_Sales']}")
else:
st.error(f"API Error {res.status_code}: {res.text}")