Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
try:
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 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"
|
|
|
|
| 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}")
|