Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| import requests | |
| st.title("SuperKart Sales Predictor") | |
| # replace with your backend endpoint URL | |
| BACKEND_URL = "https://gauravguha-superkartbe.hf.space/predict" | |
| # build input form | |
| mrp = st.number_input("Product MRP") | |
| weight = st.number_input("Product Weight") | |
| area = st.number_input("Allocated Area") | |
| age = st.number_input("Store Age") | |
| sugar = st.selectbox("Sugar Content", ["Low","Medium","High"]) | |
| ptype = st.selectbox("Product Type", ["A","B","C"]) | |
| size = st.selectbox("Store Size", ["Small","Medium","Large"]) | |
| city = st.selectbox("City Type", ["Tier 1","Tier 2","Tier 3"]) | |
| stype = st.selectbox("Store Type", ["Grocery","Supermarket"]) | |
| if st.button("Predict Sales"): | |
| payload = { | |
| "Product_MRP": mrp, | |
| "Product_Weight": weight, | |
| "Product_Allocated_Area": area, | |
| "Store_Age": age, | |
| "Product_Sugar_Content": sugar, | |
| "Product_Type": ptype, | |
| "Store_Size": size, | |
| "Store_Location_City_Type": city, | |
| "Store_Type": stype | |
| } | |
| r = requests.post(BACKEND_URL, json=payload) | |
| if r.status_code==200: | |
| st.success(f"Predicted Sales: ₹{r.json()['prediction']:.2f}") | |
| else: | |
| st.error(f"Error {r.status_code}: {r.text}") | |