File size: 2,211 Bytes
d3b8309
b67b45f
d3b8309
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 requests

st.title("πŸ›’ SuperKart Quarterly Sales Predictor")

# Input form
st.subheader("πŸ” Predict Store's Quarterly Sales")

store_id = st.selectbox("Store ID", ["OUT001", "OUT002", "OUT003", "OUT004"])
product_type = st.selectbox("Product Type", ["Dairy", "Soft Drinks", "Meat", "Canned", "Frozen Foods"])
sugar_content = st.selectbox("Product Sugar Content", ["Low", "Medium", "High", "No Added Sugar"])
store_type = st.selectbox("Store Type", ["Supermarket Type1", "Supermarket Type2", "Grocery Store", "Food Mart"])
city_type = st.selectbox("City Type", ["Urban", "Semi-Urban", "Rural"])
store_size = st.selectbox("Store Size", ["Small", "Medium", "High"])

est_year = st.number_input("Store Establishment Year", min_value=1980, max_value=2025, value=2005)
weight = st.number_input("Product Weight", min_value=0.0, value=12.0)
area = st.number_input("Product Allocated Area", min_value=0.0, value=125.0)
mrp = st.number_input("Product MRP", min_value=0.0, value=120.0)

input_data = pd.DataFrame([{
    'Store_Id': store_id,
    'Product_Type': product_type,
    'Product_Sugar_Content': sugar_content,
    'Store_Type': store_type,
    'Store_Location_City_Type': city_type,
    'Store_Size': store_size,
    'Store_Establishment_Year': est_year,
    'Product_Weight': weight,
    'Product_Allocated_Area': area,
    'Product_MRP': mrp
}])

if st.button("Predict Sales"):
    api_url = "https://abcabcabc999--superkart.hf.space/v1/storesales"
    response = requests.post(api_url, json=input_data.to_dict(orient='records'))
    if response.status_code == 200:
        result = response.json()
        st.success(f"πŸ“¦ Predicted Total Sales: β‚Ή{result['Total_Store_Sales']:,.2f}")
    else:
        st.error(f"❌ API Error: {response.text}")

st.subheader("πŸ“ Batch Prediction via CSV")
file = st.file_uploader("Upload CSV", type=["csv"])

if file and st.button("Predict Batch"):
    response = requests.post("https://abcabcabc999--superkart.hf.space/v1/storesalesbatch", files={"file": file})
    if response.status_code == 200:
        st.write(pd.DataFrame(response.json()))
    else:
        st.error(f"❌ Batch API Error: {response.text}")