superkart-streamlit / fe_app.py
siaese's picture
Upload folder using huggingface_hub
621f678 verified
import streamlit as st
import pandas as pd
import requests
# Streamlit UI for Customer Churn Prediction
st.title("SuperKart Sales Prediction App")
st.subheader("Online Sales Prediction")
# Collect user input based on dataset columns
Product_Id = st.number_input("Product ID", min_value=1, max_value=1000000, value=1)
Product_Weight = st.number_input("Product Weight (kg)", min_value=0.1, max_value=100.0, value=1.0, format="%.2f")
Product_Sugar_Content = st.selectbox("Product Sugar Content", ["Low", "Medium", "High"])
Product_Allocated_Area = st.number_input("Product Allocated Area (sq. units)", min_value=0.0, max_value=10000.0, value=100.0, format="%.2f")
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", min_value=0.0, max_value=10000.0, value=100.0, format="%.2f")
Product_Category = st.selectbox("Product_Category", ["FD", "NC", "DR"])
Store_Id = st.number_input("Store ID", min_value=1, max_value=1000000, value=1)
Store_Establishment_Year = st.number_input("Store Establishment Year", min_value=1900, max_value=2025, value=2000)
Store_Tenure = st.number_input("Store_Tenure", min_value=16, max_value=50, value=32)
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 Type2", "Departmental Store", "Supermarket Type1", "Food Mart"]) # Replace with actual store types
Perishability = st.selectbox("Perishability", ["Perishable", "Non-Perishable", "Unknown"]) # Replace with actual store types
# Convert user input to dataframe
input_data = {
"Product_Id": Product_Id,
"Product_Weight": Product_Weight,
"Product_Sugar_Content": Product_Sugar_Content,
"Product_Allocated_Area": Product_Allocated_Area,
"Product_Type": Product_Type,
"Product_MRP": Product_MRP,
"Product_Category": Product_Category,
"Store_Id": Store_Id,
"Store_Tenure": Store_Tenure,
"Store_Establishment_Year": Store_Establishment_Year,
"Store_Size": Store_Size,
"Store_Location_City_Type": Store_Location_City_Type,
"Store_Type": Store_Type,
"Perishability": Perishability
}
# Change as per requirement
if st.button("Predict"):
# response = requests.post("https://siaese/superkart-api/v1/sales", json=input_data.to_dict(orient="records")[0]) # enter user name and space name before running the cell
response = requests.post("https://siaese-superkart-api.hf.space/v1/sales", json=input_data) # enter user name and space name before running the cell
if response.status_code == 200:
prediction = response.json()["predicted_sales_price"]
st.success(f"Predicted Sales: {prediction}")
else:
st.error("Error making sales prediction")
# Sales Prediction
st.subheader("Sales Prediction")