Spaces:
Runtime error
Runtime error
Commit
·
fc152b8
1
Parent(s):
4e03e15
Update app.py
Browse files
app.py
CHANGED
@@ -36,7 +36,7 @@ from datasets import load_dataset
|
|
36 |
data = load_dataset("mertkarabacak/NSQIP-CDA", data_files="cda_imputed.csv", use_auth_token = HF_TOKEN)
|
37 |
|
38 |
data = pd.DataFrame(data['train'])
|
39 |
-
variables = ['SEX', 'TRANST', 'AGE', 'SURGSPEC', 'HEIGHT', 'WEIGHT', 'DIABETES', 'SMOKE', 'DYSPNEA', 'FNSTATUS2', 'VENTILAT', 'HXCOPD', 'ASCITES', 'HXCHF', 'HYPERMED', 'RENAFAIL', 'DIALYSIS', 'DISCANCR', 'WNDINF', 'STEROID', 'WTLOSS', 'BLEEDDIS', 'TRANSFUS', 'PRSODM', 'PRBUN', 'PRCREAT', 'PRWBC', 'PRHCT', 'PRPLATE', 'ASACLAS', '
|
40 |
data = data[variables]
|
41 |
|
42 |
data['SEX'] = data['SEX'].replace(['male'], 'Male')
|
@@ -131,19 +131,19 @@ def y1_predict_xgb(*args):
|
|
131 |
df_xgb = pd.DataFrame([args], columns=x.columns)
|
132 |
df_xgb = df_xgb.astype({col: "category" for col in categorical_columns})
|
133 |
pos_pred = y1_model_xgb.predict(xgb.DMatrix(df_xgb, enable_categorical=True))
|
134 |
-
return {"
|
135 |
|
136 |
def y1_predict_lgb(*args):
|
137 |
df = pd.DataFrame([args], columns=data.columns)
|
138 |
df = df.astype({col: "category" for col in categorical_columns})
|
139 |
pos_pred = y1_model_lgb.predict(df)
|
140 |
-
return {"
|
141 |
|
142 |
def y1_predict_cb(*args):
|
143 |
df_cb = pd.DataFrame([args], columns=x.columns)
|
144 |
df_cb = df_cb.astype({col: "category" for col in categorical_columns})
|
145 |
pos_pred = y1_model_cb.predict(Pool(df_cb, cat_features = categorical_columns), prediction_type='Probability')
|
146 |
-
return {"
|
147 |
|
148 |
def y1_predict_rf(*args):
|
149 |
df = pd.DataFrame([args], columns=x_rf.columns)
|
@@ -151,7 +151,7 @@ def y1_predict_rf(*args):
|
|
151 |
d = dict.fromkeys(df.select_dtypes(np.int64).columns, np.int32)
|
152 |
df = df.astype(d)
|
153 |
pos_pred = y1_model_rf.predict_proba(df)
|
154 |
-
return {"
|
155 |
|
156 |
|
157 |
#Define interpret for y1/AE.
|
|
|
36 |
data = load_dataset("mertkarabacak/NSQIP-CDA", data_files="cda_imputed.csv", use_auth_token = HF_TOKEN)
|
37 |
|
38 |
data = pd.DataFrame(data['train'])
|
39 |
+
variables = ['SEX', 'TRANST', 'AGE', 'SURGSPEC', 'HEIGHT', 'WEIGHT', 'DIABETES', 'SMOKE', 'DYSPNEA', 'FNSTATUS2', 'VENTILAT', 'HXCOPD', 'ASCITES', 'HXCHF', 'HYPERMED', 'RENAFAIL', 'DIALYSIS', 'DISCANCR', 'WNDINF', 'STEROID', 'WTLOSS', 'BLEEDDIS', 'TRANSFUS', 'PRSODM', 'PRBUN', 'PRCREAT', 'PRWBC', 'PRHCT', 'PRPLATE', 'ASACLAS', 'BMI', 'RACE', 'LEVELS', 'ADVERSE_OUTCOME']
|
40 |
data = data[variables]
|
41 |
|
42 |
data['SEX'] = data['SEX'].replace(['male'], 'Male')
|
|
|
131 |
df_xgb = pd.DataFrame([args], columns=x.columns)
|
132 |
df_xgb = df_xgb.astype({col: "category" for col in categorical_columns})
|
133 |
pos_pred = y1_model_xgb.predict(xgb.DMatrix(df_xgb, enable_categorical=True))
|
134 |
+
return {"Adverse Outcomes": float(pos_pred[0]), "No Adverse Outcomes": 1 - float(pos_pred[0])}
|
135 |
|
136 |
def y1_predict_lgb(*args):
|
137 |
df = pd.DataFrame([args], columns=data.columns)
|
138 |
df = df.astype({col: "category" for col in categorical_columns})
|
139 |
pos_pred = y1_model_lgb.predict(df)
|
140 |
+
return {"Adverse Outcomes": float(pos_pred[0]), "No Adverse Outcomes": 1 - float(pos_pred[0])}
|
141 |
|
142 |
def y1_predict_cb(*args):
|
143 |
df_cb = pd.DataFrame([args], columns=x.columns)
|
144 |
df_cb = df_cb.astype({col: "category" for col in categorical_columns})
|
145 |
pos_pred = y1_model_cb.predict(Pool(df_cb, cat_features = categorical_columns), prediction_type='Probability')
|
146 |
+
return {"Adverse Outcomes": float(pos_pred[0]), "No Adverse Outcomes": 1 - float(pos_pred[0])}
|
147 |
|
148 |
def y1_predict_rf(*args):
|
149 |
df = pd.DataFrame([args], columns=x_rf.columns)
|
|
|
151 |
d = dict.fromkeys(df.select_dtypes(np.int64).columns, np.int32)
|
152 |
df = df.astype(d)
|
153 |
pos_pred = y1_model_rf.predict_proba(df)
|
154 |
+
return {"Adverse Outcomes": float(pos_pred[0]), "No Adverse Outcomes": 1 - float(pos_pred[0])}
|
155 |
|
156 |
|
157 |
#Define interpret for y1/AE.
|