File size: 2,021 Bytes
0c96590
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
import requests

API_URL = "https://nohafx-superkart-predictor.hf.space/predict"

st.title("πŸ›’ SuperKart Product Sales Predictor")
st.write("Enter product and store details to predict sales.")

product_weight = st.number_input("Product Weight", min_value=0.0, value=12.5)
product_sugar = st.selectbox("Product Sugar Content", ["Low Fat", "Regular", "Low Sugar"])
product_area = st.number_input("Product Allocated Area", min_value=0.0, max_value=1.0, value=0.05)
product_type = st.selectbox("Product Type", [
    "Snack Foods", "Dairy", "Fruits and Vegetables",
    "Frozen Foods", "Household", "Baking Goods",
    "Canned", "Health and Hygiene", "Soft Drinks",
    "Meat", "Breads", "Hard Drinks", "Others",
    "Starchy Foods", "Breakfast", "Seafood"
])
product_mrp = st.number_input("Product MRP", min_value=0.0, value=150.75)
store_size = st.selectbox("Store Size", ["Small", "Medium", "High"])
store_location = st.selectbox("Store Location City Type", ["Tier 1", "Tier 2", "Tier 3"])
store_type = st.selectbox("Store Type", [
    "Supermarket Type1", "Supermarket Type2",
    "Supermarket Type3", "Grocery Store"
])
store_age = st.number_input("Store Age (Years)", min_value=0, value=15)

if st.button("πŸ” Predict Sales"):
    input_data = {
        "Product_Weight": product_weight,
        "Product_Sugar_Content": product_sugar,
        "Product_Allocated_Area": product_area,
        "Product_Type": product_type,
        "Product_MRP": product_mrp,
        "Store_Size": store_size,
        "Store_Location_City_Type": store_location,
        "Store_Type": store_type,
        "Store_Age": store_age
    }
    try:
        response = requests.post(API_URL, json=input_data)
        if response.status_code == 200:
            prediction = response.json()["prediction"]
            st.success(f"βœ… Predicted Sales: **${prediction:,.2f}**")
        else:
            st.error(f"❌ Error: {response.text}")
    except Exception as e:
        st.error(f"❌ Connection Error: {str(e)}")