Harika22 commited on
Commit
c91499f
·
verified ·
1 Parent(s): f09ef9b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -35
app.py CHANGED
@@ -39,40 +39,39 @@ st.markdown("""
39
  Just enter the store details below, and our AI model will predict the weekly sales! 💰
40
  """)
41
 
42
- with st.form("prediction_form"):
43
- Store = st.number_input("Store ID", min_value=1, max_value=100, value=1)
44
- Holiday_Flag = st.selectbox("Is it a Holiday?", [0, 1])
45
- Temperature = st.number_input("Temperature (°F)", value=75.0)
46
- Fuel_Price = st.number_input("Fuel Price ($)", value=2.5)
47
- CPI = st.number_input("CPI", value=211.0)
48
- Unemployment = st.number_input("Unemployment Rate (%)", value=7.5)
49
- month = st.selectbox("Month", list(range(1, 13)))
50
-
51
- submitted = st.form_submit_button("Predict")
52
-
53
- if submitted:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  try:
55
- # Construct input data
56
- input_data = pd.DataFrame([[
57
- Store, Holiday_Flag, Temperature, Fuel_Price, CPI, Unemployment, month
58
- ]], columns=['Store', 'Holiday_Flag', 'Temperature', 'Fuel_Price', 'CPI', 'Unemployment', 'month'])
59
-
60
- # Ensure proper data types
61
- input_data = input_data.astype({
62
- 'Store': int,
63
- 'Holiday_Flag': int,
64
- 'Temperature': float,
65
- 'Fuel_Price': float,
66
- 'CPI': float,
67
- 'Unemployment': float,
68
- 'month': int
69
- })
70
-
71
- # Prediction
72
- prediction = model.predict(input_data)[0]
73
- st.success(f"🎯 Predicted Weekly Sales: **${prediction:,.2f}**")
74
-
75
- except ValueError as ve:
76
- st.error(f"ValueError: {ve}")
77
  except Exception as e:
78
- st.error(f"An error occurred: {e}")
 
39
  Just enter the store details below, and our AI model will predict the weekly sales! 💰
40
  """)
41
 
42
+ st.title("🛒 Walmart Sales Prediction")
43
+ st.write("Enter the input features below to predict the weekly sales.")
44
+
45
+ # Store input (float64)
46
+ store = st.number_input("Enter Store ID (1-50)", min_value=1.0, max_value=50.0, step=1.0, format="%.1f")
47
+
48
+ # Holiday_Flag input (object, but should be categorical)
49
+ holiday_flag = st.selectbox("Is it a Holiday?", [0,1])
50
+
51
+ # Temperature input (float64)
52
+ temperature = st.number_input("Enter Temperature (°C)", value=20.0, format="%.2f")
53
+
54
+ # Fuel Price input (float64)
55
+ fuel_price = st.number_input("Enter Fuel Price", value=3.5, format="%.3f")
56
+
57
+ # CPI input (float64)
58
+ cpi = st.number_input("Enter CPI", value=200.0, format="%.6f")
59
+
60
+ # Unemployment input (float64)
61
+ unemployment = st.number_input("Enter Unemployment Rate", value=5.0, format="%.3f")
62
+
63
+ # Month input (float64)
64
+ month = st.number_input("Enter Month (1-12)", min_value=1.0, max_value=12.0, step=1.0, format="%.1f")
65
+
66
+
67
+ # Prediction button
68
+ if st.button("Predict Sales"):
69
+ #input_features = [[store, holiday_flag, temperature, fuel_price, cpi, unemployment,month]]
70
+
71
  try:
72
+ prediction = model.predict([[store, holiday_flag, temperature, fuel_price, cpi, unemployment, month]])
73
+ prediction
74
+
75
+ st.success(f"Predicted Weekly Sales: ${prediction[0]:,.2f}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
  except Exception as e:
77
+ st.error(f"Error during prediction: {e}")