dev02chandan commited on
Commit
91fd4b8
·
verified ·
1 Parent(s): be01f5b

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +52 -0
  2. requirements.txt +3 -3
app.py ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import streamlit as st
3
+ import pandas as pd
4
+ import joblib
5
+ import requests
6
+
7
+ # Title
8
+ st.title("🛒 SuperKart Sales Forecasting")
9
+
10
+ st.markdown("Enter product and store details to predict sales.")
11
+
12
+ # Input fields
13
+ product_weight = st.number_input("Product Weight (kg)", min_value=1.0, step=0.1)
14
+ product_sugar_content = st.selectbox("Sugar Content", ["Low Sugar", "Regular", "No Sugar", "Sugar Free"])
15
+ product_allocated_area = st.slider("Display Area (%)", 0.0, 0.3, 0.05)
16
+ product_type = st.selectbox("Product Type", [
17
+ "Meat", "Snack Foods", "Hard Drinks", "Dairy", "Canned", "Soft Drinks", "Health and Hygiene",
18
+ "Baking Goods", "Bread", "Breakfast", "Frozen Foods", "Fruits and Vegetables",
19
+ "Household", "Seafood", "Starchy Foods", "Others"
20
+ ])
21
+ product_mrp = st.number_input("Product MRP (₹)", min_value=10.0, step=1.0)
22
+ store_size = st.selectbox("Store Size", ["Small", "Medium", "High"])
23
+ store_location_city_type = st.selectbox("City Tier", ["Tier 1", "Tier 2", "Tier 3"])
24
+ store_type = st.selectbox("Store Type", [
25
+ "Departmental Store", "Supermarket Type1", "Supermarket Type2", "Food Mart"
26
+ ])
27
+ store_age = st.slider("Store Age (Years)", 1, 40, 15)
28
+
29
+ # Submit
30
+ if st.button("Predict Sales"):
31
+ input_data = {
32
+ "Product_Weight": product_weight,
33
+ "Product_Sugar_Content": product_sugar_content,
34
+ "Product_Allocated_Area": product_allocated_area,
35
+ "Product_Type": product_type,
36
+ "Product_MRP": product_mrp,
37
+ "Store_Size": store_size,
38
+ "Store_Location_City_Type": store_location_city_type,
39
+ "Store_Type": store_type,
40
+ "Store_Age": store_age
41
+ }
42
+
43
+ # Call the backend API
44
+ try:
45
+ response = requests.post("https://<your-backend-username>.huggingface.space/<backend-space-name>/predict", json=input_data)
46
+ result = response.json()
47
+ if "predicted_sales" in result:
48
+ st.success(f"📈 Predicted Sales: ₹{result['predicted_sales']}")
49
+ else:
50
+ st.error(f"Error: {result.get('error', 'Unknown')}")
51
+ except Exception as e:
52
+ st.error(f"API call failed: {e}")
requirements.txt CHANGED
@@ -1,3 +1,3 @@
1
- altair
2
- pandas
3
- streamlit
 
1
+ streamlit==1.35.0
2
+ requests==2.32.3
3
+ pandas==2.2.2