import streamlit as st import pandas as pd import requests st.title("🛒 SuperKart Sales Forecast App") st.markdown(""" Use this interactive interface to forecast product-level sales for SuperKart stores based on store and product attributes. """) API_URL = "https://jkng77433-Backend.hf.space/v1/forecast/single" st.header("Single Prediction") col1, col2 = st.columns(2) with col1: product_id = st.text_input("Product ID", "FD6114") product_type = st.selectbox("Product Type", ["Frozen Foods", "Dairy", "Canned", "Snack Foods"]) sugar_content = st.selectbox("Product Sugar Content", ["Low Sugar", "Regular", "No Sugar"]) product_weight = st.number_input("Product Weight", min_value=0.1, value=12.66) product_mrp = st.number_input("Product MRP", min_value=0.0, value=117.08) with col2: store_id = st.text_input("Store ID", "OUT004") store_type = st.selectbox("Store Type", ["Supermarket Type1", "Supermarket Type2", "Departmental Store", "Food Mart"]) store_size = st.selectbox("Store Size", ["Small", "Medium", "High"]) store_location = st.selectbox("Store Location City Type", ["Tier 1", "Tier 2", "Tier 3"]) est_year = st.number_input("Store Establishment Year", min_value=1980, max_value=2025, value=2009) allocated_area = st.number_input("Product Allocated Area", min_value=0.0, max_value=1.0, value=0.027, format="%.3f") if st.button("Predict Sales"): payload = { "Product_Id": product_id, "Product_Type": product_type, "Product_Sugar_Content": sugar_content, "Product_Weight": product_weight, "Product_MRP": product_mrp, "Store_Id": store_id, "Store_Type": store_type, "Store_Size": store_size, "Store_Location_City_Type": store_location, "Store_Establishment_Year": est_year, "Product_Allocated_Area": allocated_area } response = requests.post(API_URL, json=payload) if response.status_code == 200: result = response.json() st.success(f"Predicted Sales: **${result['Predicted_Product_Store_Sales_Total']:.2f}**") else: st.error("Prediction failed — check input values or backend availability.")