pal27's picture
Upload folder using huggingface_hub
6788cea verified
import streamlit as st
import pandas as pd
import numpy as np
import joblib
# Load the trained model
@st.cache_resource
def load_model():
return joblib.load("superkart_price_prediction_model_v1_0.joblib")
model = load_model()
# Streamlit UI for Price Prediction
st.title("Superkart Price Prediction App")
st.write("This tool predicts the revenue of Superkart outlets")
st.subheader("Enter the listing details:")
# Collect user input
Product_Weight = st.number_input("Product Weight", min_value=4, value=4)
Product_Sugar_Content = st.selectbox("Product Sugar Content", [ "Low sugar", "Regular", "No Sugar", "reg"])
Product_Allocated_Area = st.number_input("Product Allocated Area", min_value=0.004, step=0.001, value=0.056)
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=31, value=31)
Store_Establishment_Year = st.number_input("Store Establishment Year", min_value=1987, value=2002, max_value=2009)
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"])
# Convert user input 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_Establishment_Year': Store_Establishment_Year,
'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 revenue of the superkart outlet is ${prediction[0]}.")