deva8217 commited on
Commit
bbe5693
Β·
verified Β·
1 Parent(s): 5f2802f

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +60 -0
app.py ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # app.py
2
+
3
+ import streamlit as st
4
+ import pandas as pd
5
+ import joblib
6
+
7
+ # -----------------------------
8
+ # Load Trained Model
9
+ # -----------------------------
10
+ @st.cache_resource
11
+ def load_model():
12
+ return joblib.load("superkart_sales_forecast.pkl")
13
+
14
+ model = load_model()
15
+
16
+ # -----------------------------
17
+ # Streamlit UI Setup
18
+ # -----------------------------
19
+ st.set_page_config(page_title="SuperKart Sales Forecast", layout="centered")
20
+
21
+ st.title("πŸ›’ SuperKart Sales Forecasting App")
22
+ st.markdown(
23
+ """
24
+ Welcome to the SuperKart Sales Predictor!
25
+ Fill out the form below with your store's details to get an accurate sales forecast for the upcoming quarter.
26
+ """
27
+ )
28
+
29
+ # -----------------------------
30
+ # Input Widgets
31
+ # -----------------------------
32
+ with st.form("sales_form"):
33
+ col1, col2 = st.columns(2)
34
+
35
+ with col1:
36
+ store_size = st.slider("πŸ“ Store Size (sqft)", min_value=500, max_value=10000, value=3000, step=100)
37
+ city_tier = st.selectbox("πŸ™οΈ City Tier", options=[1, 2, 3], index=1)
38
+
39
+ with col2:
40
+ promotion_active = st.radio("πŸ“’ Promotion Active?", options=[0, 1], format_func=lambda x: "Yes" if x == 1 else "No")
41
+ holiday = st.radio("πŸŽ‰ Holiday Period?", options=[0, 1], format_func=lambda x: "Yes" if x == 1 else "No")
42
+
43
+ previous_sales = st.number_input("πŸ“Š Previous Quarter Sales", min_value=0.0, value=10000.0, step=500.0)
44
+
45
+ submitted = st.form_submit_button("Predict Sales")
46
+
47
+ # -----------------------------
48
+ # Prediction Logic
49
+ # -----------------------------
50
+ if submitted:
51
+ input_data = pd.DataFrame([{
52
+ "store_size": store_size,
53
+ "city_tier": city_tier,
54
+ "promotion_active": promotion_active,
55
+ "holiday": holiday,
56
+ "previous_quarter_sales": previous_sales
57
+ }])
58
+
59
+ prediction = model.predict(input_data)[0]
60
+ st.success(f"πŸ“ˆ Predicted Sales for Next Quarter: β‚Ή{prediction:,.2f}")