Synav commited on
Commit
181c64d
·
verified ·
1 Parent(s): f8f922f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -2
app.py CHANGED
@@ -1272,10 +1272,17 @@ with tab_predict:
1272
  pipe = st.session_state.pipe
1273
  meta = st.session_state.meta
1274
 
1275
- st.write("DEBUG: feature columns as loaded from meta:")
1276
- st.write(feature_cols)
 
 
1277
 
 
 
1278
 
 
 
 
1279
 
1280
  from datetime import date
1281
 
@@ -1544,6 +1551,9 @@ with tab_predict:
1544
  num_cols = meta["schema"]["numeric"]
1545
  cat_cols = meta["schema"]["categorical"]
1546
 
 
 
 
1547
  # Map normalized name -> actual model column name
1548
  FEATURE_LOOKUP = {norm_col(c): c for c in feature_cols}
1549
 
@@ -1820,7 +1830,9 @@ with tab_predict:
1820
 
1821
  out = X_one.copy()
1822
  out["predicted_probability"] = proba_one
 
1823
  out["predicted_class"] = pred_class
 
1824
  out["risk_band"] = band_one(proba_one)
1825
 
1826
  st.dataframe(out, use_container_width=True)
 
1272
  pipe = st.session_state.pipe
1273
  meta = st.session_state.meta
1274
 
1275
+ # 1) MUST come first: schema from meta
1276
+ feature_cols = meta["schema"]["features"]
1277
+ num_cols = meta["schema"]["numeric"]
1278
+ cat_cols = meta["schema"]["categorical"]
1279
 
1280
+ # 2) Now we can build lookup
1281
+ FEATURE_LOOKUP = {norm_col(c): c for c in feature_cols}
1282
 
1283
+ # 3) Debug (NOW valid)
1284
+ st.write("DEBUG: feature columns as loaded from meta:")
1285
+ st.write(feature_cols)
1286
 
1287
  from datetime import date
1288
 
 
1551
  num_cols = meta["schema"]["numeric"]
1552
  cat_cols = meta["schema"]["categorical"]
1553
 
1554
+ st.write("DEBUG: feature columns as loaded from meta:")
1555
+ st.write(feature_cols)
1556
+
1557
  # Map normalized name -> actual model column name
1558
  FEATURE_LOOKUP = {norm_col(c): c for c in feature_cols}
1559
 
 
1830
 
1831
  out = X_one.copy()
1832
  out["predicted_probability"] = proba_one
1833
+ pred_class = int(proba_one >= thr_single)
1834
  out["predicted_class"] = pred_class
1835
+
1836
  out["risk_band"] = band_one(proba_one)
1837
 
1838
  st.dataframe(out, use_container_width=True)