Synav commited on
Commit
9087964
·
verified ·
1 Parent(s): bee8652

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -0
app.py CHANGED
@@ -281,6 +281,11 @@ def train_survival_bundle(
281
  vars_sorted = var1[X_cols].sort_values(ascending=False)
282
  X_cols = list(vars_sorted.head(k).index)
283
 
 
 
 
 
 
284
  # ---- Fit Cox (use stronger ridge) ----
285
  # For small n / many predictors, penalizer 0.1 is often too weak.
286
  # Typical stable values: 1.0 to 10.0
 
281
  vars_sorted = var1[X_cols].sort_values(ascending=False)
282
  X_cols = list(vars_sorted.head(k).index)
283
 
284
+ # ---- Phase 2 (CRITICAL): refit FINAL imputer on FINAL X_cols ----
285
+ imp = SimpleImputer(strategy="median", keep_empty_features=True)
286
+ X_final = imp.fit_transform(df_surv_oh[X_cols])
287
+ df_surv_oh.loc[:, X_cols] = pd.DataFrame(X_final, columns=X_cols, index=df_surv_oh.index)
288
+
289
  # ---- Fit Cox (use stronger ridge) ----
290
  # For small n / many predictors, penalizer 0.1 is often too weak.
291
  # Typical stable values: 1.0 to 10.0