Muleex12 commited on
Commit
c70dff3
·
verified ·
1 Parent(s): 3d7ee1f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -18
app.py CHANGED
@@ -1,26 +1,42 @@
1
  import streamlit as st
2
  import requests
3
 
4
- st.title("🛒 SuperKart Sales Prediction")
5
 
6
- url = "YOUR_BACKEND_URL/predict"
7
-
8
- data = {
9
- "Product_Weight": st.number_input("Product Weight"),
10
- "Product_Sugar_Content": st.selectbox("Sugar Content", ["Low Sugar", "Regular"]),
11
- "Product_Allocated_Area": st.number_input("Allocated Area"),
12
- "Product_Type": st.selectbox("Product Type", ["Food", "Drinks", "Meat", "Household"]),
13
- "Product_MRP": st.number_input("MRP"),
14
- "Store_Establishment_Year": st.number_input("Year"),
15
- "Store_Size": st.selectbox("Store Size", ["Small", "Medium", "High"]),
16
- "Store_Location_City_Type": st.selectbox("City Type", ["Tier 1", "Tier 2", "Tier 3"]),
17
- "Store_Type": st.selectbox("Store Type", ["Grocery Store", "Supermarket Type1", "Supermarket Type2"]),
18
- "Product_Id_char": st.text_input("Product ID Char"),
19
- "Product_Type_Category": st.text_input("Product Type Category")
20
- }
21
 
22
  if st.button("Predict"):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  response = requests.post(url, json=data)
24
- result = response.json()
25
 
26
- st.success(f"Predicted Sales: {result['prediction']}")
 
 
 
 
 
1
  import streamlit as st
2
  import requests
3
 
4
+ st.title("SuperKart Sales Prediction")
5
 
6
+ # Inputs
7
+ product_weight = st.number_input("Product Weight")
8
+ product_sugar = st.selectbox("Sugar Content", ["Low Sugar", "Regular"])
9
+ product_area = st.number_input("Allocated Area")
10
+ product_type = st.text_input("Product Type")
11
+ product_mrp = st.number_input("MRP")
12
+ store_year = st.number_input("Store Year")
13
+ store_size = st.selectbox("Store Size", ["Small", "Medium", "High"])
14
+ store_city = st.selectbox("City Type", ["Tier 1", "Tier 2", "Tier 3"])
15
+ store_type = st.text_input("Store Type")
16
+ product_category = st.text_input("Product Category")
17
+ product_id_char = st.text_input("Product ID Char")
 
 
 
18
 
19
  if st.button("Predict"):
20
+ url = "https://muleex12-backends.hf.space/predict"
21
+
22
+ data = {
23
+ "Product_Weight": product_weight,
24
+ "Product_Sugar_Content": product_sugar,
25
+ "Product_Allocated_Area": product_area,
26
+ "Product_Type": product_type,
27
+ "Product_MRP": product_mrp,
28
+ "Store_Establishment_Year": store_year,
29
+ "Store_Size": store_size,
30
+ "Store_Location_City_Type": store_city,
31
+ "Store_Type": store_type,
32
+ "Product_Type_Category": product_category,
33
+ "Product_Id_char": product_id_char
34
+ }
35
+
36
  response = requests.post(url, json=data)
 
37
 
38
+ if response.status_code == 200:
39
+ result = response.json()
40
+ st.success(f"Predicted Sales: {result['prediction']}")
41
+ else:
42
+ st.error("Error getting prediction")