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 Sales features # Collect user input product_Weight=st.number_input("Product_Weight", min_value=1, value=30.00) product_Sugar_Content=st.selectbox("Product Sugar Content", ["Low Sugar", "No Sugar", "Regular"]) product_Allocated_Area=st.number_input("Product Allocate Area", min_value=0.001, value=0.09) 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=1, value=30.00) store_Id=st.selectbox("Store ID", ["OUT001", "OUT002", "OUT003", "OUT004"]) store_Establishment_Year=st.number_input("Store Establishment year", min_value=1987, value=2009) store_Size=st.selectbox("Store Size", ["High", "Medium", "Small"]) store_Location_City_Type=st.selectbox("Store location City", ["Tier1", "Tier2", "Tier3"]) store_Type=st.selectbox("Store Type", ["Departmental Store", "Supermarket Type 1", "Supermarket Type 2", "Food Mart"]) # 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_Establishment_Year': store_Establishment_Year, '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://LalithaShiva-SalesAnalysisPredictionFrontend.hf.space/v1/sksales", json=input_data.to_dict(orient='records')[0]) # Send data to Flask API if response.status_code == 200: result = response.json()['Predicted Price (in dollars)'] st.success(f"Predicted Rental Price (in dollars): {prediction}") else: st.error("Error making prediction.")