Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| import pandas as pd | |
| import requests | |
| # Streamlit UI for Price Prediction | |
| st.title("SuperKart Revenue Prediction App") | |
| st.write("This tool predicts the Revenue for SuperKart store based on the Product & Store details.") | |
| # Section for online prediction | |
| st.subheader("Online Prediction") | |
| # Collect user input | |
| Product_Weight = st.number_input("Product Weight (in kg)", min_value=0.0, step=0.1, value=12.66) # Default from example | |
| Product_Sugar_Content = st.selectbox("Product Sugar Content", ["Low Sugar", "No Sugar", "Regular", "reg"]) | |
| Product_Allocated_Area = st.number_input("Product Allocated Area Ratio", min_value=0.001, step=0.01, value=0.027) # Default from example | |
| Product_Type = st.selectbox("Product Type", ["Frozen Foods", "Dairy", "Canned", "Baking Goods", "Health and Hygiene", "Snack Foods", "Meat", "Household", "Hard Drinks", "Fruits and Vegetables", "Breads", "Soft Drinks", "Breakfast", "Others", "Starchy Foods", "Seafood"]) | |
| Product_MRP = st.number_input("Product MRP (in dollars)", min_value=0.0, step=0.1, value=117.08) # Default from example | |
| Store_Id = st.selectbox("Store Id", ["OUT001", "OUT002", "OUT003", "OUT004"]) | |
| Store_Age = st.number_input("Store_Age", min_value=16, max_value=38, value=20) | |
| Store_Size = st.selectbox("Store Size", ["Small", "Medium", "High"]) | |
| Store_Location_City_Type = st.selectbox("Store Location City Type", ["Tier 1", "Tier 2", "Tier 3"]) | |
| Store_Type = st.selectbox("Store Type", ["Supermarket Type1", "Supermarket Type2", "Food Mart", "Departmental Store"]) | |
| # Convert user input into a DataFrame | |
| input_data = pd.DataFrame([{ | |
| '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_Age': Store_Age, | |
| 'Store_Size': Store_Size, | |
| 'Store_Location_City_Type': Store_Location_City_Type, | |
| 'Store_Type': Store_Type | |
| }]) | |
| # Make prediction when the "Predict" button is clicked | |
| if st.button("Predict"): | |
| response = requests.post("https://ramanub-Superkartbe.hf.space/v1/sales", json=input_data.to_dict(orient='records')[0]) # Send data to Flask API | |
| if response.status_code == 200: | |
| prediction = response.json() | |
| st.success(f"Predicted Revenue in dollars is : {prediction}") | |
| else: | |
| st.error("Error making prediction.") | |