ccwizard commited on
Commit
b38c24d
·
verified ·
1 Parent(s): 618ad0a

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +39 -0
app.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import streamlit as st
3
+ import requests
4
+
5
+ st.title("SuperKart Sales Prediction Model with Random Forest")
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=1.0)
11
+ Product_MRP = st.number_input("Product MRP", min_value=0.0, value=300.0)
12
+ Store_Size = st.selectbox("Store Size", ["Small", "Medium", "High"])
13
+ Store_Location_City_Type = st.selectbox("Store Location City Type", ["Tier 1", "Tier 2", "Tier 3"])
14
+ Store_Type = st.selectbox("Store Type", ["Food Mart", "Departmental Store", "Supermarket Type1", "Supermarket Type2"])
15
+ Product_Code = st.selectbox("Product Category", ["FD", "DR", "NC"])
16
+ Store_Age = st.number_input("Store Age in Years", min_value=0, value=50)
17
+ Product_Category = st.selectbox("Product Category", ["Perishable", "Non-Perishable"])
18
+
19
+ product_data = {
20
+ "Product_Weight": Product_Weight,
21
+ "Product_Sugar_Content": Product_Sugar_Content,
22
+ "Product_Allocated_Area": Product_Allocated_Area,
23
+ "Product_MRP": Product_MRP,
24
+ "Store_Size": Store_Size,
25
+ "Store_Location_City_Type": Store_Location_City_Type,
26
+ "Store_Type": Store_Type,
27
+ "Product_Code": Product_Code,
28
+ "Store_Age": Store_Age,
29
+ "Product_Category": Product_Category
30
+ }
31
+
32
+ if st.button("Predict", type='primary'):
33
+ response = requests.post("https://ccwizard-SuperKartSalesPredictionRandomForestFrontend.hf.space/v1/predict", json=product_data) # Complete the code to enter user name and space name to correctly define the endpoint
34
+ if response.status_code == 200:
35
+ result = response.json()
36
+ predicted_sales = result["Sales"]
37
+ st.write(f"Predicted Product Store Sales Total: ₹{predicted_sales:.2f}")
38
+ else:
39
+ st.error("Error in API request")