Spaces:
Runtime error
Runtime error
| import streamlit as st | |
| import pandas as pd | |
| import joblib | |
| st.set_page_config(page_title="SuperKart Predictor", page_icon="🛒") | |
| # Load model one time only | |
| def load_model(): | |
| return joblib.load("model.joblib") | |
| model = load_model() | |
| st.title("🛒 SuperKart Sales Prediction") | |
| st.write("Enter product details and click **Predict** to estimate sales.") | |
| # Input form | |
| product_weight = st.number_input("Product Weight", 0.0, value=12.0) | |
| product_mrp = st.number_input("Product MRP ($)", 0.0, value=149.99) | |
| sugar_content = st.selectbox("Product Sugar Content", ["Low Sugar", "Medium", "High"]) | |
| product_type = st.selectbox("Product Type", ["Home_Office", "Food", "Drinks", "Other"]) | |
| store_size = st.selectbox("Store Size", ["Small", "Medium", "Large"]) | |
| city_type = st.selectbox("Store City Type", ["Tier 1", "Tier 2", "Tier 3"]) | |
| store_type = st.selectbox("Store Type", ["Supermarket Type1", "Supermarket Type2", "Grocery Store"]) | |
| # Predict button | |
| if st.button("Predict Sales"): | |
| X = pd.DataFrame([{ | |
| "Product_Weight": product_weight, | |
| "Product_MRP": product_mrp, | |
| "Product_Sugar_Content": sugar_content, | |
| "Product_Type": product_type, | |
| "Store_Size": store_size, | |
| "Store_Location_City_Type": city_type, | |
| "Store_Type": store_type, | |
| }]) | |
| y_pred = model.predict(X)[0] | |
| st.success(f"Predicted Sales: **${y_pred:,.2f}**") |