Debashre2824's picture
Upload Streamlit app and model
207d71b verified
import streamlit as st
import pandas as pd
import joblib
# Load trained model pipeline
model = joblib.load('SuperKart_Mode_v2_0.joblib') # Update the path if needed
# App title
st.title("Sales Predictor")
# Sidebar inputs
st.sidebar.header("Input Product & Store Details")
product_weight = st.sidebar.slider("Product Weight (kg)", 1.0, 50.0, 13.5)
allocated_area = st.sidebar.slider("Allocated Area (0 to 1)", 0.001, 1.0, 0.08)
product_mrp = st.sidebar.slider("Product MRP (₹)", 1.0, 1000.0, 250.75)
store_age = st.sidebar.slider("Store Age (years)", 1, 100, 20)
sugar_content = st.sidebar.selectbox("Sugar Content", ["Low Sugar", "Regular", "No Sugar", "High Sugar"])
product_type = st.sidebar.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.sidebar.selectbox("Store Size", ["Small", "Medium", "High"])
city_tier = st.sidebar.selectbox("City Tier", ["Tier 1", "Tier 2", "Tier 3"])
store_type = st.sidebar.selectbox("Store Type", ["Departmental Store", "Supermarket Type1", "Supermarket Type2", "Food Mart"])
# Predict button
if st.sidebar.button("Predict Sales"):
input_data = pd.DataFrame({
"Product_Weight": [product_weight],
"Product_Allocated_Area": [allocated_area],
"Product_MRP": [product_mrp],
"Store_Age": [store_age],
"Product_Sugar_Content": [sugar_content],
"Product_Type": [product_type],
"Store_Size": [store_size],
"Store_Location_City_Type": [city_tier],
"Store_Type": [store_type]
})
prediction = model.predict(input_data)[0]
st.success(f"Predicted Sales: Rs{prediction:,.2f}")