Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| import pandas as pd | |
| import requests | |
| # Set the title of the Streamlit app | |
| st.title("SuperKart Sales Prediction") | |
| # Section for online prediction | |
| st.subheader("Online Prediction") | |
| # Collect user input for property features | |
| Product_Weight = st.number_input("Enter Product Weight", min_value=0.0, value=1.0) | |
| Product_Allocated_Area = st.number_input("Enter Product Allocated Area", min_value=0.0, value=1.0) | |
| Product_MRP = st.number_input("Enter Product MRP", min_value=0.0, value=1.0) | |
| Store_Established_Year = st.number_input("Enter Store Established Year", min_value=1980, value=1987, max_value=2025)# [2009 1999 1987 1998] | |
| Product_Sugar_Content = st.selectbox("Select Product Sugar Content", ["No Sugar", "Low Sugar", "Regular"]) | |
| Store_Size = st.selectbox("Select Product Sugar Content", ["Small", "Medium", "High"]) | |
| Store_Location_City_Type = st.selectbox("Select Store Location City Type ", ["Tier 3", "Tier 2", "Tier 1"]) | |
| Product_Type = st.selectbox("Select Product Type ", ["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" ]) | |
| Store_Type = st.selectbox("Select Store Type ", ["Supermarket Type2", "Supermarket Type1", "Departmental Store","Food Mart"]) | |
| Store_Id = st.selectbox("Select Store Id ", ["OUT001", "OUT002", "OUT003","OUT004"]) | |
| # Convert user input into a DataFrame | |
| input_data = pd.DataFrame([{ | |
| "Product_Weight": Product_Weight, | |
| "Product_Allocated_Area": Product_Allocated_Area, | |
| "Product_MRP": Product_MRP, | |
| "Store_Established_Year": Store_Established_Year, | |
| "Product_Sugar_Content": Product_Sugar_Content, | |
| "Store_Size": Store_Size, | |
| "Store_Location_City_Type": Store_Location_City_Type, | |
| "Product_Type": Product_Type, | |
| "Store_Type": Store_Type, | |
| "Store_Id" :Store_Id | |
| }]) | |
| # Make prediction when the "Predict" button is clicked setuagrawal/salespredictorbackend | |
| if st.button("Predict"): | |
| response = requests.post("https://setuagrawal-salespredictorbackend.hf.space/v1/productsales", json=input_data.to_dict(orient='records')[0]) # Send data to Flask API | |
| if response.status_code == 200: | |
| prediction = response.json()['prediction'] | |
| st.success(f"Predicted Sales Value: {prediction}") | |
| else: | |
| st.error("Error making prediction.") | |