Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -17,19 +17,19 @@ df.columns = df.columns.str.strip()
|
|
| 17 |
strain_names = df['pea plant strain'].unique().tolist()
|
| 18 |
row_options = ["None, Enter Manually"] + [str(i) for i in range(len(df))]
|
| 19 |
|
| 20 |
-
# -----------------------------
|
| 21 |
-
# 2️⃣ Autofill function
|
| 22 |
-
# -----------------------------
|
| 23 |
-
def autofill_fields(row_index):
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
|
| 34 |
# -----------------------------
|
| 35 |
# 3️⃣ Prediction function
|
|
@@ -71,9 +71,9 @@ def predict_linear(strain, dose, soil_n, soil_p, soil_k, ph,
|
|
| 71 |
# Build table DataFrame
|
| 72 |
data = {
|
| 73 |
"Output Metric": target_cols,
|
| 74 |
-
"Actual Value": actuals + ["N/A"],
|
| 75 |
"Predicted Value": [round(v, 2) for v in y_pred],
|
| 76 |
-
"Absolute Error": abs_errors + ["N/A"]
|
| 77 |
}
|
| 78 |
result_df = pd.DataFrame(data)
|
| 79 |
|
|
@@ -123,13 +123,13 @@ with gr.Blocks(
|
|
| 123 |
soil_k = gr.Number(label="Soil K (ppm)")
|
| 124 |
ph = gr.Number(label="pH")
|
| 125 |
|
| 126 |
-
gr.Markdown("### Autofilled Actual Metrics (from Excel)")
|
| 127 |
-
chlorophyll = gr.Number(label="Chlorophyll (SPAD)")
|
| 128 |
-
shoot_len = gr.Number(label="Shoot Length (cm)")
|
| 129 |
-
root_len = gr.Number(label="Root Length (cm)")
|
| 130 |
-
shoot_wt = gr.Number(label="Shoot Wt (g)")
|
| 131 |
-
root_wt = gr.Number(label="Root Wt (g)")
|
| 132 |
-
yield_gp = gr.Number(label="Yield (g/pot)")
|
| 133 |
|
| 134 |
with gr.Row():
|
| 135 |
predict_btn = gr.Button(" Predict", variant="primary")
|
|
@@ -148,7 +148,6 @@ with gr.Blocks(
|
|
| 148 |
"""
|
| 149 |
### Input Tips:
|
| 150 |
- Select the **pea plant strain** you want to analyze.
|
| 151 |
-
- You can either **select a row** from the Excel sheet to autofill values, or **enter values manually**.
|
| 152 |
- Provide all essential input parameters: **Dose (g/pot), Soil N, Soil P, Soil K, and pH**.
|
| 153 |
- (Optional) Enter actual observed values for:
|
| 154 |
- **Chlorophyll (SPAD)**
|
|
@@ -170,7 +169,6 @@ with gr.Blocks(
|
|
| 170 |
"""
|
| 171 |
)
|
| 172 |
|
| 173 |
-
|
| 174 |
# Autofill callback
|
| 175 |
row_selector.change(
|
| 176 |
fn=autofill_fields,
|
|
|
|
| 17 |
strain_names = df['pea plant strain'].unique().tolist()
|
| 18 |
row_options = ["None, Enter Manually"] + [str(i) for i in range(len(df))]
|
| 19 |
|
| 20 |
+
# # -----------------------------
|
| 21 |
+
# # 2️⃣ Autofill function
|
| 22 |
+
# # -----------------------------
|
| 23 |
+
# def autofill_fields(row_index):
|
| 24 |
+
# if row_index == "None, Enter Manually":
|
| 25 |
+
# return [None]*11
|
| 26 |
+
# row = df.iloc[int(row_index)]
|
| 27 |
+
# return (
|
| 28 |
+
# row['Dose (g/pot)'], row['Soil N (ppm)'], row['Soil P (ppm)'],
|
| 29 |
+
# row['Soil K (ppm)'], row['pH'], row['Chlorophyll (SPAD)'],
|
| 30 |
+
# row['Shoot Length (cm)'], row['Root Length (cm)'], row['Shoot Wt (g)'],
|
| 31 |
+
# row['Root Wt (g)'], row['Yield (g/pot)']
|
| 32 |
+
# )
|
| 33 |
|
| 34 |
# -----------------------------
|
| 35 |
# 3️⃣ Prediction function
|
|
|
|
| 71 |
# Build table DataFrame
|
| 72 |
data = {
|
| 73 |
"Output Metric": target_cols,
|
| 74 |
+
# "Actual Value": actuals + ["N/A"],
|
| 75 |
"Predicted Value": [round(v, 2) for v in y_pred],
|
| 76 |
+
# "Absolute Error": abs_errors + ["N/A"]
|
| 77 |
}
|
| 78 |
result_df = pd.DataFrame(data)
|
| 79 |
|
|
|
|
| 123 |
soil_k = gr.Number(label="Soil K (ppm)")
|
| 124 |
ph = gr.Number(label="pH")
|
| 125 |
|
| 126 |
+
# gr.Markdown("### Autofilled Actual Metrics (from Excel)")
|
| 127 |
+
# chlorophyll = gr.Number(label="Chlorophyll (SPAD)")
|
| 128 |
+
# shoot_len = gr.Number(label="Shoot Length (cm)")
|
| 129 |
+
# root_len = gr.Number(label="Root Length (cm)")
|
| 130 |
+
# shoot_wt = gr.Number(label="Shoot Wt (g)")
|
| 131 |
+
# root_wt = gr.Number(label="Root Wt (g)")
|
| 132 |
+
# yield_gp = gr.Number(label="Yield (g/pot)")
|
| 133 |
|
| 134 |
with gr.Row():
|
| 135 |
predict_btn = gr.Button(" Predict", variant="primary")
|
|
|
|
| 148 |
"""
|
| 149 |
### Input Tips:
|
| 150 |
- Select the **pea plant strain** you want to analyze.
|
|
|
|
| 151 |
- Provide all essential input parameters: **Dose (g/pot), Soil N, Soil P, Soil K, and pH**.
|
| 152 |
- (Optional) Enter actual observed values for:
|
| 153 |
- **Chlorophyll (SPAD)**
|
|
|
|
| 169 |
"""
|
| 170 |
)
|
| 171 |
|
|
|
|
| 172 |
# Autofill callback
|
| 173 |
row_selector.change(
|
| 174 |
fn=autofill_fields,
|