Update app.py
Browse files
app.py
CHANGED
|
@@ -42,7 +42,12 @@ with tab1:
|
|
| 42 |
est_year = st.slider("Establishment Year", 1987, 2009, 2002)
|
| 43 |
|
| 44 |
# Submit button
|
| 45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
payload = {
|
| 47 |
"Product_Weight": product_weight,
|
| 48 |
"Product_Allocated_Area": product_allocated_area,
|
|
@@ -56,14 +61,17 @@ with tab1:
|
|
| 56 |
"Store_Establishment_Year": est_year
|
| 57 |
}
|
| 58 |
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
|
|
|
| 62 |
st.success(f"✅ Predicted Sales: ₹{pred_value:,.2f}")
|
| 63 |
st.json({**payload, "Predicted_Sales": pred_value})
|
| 64 |
-
|
|
|
|
| 65 |
st.error(f"⚠️ Error during prediction: {e}")
|
| 66 |
|
|
|
|
| 67 |
# ----------------- Tab 2: Batch Prediction -----------------
|
| 68 |
with tab2:
|
| 69 |
st.subheader("📄 Upload CSV for Batch Prediction")
|
|
|
|
| 42 |
est_year = st.slider("Establishment Year", 1987, 2009, 2002)
|
| 43 |
|
| 44 |
# Submit button
|
| 45 |
+
col1, col2 = st.columns([1, 3]) # Adjust ratio as needed
|
| 46 |
+
|
| 47 |
+
with col1:
|
| 48 |
+
predict_clicked = st.button("🎯 Predict Sales 🎯", key="predict_button")
|
| 49 |
+
|
| 50 |
+
if predict_clicked:
|
| 51 |
payload = {
|
| 52 |
"Product_Weight": product_weight,
|
| 53 |
"Product_Allocated_Area": product_allocated_area,
|
|
|
|
| 61 |
"Store_Establishment_Year": est_year
|
| 62 |
}
|
| 63 |
|
| 64 |
+
try:
|
| 65 |
+
prediction = get_single_prediction(payload)
|
| 66 |
+
pred_value = prediction[0] if isinstance(prediction, list) else prediction
|
| 67 |
+
with col2:
|
| 68 |
st.success(f"✅ Predicted Sales: ₹{pred_value:,.2f}")
|
| 69 |
st.json({**payload, "Predicted_Sales": pred_value})
|
| 70 |
+
except Exception as e:
|
| 71 |
+
with col2:
|
| 72 |
st.error(f"⚠️ Error during prediction: {e}")
|
| 73 |
|
| 74 |
+
|
| 75 |
# ----------------- Tab 2: Batch Prediction -----------------
|
| 76 |
with tab2:
|
| 77 |
st.subheader("📄 Upload CSV for Batch Prediction")
|