Spaces:
No application file
No application file
| import streamlit as st | |
| import pandas as pd | |
| import joblib | |
| st.title("SuperKart Sales Revenue Predictor") | |
| # Load model | |
| def load_model(): | |
| return joblib.load('final_rf_model.pkl') | |
| model = load_model() | |
| # Define all input fields | |
| st.header("Enter Product & Store Details:") | |
| product_weight = st.number_input("Product Weight", min_value=0.0, max_value=50.0, value=12.5) | |
| product_sugar_content = st.selectbox("Product Sugar Content", ["Low Sugar", "Regular", "No Sugar", "High"]) | |
| product_allocated_area = st.number_input("Product Allocated Area", min_value=0.0, max_value=1.0, value=0.05) | |
| product_type = st.selectbox("Product Type", [ | |
| "Fruits and Vegetables", "Snack Foods", "Household", "Dairy", "Baking Goods", | |
| "Frozen Foods", "Canned", "Soft Drinks", "Breads", "Breakfast", "Health and Hygiene", | |
| "Meat", "Others", "Seafood", "Starchy Foods", "Hard Drinks" | |
| ]) | |
| product_mrp = st.number_input("Product MRP", min_value=0.0, max_value=300.0, value=150.0) | |
| store_establishment_year = st.selectbox("Store Establishment Year", list(range(1987, 2010))) | |
| 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", ["Supermarket Type2", "Supermarket Type1", "Departmental Store", "Food Mart"]) | |
| # Predict button | |
| if st.button("Predict Sales"): | |
| input_df = 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 | |
| }]) | |
| prediction = model.predict(input_df)[0] | |
| st.success(f"Predicted Quarterly Sales Revenue: ₹ {prediction:,.2f}") | |