Spaces:
Runtime error
Runtime error
app version 0.0.2
Browse files
app.py
CHANGED
@@ -34,12 +34,6 @@ def predict(age, female, race, elective, aweekend, zipinc_qrtl, hosp_region, hos
|
|
34 |
prior_cabg, prior_icd, prior_mi, prior_pci, prior_ppm, prior_tia_stroke,
|
35 |
pulmonary_circulation_disorder, smoker, valvular_disease, weight_loss,
|
36 |
endovascular_tavr, transapical_tavr):
|
37 |
-
|
38 |
-
with urllib.request.urlopen('https://github.com/fmegahed/tavr_paper/blob/main/data/final_model.pkl?raw=true') as response,
|
39 |
-
open('final_model.pkl', 'wb') as out_file:
|
40 |
-
shutil.copyfileobj(response, out_file)
|
41 |
-
|
42 |
-
model = load_model('final_model')
|
43 |
|
44 |
df = pd.DataFrame.from_dict({
|
45 |
'age': [age], 'female': [female], 'race': [race], 'elective': elective,
|
@@ -73,7 +67,14 @@ def predict(age, female, race, elective, aweekend, zipinc_qrtl, hosp_region, hos
|
|
73 |
|
74 |
# converting ordinal column to ordinal
|
75 |
df.zipinc_qrtl = df.zipinc_qrtl.astype(ordinal_cat)
|
|
|
|
|
|
|
|
|
76 |
|
|
|
|
|
|
|
77 |
pred = predict_model(model, df, raw_score=True)
|
78 |
|
79 |
return {'Death %': round(100*pred['Score_Yes'][0], 2),
|
|
|
34 |
prior_cabg, prior_icd, prior_mi, prior_pci, prior_ppm, prior_tia_stroke,
|
35 |
pulmonary_circulation_disorder, smoker, valvular_disease, weight_loss,
|
36 |
endovascular_tavr, transapical_tavr):
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
|
38 |
df = pd.DataFrame.from_dict({
|
39 |
'age': [age], 'female': [female], 'race': [race], 'elective': elective,
|
|
|
67 |
|
68 |
# converting ordinal column to ordinal
|
69 |
df.zipinc_qrtl = df.zipinc_qrtl.astype(ordinal_cat)
|
70 |
+
|
71 |
+
# reading the model from GitHub
|
72 |
+
with urllib.request.urlopen('https://github.com/fmegahed/tavr_paper/blob/main/data/final_model.pkl?raw=true') as response, open('final_model.pkl', 'wb') as out_file:
|
73 |
+
shutil.copyfileobj(response, out_file)
|
74 |
|
75 |
+
model = load_model('final_model')
|
76 |
+
|
77 |
+
|
78 |
pred = predict_model(model, df, raw_score=True)
|
79 |
|
80 |
return {'Death %': round(100*pred['Score_Yes'][0], 2),
|