Synav commited on
Commit
0a06f0d
·
verified ·
1 Parent(s): 76aaf09

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -1
app.py CHANGED
@@ -105,8 +105,11 @@ def train_and_save(df: pd.DataFrame):
105
 
106
  # Categorical columns
107
  for c in CAT_COLS:
 
108
  X[c] = X[c].astype("object")
109
  X.loc[X[c].isna(), c] = np.nan
 
 
110
 
111
  y01, pos_class = coerce_binary_label(y_raw)
112
 
@@ -230,7 +233,11 @@ with tab_predict:
230
  X_inf = df_inf[FEATURE_COLS].copy()
231
  X_inf = X_inf.replace({pd.NA: np.nan})
232
 
233
-
 
 
 
 
234
  for c in NUM_COLS:
235
  X_inf[c] = pd.to_numeric(X_inf[c], errors="coerce")
236
  for c in CAT_COLS:
 
105
 
106
  # Categorical columns
107
  for c in CAT_COLS:
108
+ # Convert everything to string consistently; keep missing as np.nan
109
  X[c] = X[c].astype("object")
110
  X.loc[X[c].isna(), c] = np.nan
111
+ X[c] = X[c].map(lambda v: v if pd.isna(v) else str(v))
112
+
113
 
114
  y01, pos_class = coerce_binary_label(y_raw)
115
 
 
233
  X_inf = df_inf[FEATURE_COLS].copy()
234
  X_inf = X_inf.replace({pd.NA: np.nan})
235
 
236
+ for c in CAT_COLS:
237
+ X_inf[c] = X_inf[c].astype("object")
238
+ X_inf.loc[X_inf[c].isna(), c] = np.nan
239
+ X_inf[c] = X_inf[c].map(lambda v: v if pd.isna(v) else str(v))
240
+
241
  for c in NUM_COLS:
242
  X_inf[c] = pd.to_numeric(X_inf[c], errors="coerce")
243
  for c in CAT_COLS: