sree4411 commited on
Commit
1cb64e9
·
verified ·
1 Parent(s): 0a0a0e7

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -0
app.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import numpy as np
3
+ import pickle
4
+ import pandas as pd
5
+
6
+ # Load the trained model
7
+ def load_model():
8
+ with open("walmart_sales_model.pkl", "rb") as f:
9
+ model = pickle.load(f)
10
+ return model
11
+
12
+ # Load the model
13
+ model = load_model()
14
+
15
+ # Streamlit UI
16
+ def main():
17
+ st.title("🛒 Walmart Sales Prediction")
18
+ st.write("Enter the input features below to predict the weekly sales.")
19
+
20
+ # User inputs
21
+ temp = st.number_input("Enter Temperature (Celsius)", value=20.0)
22
+ fuel_price = st.number_input("Enter Fuel Price", value=3.5)
23
+ cpi = st.number_input("Enter CPI", value=200.0)
24
+ unemployment = st.number_input("Enter Unemployment Rate", value=5.0)
25
+ holiday_flag = st.selectbox("Is it a Holiday?", [0, 1])
26
+
27
+ if st.button("Predict Sales"):
28
+ features = np.array([[temp, fuel_price, cpi, unemployment, holiday_flag]])
29
+ prediction = model.predict(features)
30
+ st.success(f"Predicted Weekly Sales: ${prediction[0]:,.2f}")
31
+
32
+ if __name__ == "__main__":
33
+ main()