prashant91 commited on
Commit
b3d44cb
·
verified ·
1 Parent(s): c53ca19

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +38 -23
app.py CHANGED
@@ -1,29 +1,44 @@
1
- # app.py
2
  import streamlit as st
3
  import joblib
4
  import pandas as pd
5
 
6
  # Load the model
7
- model = joblib.load("best_sales_model.pkl")
8
-
9
- st.title("SuperKart Store Sales Forecasting")
10
-
11
- # Input form
12
- st.subheader("Enter Product and Store Details")
13
-
14
- product_weight = st.number_input("Product Weight", value=10.0)
15
- sugar_content = st.selectbox("Product Sugar Content", ["Low Sugar", "Regular", "No Sugar"])
16
- allocated_area = st.slider("Product Allocated Area", 0.01, 1.0, 0.1)
17
- product_type = st.selectbox("Product Type", ["Fruits and Vegetables", "Snack Foods", "Frozen Foods", "Dairy", "Household", "Baking Goods", "Canned", "Health and Hygiene", "Meat", "Soft Drinks", "Breads", "Hard Drinks", "Starchy Foods", "Breakfast", "Seafood", "Others"])
18
- product_mrp = st.number_input("Product MRP", value=100.0)
19
- store_size = st.selectbox("Store Size", ["Small", "Medium", "High"])
20
- store_city = st.selectbox("Store City Type", ["Tier 1", "Tier 2", "Tier 3"])
21
- store_type = st.selectbox("Store Type", ["Supermarket Type2", "Supermarket Type1", "Departmental Store", "Food Mart"])
22
- store_id = st.selectbox("Store ID", ["OUT001", "OUT002", "OUT003", "OUT004"])
23
- store_age = st.slider("Store Age (Years)", 0, 50, 10)
24
-
25
- # Predict
26
- if st.button("Predict Sales"):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  input_data = pd.DataFrame([{
28
  'Product_Weight': product_weight,
29
  'Product_Sugar_Content': sugar_content,
@@ -36,6 +51,6 @@ if st.button("Predict Sales"):
36
  'Store_Id': store_id,
37
  'Store_Age': store_age
38
  }])
39
-
40
  prediction = model.predict(input_data)[0]
41
- st.success(f"Predicted Sales: {round(prediction, 2)}")
 
 
1
  import streamlit as st
2
  import joblib
3
  import pandas as pd
4
 
5
  # Load the model
6
+ @st.cache_resource
7
+ def load_model():
8
+ return joblib.load("best_sales_model.pkl")
9
+
10
+ model = load_model()
11
+
12
+ # App title
13
+ st.set_page_config(page_title="SuperKart Sales Forecast", layout="centered")
14
+ st.title("🛍️ SuperKart Stores Sales Forecasting")
15
+
16
+ # User input form
17
+ st.header("📋 Input Product & Store Details")
18
+
19
+ with st.form("sales_form"):
20
+ col1, col2 = st.columns(2)
21
+
22
+ with col1:
23
+ product_weight = st.number_input("Product Weight (in grams)", min_value=0.0, step=0.1)
24
+ sugar_content = st.selectbox("Product Sugar Content", ["Low Sugar", "Regular", "No Sugar"])
25
+ allocated_area = st.slider("Product Allocated Area (ratio)", min_value=0.0, max_value=1.0, step=0.01)
26
+ product_type = st.selectbox("Product Type", [
27
+ "Fruits and Vegetables", "Snack Foods", "Frozen Foods", "Dairy", "Household", "Baking Goods", "Canned", "Health and Hygiene", "Meat", "Soft Drinks", "Breads", "Hard Drinks", "Starchy Foods", "Breakfast", "Seafood", "Others"
28
+ ])
29
+ product_mrp = st.number_input("Product MRP", min_value=0, max_value=50, value=10)
30
+
31
+ with col2:
32
+ store_size = st.selectbox("Store Size", ["Small", "Medium", "High"])
33
+ store_city = st.selectbox("Store Location City Type", ["Tier 1", "Tier 2", "Tier 3"])
34
+ store_type = st.selectbox("Store Type", ["Supermarket Type2", "Supermarket Type1", "Departmental Store", "Food Mart"])
35
+ store_id = st.selectbox("Store ID", ["OUT001", "OUT002", "OUT003", "OUT004"])
36
+ store_age = st.slider("Store Age (Years)", min_value=0.1, value=100.0)
37
+
38
+ submitted = st.form_submit_button("🔍 Predict Sales")
39
+
40
+ # Predict sales
41
+ if submitted:
42
  input_data = pd.DataFrame([{
43
  'Product_Weight': product_weight,
44
  'Product_Sugar_Content': sugar_content,
 
51
  'Store_Id': store_id,
52
  'Store_Age': store_age
53
  }])
54
+
55
  prediction = model.predict(input_data)[0]
56
+ st.success(f"Predicted Product Sales: {round(prediction, 2)}")