DD8943 commited on
Commit
2cbb646
·
verified ·
1 Parent(s): a11d65a

Upload folder using huggingface_hub

Browse files
Files changed (2) hide show
  1. app.py +44 -0
  2. requirements.txt +1 -0
app.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import streamlit as st
3
+ import requests
4
+
5
+ st.title("SuperKart Sales Predictor")
6
+
7
+ # Input fields for product and store data
8
+ Product_Weight = st.number_input("Product Weight", min_value=0.0, value=12.66)
9
+ Product_Sugar_Content = st.selectbox("Product Sugar Content", ["Low Sugar", "Regular", "No Sugar"])
10
+ Product_Allocated_Area = st.number_input("Product Allocated Area", min_value=0.0, value=20.0)
11
+ Product_MRP = st.number_input("Product MRP", min_value=0.0, value=100.0)
12
+ Store_Size = st.selectbox("Store Size", ["Small", "Medium", "High"])
13
+ Store_Location_City_Type = st.selectbox("Store Location City Type", ["Urban", "Semi-Urban", "Tier 3"])
14
+ Store_Type = st.selectbox("Store Type", ["Type 1", "Type 2", "Type 3", "Type 4"])
15
+ Product_Id_char = st.selectbox("Product ID Prefix", ["FD", "DR", "NC"]) # Example prefixes
16
+ Store_Age_Years = st.number_input("Store Age (Years)", min_value=0, value=10)
17
+ Product_Type_Category = st.selectbox("Product Type Category", ["Food", "Drinks", "Non-Consumable"]) # Example categories
18
+
19
+ # Prepare data for POST request
20
+ product_data = {
21
+ "Product_Weight": Product_Weight,
22
+ "Product_Sugar_Content": Product_Sugar_Content,
23
+ "Product_Allocated_Area": Product_Allocated_Area,
24
+ "Product_MRP": Product_MRP,
25
+ "Store_Size": Store_Size,
26
+ "Store_Location_City_Type": Store_Location_City_Type,
27
+ "Store_Type": Store_Type,
28
+ "Product_Id_char": Product_Id_char,
29
+ "Store_Age_Years": Store_Age_Years,
30
+ "Product_Type_Category": Product_Type_Category
31
+ }
32
+
33
+ # Predict button and API call
34
+ if st.button("Predict", type='primary'):
35
+ response = requests.post(
36
+ "https://DD8943/superkart-regression-app.hf.space/v1/predict",
37
+ json=product_data
38
+ )
39
+ if response.status_code == 200:
40
+ result = response.json()
41
+ predicted_sales = result["Sales"]
42
+ st.write(f"Predicted Product Store Sales Total: ₹{predicted_sales:.2f}")
43
+ else:
44
+ st.error("Error in API request")
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ requests==2.32.3