SuperKartStore / app.py
Anusha3's picture
Upload folder using huggingface_hub
815ebe7 verified
import streamlit as st
import pandas as pd
import joblib
import numpy as np
# Load the trained model
@st.cache_resource
def load_model():
return joblib.load("superkart_sales_prediction_model_v1_0.joblib")
model = load_model()
# Streamlit UI
st.title("SuperKart Sales Prediction App")
st.write("This tool predicts the sales for a product based on its features and store details.")
st.subheader("Enter the product and store details:")
# Numeric inputs
Product_Weight = st.number_input("Product Weight (in grams)", min_value=0.0, value=500.0)
Product_Allocated_Area = st.number_input("Allocated Area (sq ft)", min_value=0.0, value=100.0)
Product_MRP = st.number_input("Product MRP", min_value=0.0, value=50.0)
Store_Establishment_Year = st.number_input("Store Establishment Year", min_value=1900, max_value=2025, value=2000)
# Categorical inputs
Product_Sugar_Content = st.selectbox("Product Sugar Content", ["Low", "Medium", "High"])
Product_Type = st.selectbox("Product Type", ["Food", "Beverage", "Snack", "Other"])
Store_Size = st.selectbox("Store Size", ["Small", "Medium", "Large"])
Store_Location_City_Type = st.selectbox("City Type", ["Tier 1", "Tier 2", "Tier 3"])
Store_Type = st.selectbox("Store Type", ["Mall", "Standalone", "Supermarket", "Other"])
# Convert user input into a DataFrame
input_data = pd.DataFrame([{
'Product_Weight': Product_Weight,
'Product_Allocated_Area': Product_Allocated_Area,
'Product_MRP': Product_MRP,
'Store_Establishment_Year': Store_Establishment_Year,
'Product_Sugar_Content': Product_Sugar_Content,
'Product_Type': Product_Type,
'Store_Size': Store_Size,
'Store_Location_City_Type': Store_Location_City_Type,
'Store_Type': Store_Type
}])
# Predict button
if st.button("Predict"):
prediction = model.predict(input_data)
st.write(f"The predicted sales for the product is {prediction[0]:.2f} units.")