SuperKart / app.py
Srinivas1969's picture
Upload folder using huggingface_hub
09db914 verified
import streamlit as st
import pandas as pd
import joblib
# --- Load Trained Model ---
model = joblib.load("SuperKart_Sales_Predictor.joblib") # Make sure this path matches your folder structure
# --- UI Header ---
st.title("๐Ÿ›’ SuperKart Sales Forecasting")
st.markdown("Predict product sales by Filling the Parameters on the Side Bar")
# --- Sidebar Inputs ---
st.sidebar.header("๐Ÿ“ Store Attributes")
store_city = st.sidebar.selectbox("Store Location City Type", ['Tier 1', 'Tier 2', 'Tier 3'])
store_type = st.sidebar.selectbox("Store Type", ['Supermarket Type1', 'Supermarket Type2', 'Supermarket Type3', 'Departmental Store', 'Food Mart'])
store_size = st.sidebar.selectbox("Store Size", ['Small', 'Medium', 'High'])
store_age = st.sidebar.slider("Store Age (years)", min_value=0, max_value=50, value=10)
st.sidebar.header("๐Ÿ“ฆ Product Attributes")
product_type = st.sidebar.selectbox("Product Type", ['Dairy', 'Soft Drinks', 'Meat', 'Fruits and Vegetables', 'Household', 'Others'])
sugar_content = st.sidebar.selectbox("Sugar Content", ['Low', 'Medium', 'High'])
mrp_band = st.sidebar.selectbox("MRP Band", ['Low', 'Medium', 'High'])
product_weight = st.sidebar.number_input("Product Weight (kg)", min_value=0.0, max_value=50.0, value=10.0)
allocated_area = st.sidebar.number_input("Allocated Shelf Area (sq ft)", min_value=0.0, max_value=100.0, value=20.0)
product_mrp = st.sidebar.number_input("Product MRP (โ‚น)", min_value=0.0, max_value=500.0, value=100.0)
st.sidebar.header("๐Ÿ“Š Engineered Features")
avg_sales_product = st.sidebar.number_input("Avg Sales Per Product", min_value=0.0, value=500.0)
avg_sales_store = st.sidebar.number_input("Avg Sales Per Store", min_value=0.0, value=10000.0)
sales_rank = st.sidebar.number_input("Product Sales Rank", min_value=1, value=5)
store_product_share = st.sidebar.slider("Store Product Share", min_value=0.0, max_value=1.0, value=0.05)
# --- Prepare Input DataFrame ---
input_dict = {
'Product_Weight': product_weight,
'Product_Allocated_Area': allocated_area,
'Product_MRP': product_mrp,
'Store_Age': store_age,
'Avg_Sales_Per_Product': avg_sales_product,
'Avg_Sales_Per_Store': avg_sales_store,
'Product_Sales_Rank': sales_rank,
'Store_Product_Share': store_product_share,
'Product_Sugar_Content': sugar_content,
'Product_Type': product_type,
'Store_Size': store_size,
'Store_Location_City_Type': store_city,
'Store_Type': store_type,
'Product_MRP_Band': mrp_band
}
input_df = pd.DataFrame([input_dict])
# --- Prediction ---
if st.button("๐Ÿ”ฎ Predict Sales"):
prediction = model.predict(input_df)[0]
st.success(f"๐Ÿ“ˆ Predicted Sales: โ‚น{prediction:,.2f}")