Spaces:
Runtime error
Runtime error
| import streamlit as st | |
| import requests | |
| st.set_page_config(page_title="SuperKart Sales Forecast", layout="centered") | |
| st.title("SuperKart Sales Forecast") | |
| st.write("Predict **Product_Store_Sales_Total** using product and store attributes.") | |
| API_URL = "https://bmax16634-superkart-backend.hf.space/predict" | |
| product_id = st.text_input("Product_Id", "FD123") | |
| product_weight = st.number_input("Product_Weight", min_value=0.0, value=1.0) | |
| product_sugar = st.selectbox("Product_Sugar_Content", ["low sugar", "regular", "no sugar"]) | |
| allocated_area = st.number_input("Product_Allocated_Area", min_value=0.0, value=0.05) | |
| product_type = st.text_input("Product_Type", "dairy") | |
| mrp = st.number_input("Product_MRP", min_value=0.0, value=100.0) | |
| store_id = st.text_input("Store_Id", "S001") | |
| store_year = st.number_input("Store_Establishment_Year", min_value=1950, max_value=2030, value=2010) | |
| store_size = st.selectbox("Store_Size", ["low", "medium", "high"]) | |
| city_tier = st.selectbox("Store_Location_City_Type", ["Tier 1", "Tier 2", "Tier 3"]) | |
| store_type = st.selectbox( | |
| "Store_Type", | |
| ["Departmental Store", "Supermarket Type 1", "Supermarket Type 2", "Food Mart"] | |
| ) | |
| payload = { | |
| "Product_Id": product_id, | |
| "Product_Weight": product_weight, | |
| "Product_Sugar_Content": product_sugar, | |
| "Product_Allocated_Area": allocated_area, | |
| "Product_Type": product_type, | |
| "Product_MRP": mrp, | |
| "Store_Id": store_id, | |
| "Store_Establishment_Year": store_year, | |
| "Store_Size": store_size, | |
| "Store_Location_City_Type": city_tier, | |
| "Store_Type": store_type, | |
| } | |
| if st.button("Predict Sales"): | |
| try: | |
| response = requests.post(API_URL, json=payload, timeout=30) | |
| response.raise_for_status() | |
| prediction = response.json()["predictions"][0] | |
| st.success(f"Predicted Sales Revenue: **{prediction:,.2f}**") | |
| except Exception as e: | |
| st.error(f"Prediction failed: {e}") |