Krishna6559 commited on
Commit
0fb7cf4
·
verified ·
1 Parent(s): 918b8fa

Upload folder using huggingface_hub

Browse files
Files changed (2) hide show
  1. app.py +69 -0
  2. requirements.txt +5 -0
app.py ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import requests
4
+
5
+ # Set the title of the Streamlit app
6
+ st.title("Super Kart Sales forecast Prediction")
7
+
8
+ # Section for online prediction
9
+ st.subheader("Online Prediction")
10
+
11
+ # Collect user input for property features
12
+
13
+ Product_Weight = st.number_input("Product Weight", min_value=0.0, value=100.0)
14
+ Product_Sugar_Content = st.selectbox("Product Sugar Content", ["Low Sugar", "Regular", "No Sugar"])
15
+ Product_Allocated_Area = st.number_input("Product Allocated Area", min_value=0.0, value=1.0)
16
+ Product_Type = st.selectbox("Product Type",
17
+ [
18
+ "Frozen Foods", "Dairy", "Canned", "Baking Goods",
19
+ "Health and Hygiene", "Snack Foods", "Meat", "Household",
20
+ "Hard Drinks", "Fruits and Vegetables", "Breads", "Soft Drinks",
21
+ "Breakfast", "Others", "Starchy Foods", "Seafood"
22
+ ]
23
+ )
24
+ Product_MRP = st.number_input("Product MRP")
25
+ Store_Id = st.selectbox("Store ID", ["OUT001", "OUT002", "OUT003", "OUT004"])
26
+ Store_Establishment_Year = st.number_input("Store Establishment Year", min_value=1987, value=2009)
27
+ Store_Size = st.selectbox("Store Size", ["Small", "Medium", "Large"])
28
+ Store_Location_City_Type = st.selectbox("Store Location City Type", ["Tier 1", "Tier 2", "Tier 3"])
29
+ Store_Type = st.selectbox("Store Type", ["Departmental Store", "Supermarket Type1", "Supermarket Type2", "Food Mart"])
30
+
31
+ # Convert user input into a DataFrame
32
+ input_data = pd.DataFrame([{
33
+ 'Product_Weight': Product_Weight,
34
+ 'Product_Sugar_Content': Product_Sugar_Content,
35
+ 'Product_Allocated_Area': Product_Allocated_Area,
36
+ 'Product_Type': Product_Type,
37
+ 'Product_MRP': Product_MRP,
38
+ 'Store_Id': Store_Id,
39
+ 'Store_Establishment_Year': Store_Establishment_Year,
40
+ 'Store_Size': Store_Size,
41
+ 'Store_Location_City_Type': Store_Location_City_Type,
42
+ 'Store_Type': Store_Type
43
+ }])
44
+
45
+ # Make prediction when the "Predict" button is clicked
46
+ if st.button("Predict"):
47
+ response = requests.post("https://Krishna6559-SuperKartPredictionBackend.hf.space/v1/saletotal", json=input_data.to_dict(orient='records')[0]) # Send data to Flask API
48
+ if response.status_code == 200:
49
+ prediction = response.json()['Predicted total revenue generated by the sale']
50
+ st.success(f"Predicted Sale Total Price: {prediction}")
51
+ else:
52
+ st.error("Error making prediction.")
53
+
54
+ # Section for batch prediction
55
+ st.subheader("Batch Prediction")
56
+
57
+ # Allow users to upload a CSV file for batch prediction
58
+ uploaded_file = st.file_uploader("Upload CSV file for batch prediction", type=["csv"])
59
+
60
+ # Make batch prediction when the "Predict Batch" button is clicked
61
+ if uploaded_file is not None:
62
+ if st.button("Predict Batch"):
63
+ response = requests.post("https://Krishna6559-SuperKartPredictionBackend.hf.space/v1/saletotalbatch", files={"file": uploaded_file}) # Send file to Flask API
64
+ if response.status_code == 200:
65
+ predictions = response.json()
66
+ st.success("Batch predictions completed!")
67
+ st.write(predictions) # Display the predictions
68
+ else:
69
+ st.error("Error making batch prediction.")
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ pandas==2.2.2
2
+ requests==2.28.1
3
+ streamlit
4
+ numpy
5
+ flask