fmegahed commited on
Commit
7ee25ce
·
verified ·
1 Parent(s): 568d9ac

Updated the default values for the containers and placed the description string outside of the interface function

Browse files
Files changed (1) hide show
  1. app.py +63 -66
app.py CHANGED
@@ -83,79 +83,76 @@ def predict(age, female, race, elective, aweekend, zipinc_qrtl, hosp_region, hos
83
  'Predicting Death Outcome:': pred['Label'][0]}
84
 
85
  # Defining the containers for each input
86
- age = gr.Slider(minimum=18, maximum=100, value=60, label="Age")
87
- female = gr.Dropdown(choices=["Female", "Male"],label = 'Sex')
88
- race = gr.Dropdown(choices=['Asian or Pacific Islander', 'Black', 'Hispanic', 'Native American', 'White', 'Other'], label = 'Race')
89
- elective = gr.Radio(choices=['Elective', 'NonElective'], label = 'Elective')
90
- aweekend = gr.Radio(choices=["No", "Yes"], label = 'Weekend')
91
- zipinc_qrtl = gr.Radio(choices=['FirstQ', 'SecondQ', 'ThirdQ', 'FourthQ'], label = 'Zip Income Quartile')
92
- hosp_region = gr.Radio(choices=['Midwest', 'Northeast', 'South', 'West'], label = 'Hospital Region')
93
- hosp_division = gr.Radio(choices=['New England', 'Middle Atlantic', 'East North Central', 'West North Central', 'South Atlantic', 'East South Central', 'West South Central', 'Mountain', 'Pacific'], label = 'Hospital Division')
94
- hosp_locteach = gr.Radio(choices=['Urban teaching', 'Urban nonteaching', 'Rural'], label= 'Hospital Location/Teaching')
95
- hosp_bedsize = gr.Radio(choices=['Small', 'Medium', 'Large'], label= 'Hospital Bedsize')
96
- h_contrl = gr.Radio(choices= ['Government_nonfederal', 'Private_invest_own', 'Private_not_profit'], label = 'Hospital Control')
97
- pay = gr.Dropdown(choices= ['Private insurance', 'Medicare', 'Medicaid', 'Self-pay', 'No charge', 'Other'], label = 'Payee')
98
- anemia = gr.Radio(choices=["No", "Yes"], label = 'Anemia')
99
- atrial_fibrillation = gr.Radio(choices=["No", "Yes"], label = 'Atrial Fibrillation')
100
- cancer = gr.Radio(choices=["No", "Yes"], label = 'Cancer')
101
- cardiac_arrhythmias = gr.Radio(choices=["No", "Yes"], label = 'Cardiac Arrhythmias')
102
- carotid_artery_disease = gr.Radio(choices=["No", "Yes"], label = 'Carotid Artery Disease')
103
- chronic_kidney_disease = gr.Radio(choices=["No", "Yes"], label = 'Chronic Kidney Disease')
104
- chronic_pulmonary_disease = gr.Radio(choices=["No", "Yes"], label = 'Chronic Pulmonary Disease')
105
- coagulopathy = gr.Radio(choices=["No", "Yes"], label = 'Coagulopathy')
106
- depression = gr.Radio(choices=["No", "Yes"], label = 'Depression')
107
- diabetes_mellitus = gr.Radio(choices=["No", "Yes"], label = 'Diabetes Mellitus')
108
- drug_abuse = gr.Radio(choices=["No", "Yes"], label = 'Drug Abuse')
109
- dyslipidemia = gr.Radio(choices=["No", "Yes"], label = 'Dyslipidemia')
110
- endocarditis = gr.Radio(choices=["No", "Yes"], label = 'Endocarditis')
111
- family_history = gr.Radio(choices=["No", "Yes"], label = 'Family History')
112
- fluid_and_electrolyte_disorder = gr.Radio(choices=["No", "Yes"], label = 'Fluid and Electrolyte Disorder')
113
- heart_failure = gr.Radio(choices=["No", "Yes"], label = 'Heart Failure')
114
- hypertension = gr.Radio(choices=["No", "Yes"], label = 'Hypertension')
115
- known_cad = gr.Radio(choices=["No", "Yes"], label = 'Known CAD')
116
- liver_disease = gr.Radio(choices=["No", "Yes"], label = 'Liver Disease')
117
- obesity = gr.Radio(choices=["No", "Yes"], label = 'Obesity')
118
- peripheral_vascular_disease = gr.Radio(choices=["No", "Yes"], label = 'Peripheral Vascular Disease')
119
- prior_cabg = gr.Radio(choices=["No", "Yes"], label = 'Prior CABG')
120
- prior_icd = gr.Radio(choices=["No", "Yes"], label = 'Prior ICD')
121
- prior_mi = gr.Radio(choices=["No", "Yes"], label = 'Prior MI')
122
- prior_pci = gr.Radio(choices=["No", "Yes"], label = 'Prior PCI')
123
- prior_ppm = gr.Radio(choices=["No", "Yes"], label = 'Prior PPM')
124
- prior_tia_stroke = gr.Radio(choices=["No", "Yes"], label = 'Prior TIA Stroke')
125
- pulmonary_circulation_disorder = gr.Radio(choices=["No", "Yes"], label = 'Pulmonary Circulation Disorder')
126
- smoker = gr.Radio(choices=["No", "Yes"], label = 'Smoker')
127
- valvular_disease = gr.Radio(choices=["No", "Yes"], label = 'Valvular Disease')
128
- weight_loss = gr.Radio(choices=["No", "Yes"], label = 'Weight Loss')
129
- endovascular_tavr = gr.Radio(choices=["No", "Yes"], label = 'Endovascular TAVR')
130
- transapical_tavr = gr.Radio(choices=["No", "Yes"], label = 'Transapical TAVR', value= 'Yes')
131
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
132
 
133
  # Defining and launching the interface
134
  iface = gr.Interface(
135
  fn = predict,
136
- inputs = [age, female, race, elective, aweekend, zipinc_qrtl, hosp_region, hosp_division, hosp_locteach,
137
- hosp_bedsize, h_contrl, pay, anemia, atrial_fibrillation,
138
- cancer, cardiac_arrhythmias, carotid_artery_disease,
139
- chronic_kidney_disease, chronic_pulmonary_disease, coagulopathy,
140
- depression, diabetes_mellitus, drug_abuse, dyslipidemia, endocarditis,
141
- family_history, fluid_and_electrolyte_disorder, heart_failure,
142
- hypertension, known_cad, liver_disease, obesity, peripheral_vascular_disease,
143
- prior_cabg, prior_icd, prior_mi, prior_pci, prior_ppm, prior_tia_stroke,
144
- pulmonary_circulation_disorder, smoker, valvular_disease, weight_loss,
145
- endovascular_tavr, transapical_tavr],
146
  outputs = 'text',
147
  live=True,
148
  title = "Predicting In-Hospital Mortality After TAVR Using Preoperative Variables and Penalized Logistic Regression",
149
- description = """
150
- <p style="font-size:16px; line-height:1.6;">
151
- This app predicts in-hospital mortality after TAVR using a finalized logistic regression model with L2 penalty, based on national inpatient data from 2012–2019 (HCUP NIS).<br>
152
- <br>
153
- Published paper:
154
- <a href="https://www.nature.com/articles/s41598-023-37358-9.pdf" target="_blank">
155
- Alhwiti, T., Aldrugh, S., & Megahed, F. M. (2023), <i>Scientific Reports</i>, 13(1), 10252.
156
- </a>
157
- </p>
158
- """,
159
  css = 'https://bootswatch.com/5/journal/bootstrap.css')
160
 
161
  iface.launch()
 
83
  'Predicting Death Outcome:': pred['Label'][0]}
84
 
85
  # Defining the containers for each input
86
+ inputs = [
87
+ gr.Slider(minimum=18, maximum=100, value=80, label="Age"),
88
+ gr.Dropdown(choices=["Female", "Male"], value="Female", label="Sex"),
89
+ gr.Dropdown(choices=['Asian or Pacific Islander', 'Black', 'Hispanic', 'Native American', 'White', 'Other'], value='White', label='Race'),
90
+ gr.Radio(choices=['Elective', 'NonElective'], value='Elective', label='Elective'),
91
+ gr.Radio(choices=["No", "Yes"], value="No", label='Weekend'),
92
+ gr.Radio(choices=['FirstQ', 'SecondQ', 'ThirdQ', 'FourthQ'], value='SecondQ', label='Zip Income Quartile'),
93
+ gr.Radio(choices=['Midwest', 'Northeast', 'South', 'West'], value='South', label='Hospital Region'),
94
+ gr.Radio(choices=['New England', 'Middle Atlantic', 'East North Central', 'West North Central', 'South Atlantic', 'East South Central', 'West South Central', 'Mountain', 'Pacific'], value='South Atlantic', label='Hospital Division'),
95
+ gr.Radio(choices=['Urban teaching', 'Urban nonteaching', 'Rural'], value='Urban teaching', label='Hospital Location/Teaching'),
96
+ gr.Radio(choices=['Small', 'Medium', 'Large'], value='Large', label='Hospital Bedsize'),
97
+ gr.Radio(choices=['Government_nonfederal', 'Private_invest_own', 'Private_not_profit'], value='Private_not_profit', label='Hospital Control'),
98
+ gr.Dropdown(choices=['Private insurance', 'Medicare', 'Medicaid', 'Self-pay', 'No charge', 'Other'], value='Medicare', label='Payee'),
99
+
100
+ # Comorbidities — default to "No" with some "Yes" for making the default selection more aesthetically pleasing
101
+ gr.Radio(choices=["No", "Yes"], value="Yes", label='Anemia'),
102
+ gr.Radio(choices=["No", "Yes"], value="Yes", label='Atrial Fibrillation'),
103
+ gr.Radio(choices=["No", "Yes"], value="No", label='Cancer'),
104
+ gr.Radio(choices=["No", "Yes"], value="Yes", label='Cardiac Arrhythmias'),
105
+ gr.Radio(choices=["No", "Yes"], value="No", label='Carotid Artery Disease'),
106
+ gr.Radio(choices=["No", "Yes"], value="Yes", label='Chronic Kidney Disease'),
107
+ gr.Radio(choices=["No", "Yes"], value="Yes", label='Chronic Pulmonary Disease'),
108
+ gr.Radio(choices=["No", "Yes"], value="No", label='Coagulopathy'),
109
+ gr.Radio(choices=["No", "Yes"], value="No", label='Depression'),
110
+ gr.Radio(choices=["No", "Yes"], value="Yes", label='Diabetes Mellitus'),
111
+ gr.Radio(choices=["No", "Yes"], value="No", label='Drug Abuse'),
112
+ gr.Radio(choices=["No", "Yes"], value="Yes", label='Dyslipidemia'),
113
+ gr.Radio(choices=["No", "Yes"], value="No", label='Endocarditis'),
114
+ gr.Radio(choices=["No", "Yes"], value="No", label='Family History'),
115
+ gr.Radio(choices=["No", "Yes"], value="Yes", label='Fluid and Electrolyte Disorder'),
116
+ gr.Radio(choices=["No", "Yes"], value="Yes", label='Heart Failure'),
117
+ gr.Radio(choices=["No", "Yes"], value="Yes", label='Hypertension'),
118
+ gr.Radio(choices=["No", "Yes"], value="Yes", label='Known CAD'),
119
+ gr.Radio(choices=["No", "Yes"], value="No", label='Liver Disease'),
120
+ gr.Radio(choices=["No", "Yes"], value="Yes", label='Obesity'),
121
+ gr.Radio(choices=["No", "Yes"], value="Yes", label='Peripheral Vascular Disease'),
122
+ gr.Radio(choices=["No", "Yes"], value="Yes", label='Prior CABG'),
123
+ gr.Radio(choices=["No", "Yes"], value="Yes", label='Prior ICD'),
124
+ gr.Radio(choices=["No", "Yes"], value="Yes", label='Prior MI'),
125
+ gr.Radio(choices=["No", "Yes"], value="Yes", label='Prior PCI'),
126
+ gr.Radio(choices=["No", "Yes"], value="Yes", label='Prior PPM'),
127
+ gr.Radio(choices=["No", "Yes"], value="Yes", label='Prior TIA Stroke'),
128
+ gr.Radio(choices=["No", "Yes"], value="No", label='Pulmonary Circulation Disorder'),
129
+ gr.Radio(choices=["No", "Yes"], value="No", label='Smoker'),
130
+ gr.Radio(choices=["No", "Yes"], value="Yes", label='Valvular Disease'),
131
+ gr.Radio(choices=["No", "Yes"], value="No", label='Weight Loss'),
132
+ gr.Radio(choices=["No", "Yes"], value="Yes", label='Endovascular TAVR'),
133
+ gr.Radio(choices=["No", "Yes"], value="Yes", label='Transapical TAVR')
134
+ ]
135
+
136
+ # The app's first few descriptive lines
137
+ description_html = """
138
+ <p style="font-size:16px; line-height:1.6;">
139
+ This app predicts in-hospital mortality after TAVR using a finalized logistic regression model with L2 penalty, based on national inpatient data from 2012–2019 (HCUP NIS).<br>
140
+ <br>
141
+ Published paper:
142
+ <a href="https://www.nature.com/articles/s41598-023-37358-9.pdf" target="_blank">
143
+ Alhwiti, T., Aldrugh, S., & Megahed, F. M. (2023), <i>Scientific Reports</i>
144
+ </a>
145
+ </p>
146
+ """
147
 
148
  # Defining and launching the interface
149
  iface = gr.Interface(
150
  fn = predict,
151
+ inputs = inputs,
 
 
 
 
 
 
 
 
 
152
  outputs = 'text',
153
  live=True,
154
  title = "Predicting In-Hospital Mortality After TAVR Using Preoperative Variables and Penalized Logistic Regression",
155
+ description = description_html,
 
 
 
 
 
 
 
 
 
156
  css = 'https://bootswatch.com/5/journal/bootstrap.css')
157
 
158
  iface.launch()