subratm62's picture
Upload folder using huggingface_hub
7d981ad verified
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")
# --- Categorical inputs ---
Product_Sugar_Content = st.selectbox(
"Product Sugar Content",
['Low Sugar', 'Regular', 'No Sugar']
)
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']
)
Store_Size = st.selectbox(
"Store Size",
['Medium', 'High', 'Small']
)
Store_Location_City_Type = st.selectbox(
"Store Location City Type",
['Tier 2', 'Tier 1', 'Tier 3']
)
Store_Type = st.selectbox(
"Store Type",
['Supermarket Type2', 'Departmental Store', 'Supermarket Type1', 'Food Mart']
)
Product_Category = st.selectbox(
"Product Category",
['Food Items', 'Non-Consumables', 'Drinks']
)
# --- Numerical inputs ---
Product_Weight = st.number_input("Product Weight (kg)", min_value=1.0, step=0.1, format="%.2f")
Product_Allocated_Area = st.number_input("Allocated Area (sq ft)", min_value=0.01, step=0.01, format="%.3f")
Product_MRP = st.number_input("Product MRP", min_value=1.0, step=0.1, format="%.2f")
Store_Age = st.number_input("Store Age (years)", min_value=1, step=1)
# --- Collect inputs 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_Age": [Store_Age],
"Product_Category": [Product_Category]
}])
# Make prediction when the "Predict" button is clicked
if st.button("Predict"):
# Send data to Flask API
response = requests.post("https://subratm62-SuperKartSalesBackend.hf.space/v1/sales", json=input_data.to_dict(orient='records')[0])
if response.status_code == 200:
prediction = response.json()['Predicted Sales (in INR)']
st.success(f"Predicted Sales Total (in INR): {prediction}")
else:
st.error("Error making prediction.")