mertkarabacak commited on
Commit
9e1a964
1 Parent(s): b3cb1d2

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -255,7 +255,7 @@ y5_explainer_lgb = shap.TreeExplainer(y5_model_lgb)
255
  def y1_predict_xgb(*args):
256
  df1 = pd.DataFrame([args], columns=x1.columns)
257
  df1 = df1.astype({col: "category" for col in categorical_columns1})
258
- pos_pred = y1_model_xgb.predict(xgb.DMatrix(df1, enable_categorical=True))
259
  return {"Mortality": float(pos_pred[0]), "No Mortality": 1 - float(pos_pred[0])}
260
 
261
  def y1_predict_lgb(*args):
@@ -282,7 +282,7 @@ def y1_predict_rf(*args):
282
  def y2_predict_xgb(*args):
283
  df2 = pd.DataFrame([args], columns=x2.columns)
284
  df2 = df2.astype({col: "category" for col in categorical_columns2})
285
- pos_pred = y2_model_xgb.predict(xgb.DMatrix(df2, enable_categorical=True))
286
  return {"Facility Discharge": float(pos_pred[0]), "Home Discharge": 1 - float(pos_pred[0])}
287
 
288
  def y2_predict_lgb(*args):
@@ -309,7 +309,7 @@ def y2_predict_rf(*args):
309
  def y3_predict_xgb(*args):
310
  df3 = pd.DataFrame([args], columns=x3.columns)
311
  df3 = df3.astype({col: "category" for col in categorical_columns3})
312
- pos_pred = y3_model_xgb.predict(xgb.DMatrix(df3, enable_categorical=True))
313
  return {"Prolonged LOS": float(pos_pred[0]), "No Prolonged LOS": 1 - float(pos_pred[0])}
314
 
315
  def y3_predict_lgb(*args):
@@ -336,12 +336,12 @@ def y3_predict_rf(*args):
336
  def y4_predict_xgb(*args):
337
  df4 = pd.DataFrame([args], columns=x4.columns)
338
  df4 = df4.astype({col: "category" for col in categorical_columns4})
339
- pos_pred = y4_model_xgb.predict(xgb.DMatrix(df4, enable_categorical=True))
340
  return {"Prolonged ICU LOS": float(pos_pred[0]), "No Prolonged ICU LOS": 1 - float(pos_pred[0])}
341
 
342
  def y4_predict_lgb(*args):
343
  df4 = pd.DataFrame([args], columns=x4_lgb.columns)
344
- df4 = df.astype({col: "category" for col in categorical_columns4})
345
  pos_pred = y4_model_lgb.predict(df4)
346
  return {"Prolonged ICU LOS": float(pos_pred[0]), "No Prolonged ICU LOS": 1 - float(pos_pred[0])}
347
 
@@ -363,7 +363,7 @@ def y4_predict_rf(*args):
363
  def y5_predict_xgb(*args):
364
  df5 = pd.DataFrame([args], columns=x5.columns)
365
  df5 = df5.astype({col: "category" for col in categorical_columns5})
366
- pos_pred = y5_model_xgb.predict(xgb.DMatrix(df5, enable_categorical=True))
367
  return {"Major Complications": float(pos_pred[0]), "No Major Complications": 1 - float(pos_pred[0])}
368
 
369
  def y5_predict_lgb(*args):
 
255
  def y1_predict_xgb(*args):
256
  df1 = pd.DataFrame([args], columns=x1.columns)
257
  df1 = df1.astype({col: "category" for col in categorical_columns1})
258
+ pos_pred = y1_model_xgb.predict_proba(xgb.DMatrix(df1, enable_categorical=True))
259
  return {"Mortality": float(pos_pred[0]), "No Mortality": 1 - float(pos_pred[0])}
260
 
261
  def y1_predict_lgb(*args):
 
282
  def y2_predict_xgb(*args):
283
  df2 = pd.DataFrame([args], columns=x2.columns)
284
  df2 = df2.astype({col: "category" for col in categorical_columns2})
285
+ pos_pred = y2_model_xgb.predict_proba(xgb.DMatrix(df2, enable_categorical=True))
286
  return {"Facility Discharge": float(pos_pred[0]), "Home Discharge": 1 - float(pos_pred[0])}
287
 
288
  def y2_predict_lgb(*args):
 
309
  def y3_predict_xgb(*args):
310
  df3 = pd.DataFrame([args], columns=x3.columns)
311
  df3 = df3.astype({col: "category" for col in categorical_columns3})
312
+ pos_pred = y3_model_xgb.predict_proba(xgb.DMatrix(df3, enable_categorical=True))
313
  return {"Prolonged LOS": float(pos_pred[0]), "No Prolonged LOS": 1 - float(pos_pred[0])}
314
 
315
  def y3_predict_lgb(*args):
 
336
  def y4_predict_xgb(*args):
337
  df4 = pd.DataFrame([args], columns=x4.columns)
338
  df4 = df4.astype({col: "category" for col in categorical_columns4})
339
+ pos_pred = y4_model_xgb.predict_proba(xgb.DMatrix(df4, enable_categorical=True))
340
  return {"Prolonged ICU LOS": float(pos_pred[0]), "No Prolonged ICU LOS": 1 - float(pos_pred[0])}
341
 
342
  def y4_predict_lgb(*args):
343
  df4 = pd.DataFrame([args], columns=x4_lgb.columns)
344
+ df4 = df4.astype({col: "category" for col in categorical_columns4})
345
  pos_pred = y4_model_lgb.predict(df4)
346
  return {"Prolonged ICU LOS": float(pos_pred[0]), "No Prolonged ICU LOS": 1 - float(pos_pred[0])}
347
 
 
363
  def y5_predict_xgb(*args):
364
  df5 = pd.DataFrame([args], columns=x5.columns)
365
  df5 = df5.astype({col: "category" for col in categorical_columns5})
366
+ pos_pred = y5_model_xgb.predict_proba(xgb.DMatrix(df5, enable_categorical=True))
367
  return {"Major Complications": float(pos_pred[0]), "No Major Complications": 1 - float(pos_pred[0])}
368
 
369
  def y5_predict_lgb(*args):