Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -54,15 +54,14 @@ def on_predict(row_label):
|
|
| 54 |
error_rounded = float(np.round(error, 3))
|
| 55 |
|
| 56 |
# Markdown display
|
| 57 |
-
features_md = "### Input Features\n\n" + row.to_frame().to_markdown()
|
| 58 |
result_md = (
|
| 59 |
-
f"###
|
| 60 |
f"**Predicted Yield (g per pot):** {pred_rounded}\n\n"
|
| 61 |
f"**Actual Yield (Ground Truth):** {actual}\n\n"
|
| 62 |
f"**Absolute Error:** {error_rounded}"
|
| 63 |
)
|
| 64 |
|
| 65 |
-
return "✅ Prediction complete",
|
| 66 |
|
| 67 |
# -------------------------------
|
| 68 |
# Dropdown options
|
|
@@ -79,7 +78,7 @@ body {background:#f5f7fa;color:#0b1220;font-family:Inter,sans-serif;}
|
|
| 79 |
""") as demo:
|
| 80 |
|
| 81 |
with gr.Row():
|
| 82 |
-
# LEFT COLUMN: controls
|
| 83 |
with gr.Column(elem_classes="card", scale=1):
|
| 84 |
gr.Markdown("# 🌿 EcoGrowAI — Yield Prediction")
|
| 85 |
gr.Markdown("Select any experimental row and predict **Yield (g per pot)** using the trained XGBoost model.")
|
|
@@ -90,18 +89,17 @@ body {background:#f5f7fa;color:#0b1220;font-family:Inter,sans-serif;}
|
|
| 90 |
|
| 91 |
predict_button = gr.Button("Predict", variant="primary")
|
| 92 |
status = gr.Markdown("")
|
|
|
|
| 93 |
|
| 94 |
-
# RIGHT COLUMN:
|
| 95 |
-
with gr.Column(elem_classes="card", scale=
|
| 96 |
-
|
| 97 |
-
features_md = gr.Markdown("")
|
| 98 |
-
result_md = gr.Markdown("")
|
| 99 |
|
| 100 |
# -------------------------------
|
| 101 |
# Event bindings
|
| 102 |
# -------------------------------
|
| 103 |
row_dropdown.change(on_row_select, row_dropdown, row_info)
|
| 104 |
-
predict_button.click(on_predict, row_dropdown, [status,
|
| 105 |
|
| 106 |
# -------------------------------
|
| 107 |
# Launch
|
|
|
|
| 54 |
error_rounded = float(np.round(error, 3))
|
| 55 |
|
| 56 |
# Markdown display
|
|
|
|
| 57 |
result_md = (
|
| 58 |
+
f"### Prediction Result\n\n"
|
| 59 |
f"**Predicted Yield (g per pot):** {pred_rounded}\n\n"
|
| 60 |
f"**Actual Yield (Ground Truth):** {actual}\n\n"
|
| 61 |
f"**Absolute Error:** {error_rounded}"
|
| 62 |
)
|
| 63 |
|
| 64 |
+
return "✅ Prediction complete", result_md
|
| 65 |
|
| 66 |
# -------------------------------
|
| 67 |
# Dropdown options
|
|
|
|
| 78 |
""") as demo:
|
| 79 |
|
| 80 |
with gr.Row():
|
| 81 |
+
# LEFT COLUMN: controls + selected row info
|
| 82 |
with gr.Column(elem_classes="card", scale=1):
|
| 83 |
gr.Markdown("# 🌿 EcoGrowAI — Yield Prediction")
|
| 84 |
gr.Markdown("Select any experimental row and predict **Yield (g per pot)** using the trained XGBoost model.")
|
|
|
|
| 89 |
|
| 90 |
predict_button = gr.Button("Predict", variant="primary")
|
| 91 |
status = gr.Markdown("")
|
| 92 |
+
row_info = gr.Markdown("No row selected yet.") # Selected row info on left
|
| 93 |
|
| 94 |
+
# RIGHT COLUMN: prediction result
|
| 95 |
+
with gr.Column(elem_classes="card", scale=1):
|
| 96 |
+
result_md = gr.Markdown("Prediction result will appear here.")
|
|
|
|
|
|
|
| 97 |
|
| 98 |
# -------------------------------
|
| 99 |
# Event bindings
|
| 100 |
# -------------------------------
|
| 101 |
row_dropdown.change(on_row_select, row_dropdown, row_info)
|
| 102 |
+
predict_button.click(on_predict, row_dropdown, [status, result_md])
|
| 103 |
|
| 104 |
# -------------------------------
|
| 105 |
# Launch
|