ashaddams commited on
Commit
7a41708
·
verified ·
1 Parent(s): f8eb81c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -4
app.py CHANGED
@@ -951,7 +951,8 @@ def predict_and_plot_ui(
951
 
952
  # 5) response curve vs selected variable (same chosen model)
953
  plot_var = (plot_var or "light").strip().lower()
954
- if plot_var not in FEATURES: plot_var = "light"
 
955
  j = FEATURES.index(plot_var)
956
 
957
  _load_aug_and_knn(target)
@@ -961,7 +962,7 @@ def predict_and_plot_ui(
961
  grid_rows = []
962
  for xv in xs:
963
  row = dict(raw_row)
964
- if plot_var in ["light","expo_day","expo_night","_c","ph","days"]:
965
  row[plot_var] = float(xv)
966
  grid_rows.append(row)
967
  raw_grid_df = pd.DataFrame(grid_rows)
@@ -998,11 +999,13 @@ def predict_and_plot_ui(
998
  ax.set_ylim(b_lo - pad, b_hi + pad)
999
  plt.tight_layout()
1000
 
 
1001
  clamp_note = " _(clamped to literature range)_" if clamped_point else ""
1002
  md = (
1003
  f"### Prediction ({chosen})\n"
1004
  f"**{target}** = **{yhat:.3f}**{clamp_note} \n"
1005
- f"Local {int((Q_HI-Q_LO)*100)}% interval: **[{lo_pt:.3f}, {hi_pt:.3f}]**"
 
1006
  + ("" if not clamped_curve else "\n\n*Response curve clipped to species×medium range.*")
1007
  )
1008
  if preds_point:
@@ -1017,9 +1020,12 @@ def predict_and_plot_ui(
1017
  return md, fig
1018
 
1019
  except Exception as e:
1020
- fig, ax = plt.subplots(figsize=(6,3)); ax.axis("off"); plt.tight_layout()
 
 
1021
  return f"Error: {e}", fig
1022
 
 
1023
  def doi_matches_ui(target, species, media, light, expo_day, expo_night, temp_c, ph, days):
1024
  return _closest_doi(species, media, light, expo_day, expo_night, temp_c, ph, days, topk=3)
1025
 
 
951
 
952
  # 5) response curve vs selected variable (same chosen model)
953
  plot_var = (plot_var or "light").strip().lower()
954
+ if plot_var not in FEATURES:
955
+ plot_var = "light"
956
  j = FEATURES.index(plot_var)
957
 
958
  _load_aug_and_knn(target)
 
962
  grid_rows = []
963
  for xv in xs:
964
  row = dict(raw_row)
965
+ if plot_var in ["light", "expo_day", "expo_night", "_c", "ph", "days"]:
966
  row[plot_var] = float(xv)
967
  grid_rows.append(row)
968
  raw_grid_df = pd.DataFrame(grid_rows)
 
999
  ax.set_ylim(b_lo - pad, b_hi + pad)
1000
  plt.tight_layout()
1001
 
1002
+ # ---- Markdown output with disclaimer ----
1003
  clamp_note = " _(clamped to literature range)_" if clamped_point else ""
1004
  md = (
1005
  f"### Prediction ({chosen})\n"
1006
  f"**{target}** = **{yhat:.3f}**{clamp_note} \n"
1007
+ f"Local {int((Q_HI-Q_LO)*100)}% interval: **[{lo_pt:.3f}, {hi_pt:.3f}]** \n"
1008
+ f"*Exogenous factors may affect the value; DOI reference advised.*"
1009
  + ("" if not clamped_curve else "\n\n*Response curve clipped to species×medium range.*")
1010
  )
1011
  if preds_point:
 
1020
  return md, fig
1021
 
1022
  except Exception as e:
1023
+ fig, ax = plt.subplots(figsize=(6,3))
1024
+ ax.axis("off")
1025
+ plt.tight_layout()
1026
  return f"Error: {e}", fig
1027
 
1028
+
1029
  def doi_matches_ui(target, species, media, light, expo_day, expo_night, temp_c, ph, days):
1030
  return _closest_doi(species, media, light, expo_day, expo_night, temp_c, ph, days, topk=3)
1031