Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| import pandas as pd | |
| import joblib | |
| from huggingface_hub import hf_hub_download | |
| st.set_page_config(page_title="SuperKart Sales Predictor", layout="centered") | |
| st.title("SuperKart Sales Prediction") | |
| st.write("Predict **Product_Store_Sales_Total** using the trained SuperKart model hosted on Hugging Face.") | |
| MODEL_REPO = "atsh2846/superkart_model" | |
| MODEL_FILE = "superkart_model.joblib" | |
| def load_model(): | |
| model_path = hf_hub_download( | |
| repo_id=MODEL_REPO, | |
| filename=MODEL_FILE, | |
| repo_type="model" | |
| ) | |
| return joblib.load(model_path) | |
| model = load_model() | |
| st.subheader("Enter product & store details") | |
| # Inputs (match your dataset columns) | |
| Product_Id = st.text_input("Product_Id", value="NC6218") | |
| Product_Weight = st.number_input("Product_Weight", value=10.0) | |
| Product_Sugar_Content = st.selectbox("Product_Sugar_Content", ["Low Sugar", "Regular", "No Sugar"]) | |
| Product_Allocated_Area = st.number_input("Product_Allocated_Area", value=1200.0) | |
| Product_Type = st.text_input("Product_Type", value="Snack Foods") | |
| Product_MRP = st.number_input("Product_MRP", value=150.0) | |
| Store_Id = st.text_input("Store_Id", value="OUT049") | |
| Store_Establishment_Year = st.number_input("Store_Establishment_Year", value=2005) | |
| 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", ["Grocery Store", "Supermarket Type1", "Supermarket Type2", "Supermarket Type3"]) | |
| if st.button("Predict Sales"): | |
| row = { | |
| "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, | |
| "Store_Id": Store_Id, | |
| "Store_Establishment_Year": Store_Establishment_Year, | |
| "Store_Size": Store_Size, | |
| "Store_Location_City_Type": Store_Location_City_Type, | |
| "Store_Type": Store_Type, | |
| } | |
| X = pd.DataFrame([row]) | |
| pred = model.predict(X)[0] | |
| st.success(f"Predicted Product_Store_Sales_Total: {pred:.2f}") |