File size: 2,170 Bytes
3a84d9a
 
 
 
 
 
7374c0f
3a84d9a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53

import streamlit as st
import pandas as pd
import joblib

# Load trained model pipeline
model = joblib.load('SuperKart_Mode_v1_0.joblib')

# Streamlit app title
st.title("🛒 Product Store Sales Prediction App")
st.markdown("Enter product and store details below to predict sales.")

# Input form
with st.form("prediction_form"):
    product_weight = st.number_input("Product Weight (in kg)", min_value=1.0, max_value=50.0, value=13.5)
    product_allocated_area = st.number_input("Allocated Area (0 to 1)", min_value=0.001, max_value=1.0, value=0.08)
    product_mrp = st.number_input("Product MRP (₹)", min_value=1.0, max_value=1000.0, value=250.75)
    store_age = st.number_input("Store Age (in years)", min_value=1, max_value=100, value=20)

    product_sugar_content = st.selectbox("Product Sugar Content", ["Low Sugar", "Regular", "No Sugar", "High Sugar"])
    product_type = st.selectbox("Product Type", [
        "Meat", "Snack Foods", "Hard Drinks", "Dairy", "Canned", "Soft Drinks",
        "Health and Hygiene", "Baking Goods", "Bread", "Breakfast", "Frozen Foods",
        "Fruits and Vegetables", "Household", "Seafood", "Starchy Foods", "Others"
    ])
    store_size = st.selectbox("Store Size", ["Small", "Medium", "High"])
    store_location = st.selectbox("City Tier", ["Tier 1", "Tier 2", "Tier 3"])
    store_type = st.selectbox("Store Type", ["Departmental Store", "Supermarket Type1", "Supermarket Type2", "Food Mart"])

    submit = st.form_submit_button("Predict Sales")

# Prediction logic
if submit:
    input_dict = {
        "Product_Weight": [product_weight],
        "Product_Allocated_Area": [product_allocated_area],
        "Product_MRP": [product_mrp],
        "Store_Age": [store_age],
        "Product_Sugar_Content": [product_sugar_content],
        "Product_Type": [product_type],
        "Store_Size": [store_size],
        "Store_Location_City_Type": [store_location],
        "Store_Type": [store_type]
    }

    input_df = pd.DataFrame(input_dict)

    # Predict using loaded model
    prediction = model.predict(input_df)[0]

    # Show result
    st.success(f"📈 Predicted Product Store Sales: ₹{prediction:,.2f}")