frontend_space / app.py
Sandhya-2025's picture
Upload folder using huggingface_hub
e3e8eb3 verified
import streamlit as st
import pandas as pd
import requests
# Set the title of the Streamlit app
st.title("Superkart Product sales revenue Predictor")
# Section for online prediction
st.subheader("Online Prediction")
# Collect user input for property features
Product_Weight = st.number_input("Product Weight", min_value=4.0, max_value=25.0, step=1.0, value=15.14)
Product_Allocated_Area = st.number_input("Allocated Display Area Ratio", min_value=0.004, max_value=0.3, step=0.001,value=0.052,format="%.3f")
Product_MRP = st.number_input("Product MRP", min_value=10.0, max_value=500.0, step=1.0, value=148.06)
Product_Sugar_Content = st.selectbox("Sugar Content", ["Low Sugar", "Regular", "No Sugar"])
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"
])
Store_Size = st.selectbox("Store Size", ["High", "Medium", "Low"])
Store_Location_City_Type = st.selectbox("City Type", ["Tier 1", "Tier 2", "Tier 3"])
Store_Type = st.selectbox("Store Type", [
"Departmental Store","Supermarket Type 1","Supermarket Type 2","Food Mart"
])
Store_Id = st.selectbox("Store Id", ["OUT001","OUT002","OUT003","OUT004"])
# 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_Size': Store_Size,
'Store_Location_City_Type': Store_Location_City_Type,
'Store_Type': Store_Type,
'Store_Id': Store_Id
}])
# Make prediction when the "Predict" button is clicked
if st.button("Predict"):
response = requests.post("https://sandhya-2025-superkartrevenuepredictionbackend.hf.space/v1/salesRevenue", json=input_data.to_dict(orient='records')[0]) # Send data to Flask API
if response.status_code == 200:
prediction = response.json()['Predicted sales']
st.success(f"Predicted product sales revenue: {prediction}")
else:
st.error("Error making prediction.")