import streamlit as st import pandas as pd import requests # Set the title of the Streamlit app st.title("SuperKart Sales Revenue Prediction") # Section for online prediction st.subheader("Online Prediction") # Collect user input for property features store_id = st.selectbox("Store Id", ["OUT001", "OUT002", "OUT003","OUT004"]) 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_sugar_content = st.selectbox("Sugar Contents", ["Low Sugar","Regular","No Sugar","reg"]) product_mrp = st.number_input("MPR", min_value=1.0, max_value=500.0, step=1.0, value=90.0) product_weight = st.number_input("Product Weight", min_value=1.0, max_value=30.0, step=1.0, value=5.0) product_allocated_area = st.number_input("Allocated Display Area Ratio", min_value=0.001, max_value=0.3, step=0.001, value=0.10) # Convert user input into a DataFrame input_data = { 'store_id': store_id, 'product_type': product_type, 'product_sugar_content': product_sugar_content, 'product_mrp': product_mrp, 'product_weight': product_weight, 'product_allocated_area': product_allocated_area } # Make prediction when the "Predict" button is clicked if st.button("Predict"): response = requests.post("https://SRGL-SuperKartSalesRevenuePredictorBackend.hf.space/v1/sales", json=input_data) # Send data to Flask API if response.status_code == 200: prediction = response.json()['Predicted Sales Revenue'] st.success(f"Predicted Sales Revenue: {prediction}") else: st.error("Error making prediction.") st.error(input_data)