import streamlit as st import pandas as pd import requests # Streamlit UI for SuperKart Outlet Sales Revenue Prediction st.title("SuperKart Outlet Sales Revenue Predictor") st.write("This app generates a forecast for the total store sales revenue of its outlets for the upcoming quarter.") st.write("Please enter the product and store details below to get a prediction.") # Collect user input st.subheader("Product Details") Product_Id = st.text_input("Product ID", "FD6114") Product_Weight = st.slider("Product Weight", 4.0, 22.0, 12.66, 0.01) Product_Sugar_Content = st.selectbox("Product Sugar Content", ['Low Sugar', 'Regular', 'No Sugar']) Product_Allocated_Area = st.slider("Product Allocated Area", 0.00, 0.30, 0.027, 0.001) Product_Type = st.selectbox("Product Type", [ 'Fruits and Vegetables', 'Snack Foods', 'Frozen Foods', 'Dairy', 'Household', 'Baking Goods', 'Canned', 'Health and Hygiene', 'Meat', 'Soft Drinks', 'Breads', 'Hard Drinks', 'Others', 'Starchy Foods', 'Breakfast', 'Seafood' ]) Product_MRP = st.slider("Product MRP (Maximum Retail Price)", 30.0, 270.0, 117.08, 0.01) st.subheader("Store Details") Store_Id = st.text_input("Store ID", "OUT004") Store_Establishment_Year = st.slider("Store Establishment Year", 1980, 2010, 2009, 1) Store_Size = st.selectbox("Store Size", ['Medium', 'High', 'Small']) Store_Location_City_Type = st.selectbox("Store Location City Type", ['Tier 1', 'Tier 2', 'Tier 3']) Store_Type = st.selectbox("Store Type", ['Supermarket Type2', 'Departmental Store', 'Supermarket Type1', 'Food Mart']) # Create input DataFrame input_data = { 'Product_Id': Product_Id, '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_Id': Store_Id, 'Store_Establishment_Year': Store_Establishment_Year, 'Store_Size': Store_Size, 'Store_Location_City_Type': Store_Location_City_Type, 'Store_Type': Store_Type } if st.button("Predict Sales Revenue", type='primary'): response = requests.post("https://chandrachurhghosh-Backend.hf.space/v1/outlet", json=input_data) if response.status_code == 200: result = response.json() predicted_sales = result["Predicted_Product_Store_Sales_Total"] st.success(f"💰 Predicted Product-Store Sales Total: **{predicted_sales:.2f}**") else: st.error(f"Error in API request: {response.status_code} - {response.text}") # Batch Prediction st.subheader("Batch Prediction") file = st.file_uploader("Upload CSV file for Batch Prediction", type=["csv"]) if file is not None: if st.button("Predict for Batch", type='primary'): response = requests.post("https://chandrachurhghosh-Backend.hf.space/v1/outletbatch", files={"file": file}) if response.status_code == 200: result = response.json() st.header("Batch Prediction Results") # Convert list of dicts to DataFrame for better display df_results = pd.DataFrame(result) st.dataframe(df_results) else: st.error(f"Error in API request for batch prediction: {response.status_code} - {response.text}")