import streamlit as st import pandas as pd import joblib import requests # Title st.title("🛒 SuperKart Sales Forecasting") st.markdown("Enter product and store details to predict sales.") # Input fields product_weight = st.number_input("Product Weight (kg)", min_value=1.0, step=0.1) product_sugar_content = st.selectbox("Sugar Content", ["Low Sugar", "Regular", "No Sugar", "Sugar Free"]) product_allocated_area = st.slider("Display Area (%)", 0.0, 0.3, 0.05) product_type = st.selectbox("Product Type", [ "Meat", "Snack Foods", "Hard Drinks", "Dairy", "Canned", "Soft Drinks", "Health and Hygiene", "Baking Goods", "Bread", "Breakfast", "Frozen Foods", "Fruits and Vegetables", "Household", "Seafood", "Starchy Foods", "Others" ]) product_mrp = st.number_input("Product MRP (₹)", min_value=10.0, step=1.0) store_size = st.selectbox("Store Size", ["Small", "Medium", "High"]) store_location_city_type = st.selectbox("City Tier", ["Tier 1", "Tier 2", "Tier 3"]) store_type = st.selectbox("Store Type", [ "Departmental Store", "Supermarket Type1", "Supermarket Type2", "Food Mart" ]) store_age = st.slider("Store Age (Years)", 1, 40, 15) # Submit if st.button("Predict Sales"): input_data = { "Product_Weight": product_weight, "Product_Sugar_Content": product_sugar_content, "Product_Allocated_Area": product_allocated_area, "Product_Type": product_type, "Product_MRP": product_mrp, "Store_Size": store_size, "Store_Location_City_Type": store_location_city_type, "Store_Type": store_type, "Store_Age": store_age } # Call the backend API try: response = requests.post("https://.huggingface.space//predict", json=input_data) result = response.json() if "predicted_sales" in result: st.success(f"📈 Predicted Sales: ₹{result['predicted_sales']}") else: st.error(f"Error: {result.get('error', 'Unknown')}") except Exception as e: st.error(f"API call failed: {e}")