jkng77433 commited on
Commit
1ea927f
·
verified ·
1 Parent(s): 08aec62

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +50 -0
app.py ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import requests
4
+
5
+ st.title("🛒 SuperKart Sales Forecast App")
6
+
7
+ st.markdown("""
8
+ Use this interactive interface to forecast product-level sales for SuperKart stores based on store and product attributes.
9
+ """)
10
+
11
+ API_URL = "https://jkng77433-Backend.hf.space/v1/forecast/single"
12
+
13
+ st.header("Single Prediction")
14
+
15
+ col1, col2 = st.columns(2)
16
+ with col1:
17
+ product_id = st.text_input("Product ID", "FD6114")
18
+ product_type = st.selectbox("Product Type", ["Frozen Foods", "Dairy", "Canned", "Snack Foods"])
19
+ sugar_content = st.selectbox("Product Sugar Content", ["Low Sugar", "Regular", "No Sugar"])
20
+ product_weight = st.number_input("Product Weight", min_value=0.1, value=12.66)
21
+ product_mrp = st.number_input("Product MRP", min_value=0.0, value=117.08)
22
+
23
+ with col2:
24
+ store_id = st.text_input("Store ID", "OUT004")
25
+ store_type = st.selectbox("Store Type", ["Supermarket Type1", "Supermarket Type2", "Departmental Store", "Food Mart"])
26
+ store_size = st.selectbox("Store Size", ["Small", "Medium", "High"])
27
+ store_location = st.selectbox("Store Location City Type", ["Tier 1", "Tier 2", "Tier 3"])
28
+ est_year = st.number_input("Store Establishment Year", min_value=1980, max_value=2025, value=2009)
29
+ allocated_area = st.number_input("Product Allocated Area", min_value=0.0, max_value=1.0, value=0.027, format="%.3f")
30
+
31
+ if st.button("Predict Sales"):
32
+ payload = {
33
+ "Product_Id": product_id,
34
+ "Product_Type": product_type,
35
+ "Product_Sugar_Content": sugar_content,
36
+ "Product_Weight": product_weight,
37
+ "Product_MRP": product_mrp,
38
+ "Store_Id": store_id,
39
+ "Store_Type": store_type,
40
+ "Store_Size": store_size,
41
+ "Store_Location_City_Type": store_location,
42
+ "Store_Establishment_Year": est_year,
43
+ "Product_Allocated_Area": allocated_area
44
+ }
45
+ response = requests.post(API_URL, json=payload)
46
+ if response.status_code == 200:
47
+ result = response.json()
48
+ st.success(f"Predicted Sales: **${result['Predicted_Product_Store_Sales_Total']:.2f}**")
49
+ else:
50
+ st.error("Prediction failed — check input values or backend availability.")