File size: 53,396 Bytes
49e436b 843669a 49e436b 37833d2 49e436b 9e1cb74 49e436b 3c6118d fa3d99d 49e436b fdeec0a 49e436b 4d84f3e 49e436b 4c4701f 49e436b 7621044 49e436b 4d84f3e 49e436b 7621044 49e436b 7621044 49e436b 38e79b7 49e436b 6e1522d 49e436b d8b3637 49e436b 4d84f3e 49e436b 3962b0c 49e436b 4d84f3e 9e1cb74 4d84f3e 9e1cb74 4d84f3e 49e436b 7621044 49e436b 7621044 49e436b 7621044 49e436b 7621044 49e436b 7621044 49e436b 7621044 49e436b 7621044 49e436b 7621044 49e436b 33bee46 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 |
import os
HF_TOKEN = os.getenv("HF_TOKEN")
import numpy as np
import pandas as pd
import sklearn
import sklearn.metrics
from sklearn.metrics import roc_auc_score, roc_curve, precision_recall_curve, auc, precision_score, recall_score, f1_score, classification_report, accuracy_score, confusion_matrix, ConfusionMatrixDisplay, matthews_corrcoef
from sklearn.model_selection import train_test_split
from sklearn.calibration import calibration_curve
from math import sqrt
from scipy import stats as st
from random import randrange
from matplotlib import pyplot
import xgboost as xgb
import lightgbm as lgb
import catboost as cb
from catboost import Pool
from sklearn.ensemble import RandomForestClassifier
import optuna
from optuna.samplers import TPESampler
import shap
import gradio as gr
import random
import re
#Read data.
from datasets import load_dataset
x1 = load_dataset("mertkarabacak/NTDB-Epidural", data_files="mortality_data.csv", use_auth_token = HF_TOKEN)
x1 = pd.DataFrame(x1['train'])
variables = ['Age', 'Sex', 'Ethnicity', 'Weight', 'Height', 'Systolic_Blood_Pressure', 'Pulse_Rate', 'Supplemental_Oxygen', 'Pulse_Oximetry', 'Respiratory_Assistance', 'Respiratory_Rate', 'Temperature', 'PreHospital_Cardiac_Arrest', 'GCS__Eye', 'GCS__Verbal', 'GCS__Motor', 'Total_GCS', 'Pupillary_Response', 'Midline_Shift', 'Current_Smoker', 'Comorbid_Condition__Alcohol_Use_Disorder', 'Comorbid_Condition__Substance_Abuse_Disorder', 'Comorbid_Condition__Diabetes_Mellitus', 'Comorbid_Condition__Hypertension', 'Comorbid_Condition__Congestive_Heart_Failure', 'History_of_Myocardial_Infarction', 'Comorbid_Condition__Angina_Pectoris', 'History_of_Cerebrovascular_Accident', 'Comorbid_Condition__Peripheral_Arterial_Disease', 'Comorbid_Condition__Chronic_Obstructive_Pulmonary_Disease', 'Comorbid_Condition__Chronic_Renal_Failure', 'Comorbid_Condition__Cirrhosis', 'Comorbid_Condition__Bleeding_Disorder', 'Comorbid_Condition__Disseminated_Cancer', 'Comorbid_Condition__Currently_Receiving_Chemotherapy_for_Cancer', 'Comorbid_Condition__Dementia', 'Comorbid_Condition__Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder', 'Comorbid_Condition__Mental_or_Personality_Disorder', 'Ability_to_Complete_AgeAppropriate_ADL', 'Pregnancy', 'Anticoagulant_Therapy', 'Steroid_Use', 'Advanced_Directive_Limiting_Care', 'Days_from_Incident_to_ED_or_Hospital_Arrival', 'Transport_Mode', 'InterFacility_Transfer', 'Trauma_Type', 'Injury_Intent', 'Mechanism_of_Injury', 'WorkRelated', 'AIS_Severity__Maximum_Severity_of_Injury_in_the_Head', 'AIS_Severity__Maximum_Severity_of_Injury_in_the_Face', 'AIS_Severity__Maximum_Severity_of_Injury_in_the_Neck', 'AIS_Severity__Maximum_Severity_of_Injury_in_the_Thorax', 'AIS_Severity__Maximum_Severity_of_Injury_in_the_Abdomen', 'AIS_Severity__Maximum_Severity_of_Injury_in_the_Spine', 'AIS_Severity__Maximum_Severity_of_Injury_in_the_Upper_Extremity', 'AIS_Severity__Maximum_Severity_of_Injury_in_the_Lower_Extremity', 'AIS_Severity__Maximum_Severity_of_Injury_in_Unspecified_Body_Regions', 'AIS_derived_ISS', 'Blood_Transfusion', 'Neurosurgical_Intervention', 'Alcohol_Screen', 'Alcohol_Screen_Result', 'Drug_Screen__Amphetamine', 'Drug_Screen__Barbiturate', 'Drug_Screen__Benzodiazepines', 'Drug_Screen__Cannabinoid', 'Drug_Screen__Cocaine', 'Drug_Screen__MDMA_or_Ecstasy', 'Drug_Screen__Methadone', 'Drug_Screen__Methamphetamine', 'Drug_Screen__Opioid', 'Drug_Screen__Oxycodone', 'Drug_Screen__Phencyclidine', 'Drug_Screen__Tricyclic_Antidepressant', 'ACS_Verification_Level', 'Hospital_Type', 'Facility_Bed_Size', 'Primary_Method_of_Payment', 'Race', 'Cerebral_Monitoring', 'Protective_Device', 'OUTCOME']
x1 = x1[variables]
#Assign unique values as answer options.
unique_SEX = ['Male', 'Female', 'Unknown']
unique_RACE = ['White', 'Black', 'Asian', 'American Indian', 'Pacific Islander', 'Other', 'Unknown']
unique_ETHNICITY = ['Not Hispanic or Latino', 'Hispanic or Latino', 'Unknown']
unique_SUPPLEMENTALOXYGEN = ['No supplemental oxygen', 'Supplemental oxygen', 'Unknown']
unique_RESPIRATORYASSISTANCE = ['Unassisted respiratory rate', 'Assisted respiratory rate', 'Unknown']
unique_PREHOSPITALCARDIACARREST = ['No', 'Yes', 'Unknown']
unique_TBIMIDLINESHIFT = ['No', 'Yes', 'Not imaged/unknown']
unique_TBIPUPILLARYRESPONSE = ['Both reactive', 'One reactive', 'Neither reactive', 'Unknown']
unique_CC_ADHD = ['No', 'Yes', 'Unknown']
unique_CC_ADLC = ['No', 'Yes', 'Unknown']
unique_CC_ALCOHOLISM = ['No', 'Yes', 'Unknown']
unique_CC_ANGINAPECTORIS = ['No', 'Yes', 'Unknown']
unique_CC_ANTICOAGULANT = ['No', 'Yes', 'Unknown']
unique_CC_BLEEDING = ['No', 'Yes', 'Unknown']
unique_CC_CHEMO = ['No', 'Yes', 'Unknown']
unique_CC_CHF = ['No', 'Yes', 'Unknown']
unique_CC_CIRRHOSIS = ['No', 'Yes', 'Unknown']
unique_CC_COPD = ['No', 'Yes', 'Unknown']
unique_CC_CVA = ['No', 'Yes', 'Unknown']
unique_CC_DEMENTIA = ['No', 'Yes', 'Unknown']
unique_CC_DIABETES = ['No', 'Yes', 'Unknown']
unique_CC_DISCANCER = ['No', 'Yes', 'Unknown']
unique_CC_FUNCTIONAL = ['No', 'Yes', 'Unknown']
unique_CC_HYPERTENSION = ['No', 'Yes', 'Unknown']
unique_CC_MENTALPERSONALITY = ['No', 'Yes', 'Unknown']
unique_CC_MI = ['No', 'Yes', 'Unknown']
unique_CC_PAD = ['No', 'Yes', 'Unknown']
unique_CC_RENAL = ['No', 'Yes', 'Unknown']
unique_CC_SMOKING = ['No', 'Yes', 'Unknown']
unique_CC_STEROID = ['No', 'Yes', 'Unknown']
unique_CC_SUBSTANCEABUSE = ['No', 'Yes', 'Unknown']
unique_CC_PREGNANCY = ['No', 'Yes', 'Unknown', 'Not applicable (male patient)']
unique_TRANSPORTMODE = ['Ground ambulance', 'Private vehicle/public vehicle/walk-in', 'Air ambulance', 'Police', 'Other/unknown']
unique_INTERFACILITYTRANSFER = ['No', 'Yes']
unique_TRAUMATYPE = ['Blunt', 'Penetrating', 'Other/unknown']
unique_INTENT = ['Unintentional', 'Assault', 'Self-inflicted', 'Other/undetermined/unknown']
unique_MECHANISM = ['Fall', 'Struck by or against', 'MVT occupant', 'MVT pedestrian', 'MVT motorcyclist', 'MVT pedal cyclist', 'Other MVT', 'Other transport', 'Other pedestrian', 'Other pedal cyclist', 'Firearm', 'Cut/pierce', 'Natural/environmental', 'Machinery', 'Overexertion', 'Other/unspecified/unknown']
unique_PROTDEV = ['None', 'Airbag present', 'Helmet', 'Lap belt', 'Shoulder Belt', 'Protective clothing', 'Protective non-clothing gear', 'Eye protection', 'Unknown']
unique_WORKRELATED = ['No', 'Yes (Unknown)', 'Yes (Construction and Extraction Occupations)', 'Yes (Transportation and Material Moving Occupations)', 'Yes (Installation, Maintenance, and Repair Occupations)', 'Yes (Farming, Fishing, and Forestry Occupations)', 'Yes (Building and Grounds Cleaning and Maintenance)', 'Yes (Food Preparation and Serving Related)', 'Yes (Production Occupations)', 'Yes (Sales and Related Occupations)', 'Yes (Arts, Design, Entertainment, Sports, and Media)', 'Yes (Military Specific Occupations)', 'Yes (Healthcare Practitioners and Technical Occupations)', 'Yes (Management Occupations)', 'Yes (Protective Service Occupations)', 'Yes (Education, Training, and Library Occupations)', 'Yes (Office and Administrative Support Occupations)', 'Yes (Computer and Mathematical Occupations)', 'Yes (Legal Occupations)', 'Yes (Personal Care and Service Occupations)']
unique_INTERVENTION = ['No', 'Yes']
unique_ICP = ['None', 'Intraventricular drain or catheter (e.g. ventriculostomy, external ventricular drain)', 'Intraparenchymal pressure monitor (e.g. Camino bolt, subarachnoid bolt, intraparenchymal catheter)', 'Jugular venous bulb', 'Intraparenchymal oxygen monitor (e.g. Licox)', 'Unknown']
unique_ALCOHOLSCREEN = ['Yes', 'No', 'Unknown']
unique_ANTIBIOTICTHERAPY = ['Yes', 'No', 'Unknown']
unique_DRGSCR_AMPHETAMINE = ['Not tested', 'No', 'Yes']
unique_DRGSCR_BARBITURATE = ['Not tested', 'No', 'Yes']
unique_DRGSCR_BENZODIAZEPINES = ['Not tested', 'No', 'Yes']
unique_DRGSCR_CANNABINOID = ['Not tested', 'No', 'Yes']
unique_DRGSCR_COCAINE = ['Not tested', 'No', 'Yes']
unique_DRGSCR_ECSTASY = ['Not tested', 'No', 'Yes']
unique_DRGSCR_METHADONE = ['Not tested', 'No', 'Yes']
unique_DRGSCR_METHAMPHETAMINE = ['Not tested', 'No', 'Yes']
unique_DRGSCR_OPIOID = ['Not tested', 'No', 'Yes']
unique_DRGSCR_OXYCODONE = ['Not tested', 'No', 'Yes']
unique_DRGSCR_PHENCYCLIDINE = ['Not tested', 'No', 'Yes']
unique_DRGSCR_TRICYCLICDEPRESS = ['Not tested', 'No', 'Yes']
unique_VERIFICATIONLEVEL = ['Level I Trauma Center', 'Level II Trauma Center', 'Level III Trauma Center', 'Unknown']
unique_HOSPITALTYPE = ['Non-profit', 'For profit', 'Government', 'Unknown']
unique_BEDSIZE = ['More than 600', '401 to 600', '201 to 400', '200 or fewer']
unique_PRIMARYMETHODPAYMENT = ['Private/commercial insurance', 'Medicaid', 'Medicare', 'Other government', 'Self-pay', 'Other', 'Not billed', 'Unknown']
#Prepare data for the outcome 1 (mortality).
y1 = x1.pop('OUTCOME')
categorical_columns1 = list(x1.select_dtypes('object').columns)
x1 = x1.astype({col: "category" for col in categorical_columns1})
y1_data_xgb = xgb.DMatrix(x1, label=y1, enable_categorical=True)
x1_lgb = x1.rename(columns = lambda x:re.sub('[^A-Za-z0-9_]+', '', x))
y1_data_lgb = lgb.Dataset(x1_lgb, label=y1)
y1_data_cb = Pool(data=x1, label=y1, cat_features=categorical_columns1)
x1_rf = x1
categorical_columns1 = list(x1_rf.select_dtypes('category').columns)
x1_rf = x1_rf.astype({col: "category" for col in categorical_columns1})
le = sklearn.preprocessing.LabelEncoder()
for col in categorical_columns1:
x1_rf[col] = le.fit_transform(x1_rf[col].astype(str))
d1 = dict.fromkeys(x1_rf.select_dtypes(np.int64).columns, str)
x1_rf = x1_rf.astype(d1)
#Assign hyperparameters.
y1_xgb_params = {'objective': 'binary:logistic', 'booster': 'gbtree', 'lambda': 0.7463867502190046, 'alpha': 0.0007952683509471142, 'max_depth': 2, 'eta': 0.001938108415188413, 'gamma': 0.23560062559306924, 'grow_policy': 'depthwise'}
y1_lgb_params = {'objective': 'binary', 'boosting_type': 'gbdt', 'lambda_l1': 9.55209278055602, 'lambda_l2': 9.791473124643204, 'num_leaves': 13, 'feature_fraction': 0.5992658612730835, 'bagging_fraction': 0.43683499843234525, 'bagging_freq': 4, 'min_child_samples': 26}
y1_cb_params = {'objective': 'CrossEntropy', 'colsample_bylevel': 0.02048734243685444, 'depth': 9, 'boosting_type': 'Ordered', 'bootstrap_type': 'MVS'}
y1_rf_params = {'criterion': 'gini', 'max_features': 'log2', 'max_depth': 1, 'n_estimators': 700, 'min_samples_leaf': 3, 'min_samples_split': 4}
#Modeling for y1 (mortality).
y1_model_xgb = xgb.train(params=y1_xgb_params, dtrain=y1_data_xgb)
y1_explainer_xgb = shap.TreeExplainer(y1_model_xgb)
y1_model_lgb = lgb.train(params=y1_lgb_params, train_set=y1_data_lgb)
y1_explainer_lgb = shap.TreeExplainer(y1_model_lgb)
y1_model_cb = cb.train(pool=y1_data_cb, params=y1_cb_params)
y1_explainer_cb = shap.TreeExplainer(y1_model_cb)
from sklearn.ensemble import RandomForestClassifier as rf
y1_rf = rf(**y1_rf_params)
y1_model_rf = y1_rf.fit(x1_rf, y1)
y1_explainer_rf = shap.TreeExplainer(y1_model_rf)
#Define predict for y1 (mortality).
def y1_predict_xgb(*args):
df_xgb = pd.DataFrame([args], columns=x1.columns)
df_xgb = df_xgb.astype({col: "category" for col in categorical_columns1})
pos_pred = y1_model_xgb.predict(xgb.DMatrix(df_xgb, enable_categorical=True))
return {"Mortality": float(pos_pred[0]), "No Mortality": 1 - float(pos_pred[0])}
def y1_predict_lgb(*args):
df = pd.DataFrame([args], columns=data.columns)
df = df.astype({col: "category" for col in categorical_columns1})
pos_pred = y1_model_lgb.predict(df)
return {"Mortality": float(pos_pred[0]), "No Mortality": 1 - float(pos_pred[0])}
def y1_predict_cb(*args):
df_cb = pd.DataFrame([args], columns=x1.columns)
df_cb = df_cb.astype({col: "category" for col in categorical_columns1})
pos_pred = y1_model_cb.predict(Pool(df_cb, cat_features = categorical_columns1), prediction_type='Probability')
return {"Mortality": float(pos_pred[0][1]), "No Mortality": float(pos_pred[0][0])}
def y1_predict_rf(*args):
df = pd.DataFrame([args], columns=x1_rf.columns)
df = df.astype({col: "category" for col in categorical_columns1})
d = dict.fromkeys(df.select_dtypes(np.int64).columns, np.int32)
df = df.astype(d)
pos_pred = y1_model_rf.predict_proba(df)
return {"Mortality": float(pos_pred[0][1]), "Home Discharge": float(pos_pred[0][0])}
#Define interpret for y1 (mortality).
def y1_interpret_xgb(*args):
df = pd.DataFrame([args], columns=x1.columns)
df = df.astype({col: "category" for col in categorical_columns1})
shap_values = y1_explainer_xgb.shap_values(xgb.DMatrix(df, enable_categorical=True))
scores_desc = list(zip(shap_values[0], x1.columns))
scores_desc = sorted(scores_desc)
fig_m = plt.figure(facecolor='white')
fig_m.set_size_inches(14, 10)
plt.barh([s[1] for s in scores_desc], [s[0] for s in scores_desc])
plt.title("Feature Shap Values", fontsize = 24, pad = 20, fontweight = 'bold')
plt.yticks(fontsize=12)
plt.xlabel("Shap Value", fontsize = 16, labelpad=8, fontweight = 'bold')
plt.ylabel("Feature", fontsize = 16, labelpad=14, fontweight = 'bold')
return fig_m
def y1_interpret_lgb(*args):
df = pd.DataFrame([args], columns=x1.columns)
df = df.astype({col: "category" for col in categorical_columns1})
shap_values = y1_explainer_lgb.shap_values(df)
scores_desc = list(zip(shap_values[0][0], x1.columns))
scores_desc = sorted(scores_desc)
fig_m = plt.figure(facecolor='white')
fig_m.set_size_inches(14, 10)
plt.barh([s[1] for s in scores_desc], [s[0] for s in scores_desc])
plt.title("Feature Shap Values", fontsize = 24, pad = 20, fontweight = 'bold')
plt.yticks(fontsize=12)
plt.xlabel("Shap Value", fontsize = 16, labelpad=8, fontweight = 'bold')
plt.ylabel("Feature", fontsize = 16, labelpad=14, fontweight = 'bold')
return fig_m
def y1_interpret_cb(*args):
df = pd.DataFrame([args], columns=x1.columns)
df = df.astype({col: "category" for col in categorical_columns1})
shap_values = y1_explainer_cb.shap_values(Pool(df, cat_features = categorical_columns1))
scores_desc = list(zip(shap_values[0], x1.columns))
scores_desc = sorted(scores_desc)
fig_m = plt.figure(facecolor='white')
fig_m.set_size_inches(14, 10)
plt.barh([s[1] for s in scores_desc], [s[0] for s in scores_desc])
plt.title("Feature Shap Values", fontsize = 24, pad = 20, fontweight = 'bold')
plt.yticks(fontsize=12)
plt.xlabel("Shap Value", fontsize = 16, labelpad=8, fontweight = 'bold')
plt.ylabel("Feature", fontsize = 16, labelpad=14, fontweight = 'bold')
return fig_m
def y1_interpret_rf(*args):
df = pd.DataFrame([args], columns=x1_rf.columns)
df = df.astype({col: "category" for col in categorical_columns1})
shap_values = y1_explainer_rf.shap_values(df)
scores_desc = list(zip(shap_values[0][0], x1_rf.columns))
scores_desc = sorted(scores_desc)
fig_m = plt.figure(facecolor='white')
fig_m.set_size_inches(14, 10)
plt.barh([s[1] for s in scores_desc], [s[0] for s in scores_desc])
plt.title("Feature Shap Values", fontsize = 24, pad = 20, fontweight = 'bold')
plt.yticks(fontsize=12)
plt.xlabel("Shap Value", fontsize = 16, labelpad=8, fontweight = 'bold')
plt.ylabel("Feature", fontsize = 16, labelpad=14, fontweight = 'bold')
return fig_m
with gr.Blocks(title = "NTDB-Epidural") as demo:
gr.Markdown(
"""
"""
)
gr.Markdown(
"""
# Prediction Tool
## Epidural Hematoma Outcomes
**The publication describing the details of this predictive tool will be posted here upon the acceptance of publication.**
### Disclaimer
The American College of Surgeons National Trauma Data Bank (ACS-NTDB) and the hospitals participating in the ACS-NTDB are the source of the data used herein; they have not been verified and are not responsible for the statistical validity of the data analysis or the conclusions derived by the authors.
The predictive tool located on this web page is for general health information only. This prediction tool should not be used in place of professional medical service for any disease or concern. Users of the prediction tool shouldn't base their decisions about their own health issues on the information presented here. You should ask any questions to your own doctor or another healthcare professional.
The authors of the study mentioned above make no guarantees or representations, either express or implied, as to the completeness, timeliness, comparative or contentious nature, or utility of any information contained in or referred to in this prediction tool. The risk associated with using this prediction tool or the information in this predictive tool is not at all assumed by the authors. The information contained in the prediction tools may be outdated, not complete, or incorrect because health-related information is subject to frequent change and multiple confounders.
No express or implied doctor-patient relationship is established by using the prediction tool. The prediction tools on this website are not validated by the authors. Users of the tool are not contacted by the authors, who also do not record any specific information about them.
You are hereby advised to seek the advice of a doctor or other qualified healthcare provider before making any decisions, acting, or refraining from acting in response to any healthcare problem or issue you may be experiencing at any time, now or in the future. By using the prediction tool, you acknowledge and agree that neither the authors nor any other party are or will be liable or otherwise responsible for any decisions you make, actions you take, or actions you choose not to take as a result of using any information presented here.
By using this tool, you accept all of the above terms.
"""
)
with gr.Row():
with gr.Column():
Age = gr.Slider(label="Age", minimum = 18, maximum = 99, step = 1, value = 37)
Sex = gr.Radio(label = "Sex", choices = unique_SEX, type = 'index', value = 'Male')
Race = gr.Radio(label = "Race", choices = unique_RACE, type = 'index', value = 'White')
Ethnicity = gr.Radio(label = "Ethnicity", choices = unique_ETHNICITY, type = 'index',value = 'Not Hispanic or Latino')
Weight = gr.Slider(label = "Weight (in kilograms)", minimum = 20, maximum = 200, step = 1, value = 75)
Height = gr.Slider(label = "Height (in centimeters)", minimum = 100, maximum = 250, step = 1, value = 175)
Systolic_Blood_Pressure = gr.Slider(label = "Systolic Blood Pressure", minimum = 50, maximum = 250, step = 1, value = 135)
Pulse_Rate = gr.Slider(label = "Pulse Rate", minimum=20, maximum=250, step=1, value = 250)
Supplemental_Oxygen = gr.Radio(label = "Supplemental Oxygen", choices = unique_SUPPLEMENTALOXYGEN, type = 'index', value = 'No supplemental oxygen')
Pulse_Oximetry = gr.Slider(label = "Pulse Oximetry", minimum = 50, maximum = 100, step = 1, value = 99)
Respiratory_Assistance = gr.Radio(label = "Respiratory Assistance", choices = unique_RESPIRATORYASSISTANCE, type = 'index', value = 'Unassisted respiratory rate')
Respiratory_Rate = gr.Slider(label = "Respiratory Rate", minimum = 1, maximum = 99, step = 1, value = 18)
Temperature = gr.Slider(label = "Temperature", minimum = 30, maximum = 50, step = 0.1, value = 36.5)
PreHospital_Cardiac_Arrest = gr.Radio(label = "Pre-Hospital Cardiac Arrest", choices = unique_PREHOSPITALCARDIACARREST, type = 'index', value = 'No')
GCS__Eye = gr.Slider(label = "GCS - Eye", minimum = 1, maximum = 4, step = 1, value = 4)
GCS__Verbal = gr.Slider(label = "GCS - Verbal", minimum = 1, maximum = 5, step = 1, value = 5)
GCS__Motor = gr.Slider(label = "GCS - Motor", minimum = 1, maximum = 6, step = 1, value = 6)
Total_GCS = gr.Slider(label = "GCS - Total", minimum = 1, maximum = 15, step = 1, value = 15)
Pupillary_Response = gr.Radio(label = "Pupillary Response", choices = unique_TBIPUPILLARYRESPONSE, type = 'index', value = 'Both reactive')
Midline_Shift = gr.Radio(label = "Midline Shift", choices = unique_TBIMIDLINESHIFT, type = 'index', value = 'No')
Current_Smoker = gr.Radio(label = "Current Smoker", choices = unique_CC_SMOKING, type = 'index', value = 'No')
Comorbid_Condition__Alcohol_Use_Disorder = gr.Radio(label = "Comorbid Condition - Alcohol Use Disorder", choices = unique_CC_ALCOHOLISM, type = 'index', value = 'No')
Comorbid_Condition__Substance_Abuse_Disorder = gr.Radio(label = "Comorbid Condition - Substance Abuse Disorder", choices = unique_CC_SUBSTANCEABUSE, type = 'index', value = 'No')
Comorbid_Condition__Diabetes_Mellitus = gr.Radio(label = "Comorbid Condition - Diabetes Mellitus", choices = unique_CC_DIABETES, type = 'index', value = 'No')
Comorbid_Condition__Hypertension = gr.Radio(label = "Comorbid Condition - Hypertension", choices = unique_CC_HYPERTENSION, type = 'index', value = 'No')
Comorbid_Condition__Congestive_Heart_Failure = gr.Radio(label = "Comorbid Condition - Congestive Heart Failure", choices = unique_CC_CHF, type = 'index', value = 'No')
History_of_Myocardial_Infarction = gr.Radio(label = "History of Myocardial Infarction", choices = unique_CC_MI, type = 'index', value = 'No')
Comorbid_Condition__Angina_Pectoris = gr.Radio(label = "Comorbid Condition - Angina Pectoris", choices = unique_CC_ANGINAPECTORIS, type = 'index', value = 'No')
History_of_Cerebrovascular_Accident = gr.Radio(label = "History of Cerebrovascular Accident", choices = unique_CC_CVA, type = 'index', value = 'No')
Comorbid_Condition__Peripheral_Arterial_Disease = gr.Radio(label = "Comorbid Condition - Peripheral Arterial Disease", choices = unique_CC_PAD, type = 'index', value = 'No')
Comorbid_Condition__Chronic_Obstructive_Pulmonary_Disease = gr.Radio(label = "Comorbid Condition - Chronic Obstructive Pulmonary Disease", choices = unique_CC_COPD, type = 'index', value = 'No')
Comorbid_Condition__Chronic_Renal_Failure = gr.Radio(label = "Comorbid Condition - Chronic Renal Failure", choices = unique_CC_RENAL, type = 'index', value = 'No')
Comorbid_Condition__Cirrhosis = gr.Radio(label = "Comorbid Condition - Cirrhosis", choices = unique_CC_CIRRHOSIS, type = 'index', value = 'No')
Comorbid_Condition__Bleeding_Disorder = gr.Radio(label = "Comorbid Condition - Bleeding Disorder", choices = unique_CC_BLEEDING, type = 'index', value = 'No')
Comorbid_Condition__Disseminated_Cancer = gr.Radio(label = "Comorbid Condition - Disseminated Cancer", choices = unique_CC_DISCANCER, type = 'index', value = 'No')
Comorbid_Condition__Currently_Receiving_Chemotherapy_for_Cancer = gr.Radio(label = "Comorbid Condition - Currently Receiving Chemotherapy for Cancer", choices = unique_CC_CHEMO, type = 'index', value = 'No')
Comorbid_Condition__Dementia = gr.Radio(label = "Comorbid Condition - Dementia", choices = unique_CC_DEMENTIA, type = 'index', value = 'No')
Comorbid_Condition__Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder = gr.Radio(label = "Comorbid Condition - Attention Deficit Disorder or Attention Deficit Hyperactivity Disorder", choices = unique_CC_ADHD, type = 'index', value = 'No')
Comorbid_Condition__Mental_or_Personality_Disorder = gr.Radio(label = "Comorbid Condition - Mental or Personality Disorder", choices = unique_CC_MENTALPERSONALITY, type = 'index', value = 'No')
Ability_to_Complete_AgeAppropriate_ADL = gr.Radio(label = "Ability to Complete Age-Appropriate ADL", choices = unique_CC_FUNCTIONAL, type = 'index', value = 'Yes')
Pregnancy = gr.Radio(label = "Pregnancy", choices = unique_CC_PREGNANCY, type = 'index', value = 'Not applicable (male patient)')
Anticoagulant_Therapy = gr.Radio(label = "Anticoagulant Therapy", choices = unique_CC_ANTICOAGULANT, type = 'index', value = 'No')
Steroid_Use = gr.Radio(label = "Steroid Use", choices = unique_CC_STEROID, type = 'index', value = 'No')
Advanced_Directive_Limiting_Care = gr.Radio(label = "Advanced Directive Limiting Care", choices = unique_CC_ADLC, type = 'index', value = 'No')
Days_from_Incident_to_ED_or_Hospital_Arrival = gr.Slider(label = "Days from Incident to ED or Hospital Arrival", minimum = 1, maximum = 31, step = 1, value = 1)
Transport_Mode = gr.Radio(label = "Transport Mode", choices = unique_TRANSPORTMODE, type = 'index', value = 'Ground ambulance')
InterFacility_Transfer = gr.Radio(label = "Inter-Facility Transfer", choices = unique_INTERFACILITYTRANSFER, type = 'index', value = 'No')
Trauma_Type = gr.Radio(label = "Trauma Type", choices = unique_TRAUMATYPE, type = 'index', value = 'Blunt')
Injury_Intent = gr.Radio(label = "Injury Intent", choices = unique_INTENT, type = 'index', value = 'Unintentional')
Mechanism_of_Injury = gr.Dropdown(label = "Mechanism of Injury", choices = unique_MECHANISM, type = 'index', value = 'Fall')
Protective_Device = gr.Dropdown(label = "Protective Device", choices = unique_PROTDEV, type = 'index', value = 'None')
WorkRelated = gr.Dropdown(label = "Work-Related", choices = unique_WORKRELATED, type = 'index', value = 'No')
AIS_Severity__Maximum_Severity_of_Injury_in_the_Head = gr.Slider(label = "AIS Severity - Maximum Severity of Injury in the Head", minimum = 0, maximum = 9, step = 1, value = 1)
AIS_Severity__Maximum_Severity_of_Injury_in_the_Face = gr.Slider(label = "AIS Severity - Maximum Severity of Injury in the Face", minimum = 0, maximum = 9, step = 1, value = 1)
AIS_Severity__Maximum_Severity_of_Injury_in_the_Neck = gr.Slider(label = "AIS Severity - Maximum Severity of Injury in the Neck", minimum = 0, maximum = 9, step = 1, value = 0)
AIS_Severity__Maximum_Severity_of_Injury_in_the_Thorax = gr.Slider(label = "AIS Severity - Maximum Severity of Injury in the Thorax", minimum = 0, maximum = 9, step = 1, value = 0)
AIS_Severity__Maximum_Severity_of_Injury_in_the_Abdomen = gr.Slider(label = "AIS Severity - Maximum Severity of Injury in the Abdomen", minimum = 0, maximum = 9, step = 1, value = 0)
AIS_Severity__Maximum_Severity_of_Injury_in_the_Spine = gr.Slider(label = "AIS Severity - Maximum Severity of Injury in the Spine", minimum = 0, maximum = 9, step = 1, value = 0)
AIS_Severity__Maximum_Severity_of_Injury_in_the_Upper_Extremity = gr.Slider(label = "AIS Severity - Maximum Severity of Injury in the Upper Extremity", minimum = 0, maximum = 9, step = 1, value = 0)
AIS_Severity__Maximum_Severity_of_Injury_in_the_Lower_Extremity = gr.Slider(label = "AIS Severity - Maximum Severity of Injury in the Lower Extremity", minimum = 0, maximum = 9, step = 1, value = 0)
AIS_Severity__Maximum_Severity_of_Injury_in_Unspecified_Body_Regions = gr.Slider(label = "AIS Severity - Maximum Severity of Injury in Unspecified Body Regions", minimum = 0, maximum = 9, step = 1, value = 0)
AIS_derived_ISS = gr.Slider(label="AIS derived ISS", minimum = 1, maximum = 75, step = 1, value = 1)
Blood_Transfusion = gr.Slider(label="Blood Transfusion", minimum = 0, maximum = 5000, step = 50, value = 0)
Neurosurgical_Intervention = gr.Radio(label = "Neurosurgical Intervention", choices = unique_INTERVENTION, type = 'index', value = 'No')
Cerebral_Monitoring = gr.Dropdown(label = "Cerebral Monitoring", choices = unique_ICP, type = 'index', value = 'None')
Alcohol_Screen = gr.Radio(label = "Alcohol Screen", choices = unique_ALCOHOLSCREEN, type = 'index', value = 'Yes')
Alcohol_Screen_Result = gr.Slider(label="Alcohol Screen Result", minimum = 0, maximum = 1, step = 0.1, value = 0)
Drug_Screen__Amphetamine = gr.Radio(label = "Drug Screen - Amphetamine", choices = unique_DRGSCR_AMPHETAMINE, type = 'index', value = 'No')
Drug_Screen__Barbiturate = gr.Radio(label = "Drug Screen - Barbiturate", choices = unique_DRGSCR_BARBITURATE, type = 'index', value = 'No')
Drug_Screen__Benzodiazepines = gr.Radio(label = "Drug Screen - Benzodiazepines", choices = unique_DRGSCR_BENZODIAZEPINES, type = 'index', value = 'No')
Drug_Screen__Cannabinoid = gr.Radio(label = "Drug Screen - Cannabinoid", choices = unique_DRGSCR_CANNABINOID, type = 'index', value = 'No')
Drug_Screen__Cocaine = gr.Radio(label = "Drug Screen - Cocaine", choices = unique_DRGSCR_COCAINE, type = 'index', value = 'No')
Drug_Screen__MDMA_or_Ecstasy = gr.Radio(label = "Drug Screen - MDMA or Ecstasy", choices = unique_DRGSCR_ECSTASY, type = 'index', value = 'No')
Drug_Screen__Methadone = gr.Radio(label = "Drug Screen - Methadone", choices = unique_DRGSCR_METHADONE, type = 'index', value = 'No')
Drug_Screen__Methamphetamine = gr.Radio(label = "Drug Screen - Methamphetamine", choices = unique_DRGSCR_METHAMPHETAMINE, type = 'index', value = 'No')
Drug_Screen__Opioid = gr.Radio(label = "Drug Screen - Opioid", choices = unique_DRGSCR_OPIOID, type = 'index', value = 'No')
Drug_Screen__Oxycodone = gr.Radio(label = "Drug Screen - Oxycodone", choices = unique_DRGSCR_OXYCODONE, type = 'index', value = 'No')
Drug_Screen__Phencyclidine = gr.Radio(label = "Drug Screen - Phencyclidine", choices = unique_DRGSCR_PHENCYCLIDINE, type = 'index', value = 'No')
Drug_Screen__Tricyclic_Antidepressant = gr.Radio(label = "Drug Screen - Tricyclic Antidepressant", choices = unique_DRGSCR_TRICYCLICDEPRESS, type = 'index', value = 'No')
ACS_Verification_Level = gr.Radio(label = "ACS Verification Level", choices = unique_VERIFICATIONLEVEL, type = 'index', value = 'Level I Trauma Center')
Hospital_Type = gr.Radio(label = "Hospital Type", choices = unique_HOSPITALTYPE, type = 'index', value = 'Non-profit')
Facility_Bed_Size = gr.Radio(label = "Facility Bed Size", choices = unique_BEDSIZE, type = 'index', value = 'More than 600')
Primary_Method_of_Payment = gr.Dropdown(label = "Primary Method of Payment", choices = unique_PRIMARYMETHODPAYMENT, type = 'index', value = 'Private/commercial insurance')
with gr.Column():
with gr.Box():
with gr.Row():
gr.Markdown(
"""
\n
## Mortality
\n
"""
)
with gr.Row():
y1_predict_btn_xgb = gr.Button(value="Predict (XGBoost)")
y1_predict_btn_lgb = gr.Button(value="Predict (LightGBM)")
y1_predict_btn_cb = gr.Button(value="Predict (CatBoost)")
y1_predict_btn_rf = gr.Button(value="Predict (Random Forest)")
label = gr.Label()
with gr.Row():
y1_interpret_btn_xgb = gr.Button(value="Explain (XGBoost)")
y1_interpret_btn_lgb = gr.Button(value="Explain (LightGBM)")
y1_interpret_btn_cb = gr.Button(value="Explain (CatBoost)")
y1_interpret_btn_rf = gr.Button(value="Explain (Random Forest)")
plot = gr.Plot()
y1_predict_btn_xgb.click(
y1_predict_xgb,
inputs = [Age, Sex, Ethnicity, Weight, Height, Systolic_Blood_Pressure, Pulse_Rate, Supplemental_Oxygen, Pulse_Oximetry, Respiratory_Assistance, Respiratory_Rate, Temperature, PreHospital_Cardiac_Arrest, GCS__Eye, GCS__Verbal, GCS__Motor, Total_GCS, Pupillary_Response, Midline_Shift, Current_Smoker, Comorbid_Condition__Alcohol_Use_Disorder, Comorbid_Condition__Substance_Abuse_Disorder, Comorbid_Condition__Diabetes_Mellitus, Comorbid_Condition__Hypertension, Comorbid_Condition__Congestive_Heart_Failure, History_of_Myocardial_Infarction, Comorbid_Condition__Angina_Pectoris, History_of_Cerebrovascular_Accident, Comorbid_Condition__Peripheral_Arterial_Disease, Comorbid_Condition__Chronic_Obstructive_Pulmonary_Disease, Comorbid_Condition__Chronic_Renal_Failure, Comorbid_Condition__Cirrhosis, Comorbid_Condition__Bleeding_Disorder, Comorbid_Condition__Disseminated_Cancer, Comorbid_Condition__Currently_Receiving_Chemotherapy_for_Cancer, Comorbid_Condition__Dementia, Comorbid_Condition__Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder, Comorbid_Condition__Mental_or_Personality_Disorder, Ability_to_Complete_AgeAppropriate_ADL, Pregnancy, Anticoagulant_Therapy, Steroid_Use, Advanced_Directive_Limiting_Care, Days_from_Incident_to_ED_or_Hospital_Arrival, Transport_Mode, InterFacility_Transfer, Trauma_Type, Injury_Intent, Mechanism_of_Injury, WorkRelated, AIS_Severity__Maximum_Severity_of_Injury_in_the_Head, AIS_Severity__Maximum_Severity_of_Injury_in_the_Face, AIS_Severity__Maximum_Severity_of_Injury_in_the_Neck, AIS_Severity__Maximum_Severity_of_Injury_in_the_Thorax, AIS_Severity__Maximum_Severity_of_Injury_in_the_Abdomen, AIS_Severity__Maximum_Severity_of_Injury_in_the_Spine, AIS_Severity__Maximum_Severity_of_Injury_in_the_Upper_Extremity, AIS_Severity__Maximum_Severity_of_Injury_in_the_Lower_Extremity, AIS_Severity__Maximum_Severity_of_Injury_in_Unspecified_Body_Regions, AIS_derived_ISS, Blood_Transfusion, Neurosurgical_Intervention, Alcohol_Screen, Alcohol_Screen_Result, Drug_Screen__Amphetamine, Drug_Screen__Barbiturate, Drug_Screen__Benzodiazepines, Drug_Screen__Cannabinoid, Drug_Screen__Cocaine, Drug_Screen__MDMA_or_Ecstasy, Drug_Screen__Methadone, Drug_Screen__Methamphetamine, Drug_Screen__Opioid, Drug_Screen__Oxycodone, Drug_Screen__Phencyclidine, Drug_Screen__Tricyclic_Antidepressant, ACS_Verification_Level, Hospital_Type, Facility_Bed_Size, Primary_Method_of_Payment, Race, Cerebral_Monitoring, Protective_Device,],
outputs = [label]
)
y1_predict_btn_lgb.click(
y1_predict_lgb,
inputs = [Age, Sex, Ethnicity, Weight, Height, Systolic_Blood_Pressure, Pulse_Rate, Supplemental_Oxygen, Pulse_Oximetry, Respiratory_Assistance, Respiratory_Rate, Temperature, PreHospital_Cardiac_Arrest, GCS__Eye, GCS__Verbal, GCS__Motor, Total_GCS, Pupillary_Response, Midline_Shift, Current_Smoker, Comorbid_Condition__Alcohol_Use_Disorder, Comorbid_Condition__Substance_Abuse_Disorder, Comorbid_Condition__Diabetes_Mellitus, Comorbid_Condition__Hypertension, Comorbid_Condition__Congestive_Heart_Failure, History_of_Myocardial_Infarction, Comorbid_Condition__Angina_Pectoris, History_of_Cerebrovascular_Accident, Comorbid_Condition__Peripheral_Arterial_Disease, Comorbid_Condition__Chronic_Obstructive_Pulmonary_Disease, Comorbid_Condition__Chronic_Renal_Failure, Comorbid_Condition__Cirrhosis, Comorbid_Condition__Bleeding_Disorder, Comorbid_Condition__Disseminated_Cancer, Comorbid_Condition__Currently_Receiving_Chemotherapy_for_Cancer, Comorbid_Condition__Dementia, Comorbid_Condition__Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder, Comorbid_Condition__Mental_or_Personality_Disorder, Ability_to_Complete_AgeAppropriate_ADL, Pregnancy, Anticoagulant_Therapy, Steroid_Use, Advanced_Directive_Limiting_Care, Days_from_Incident_to_ED_or_Hospital_Arrival, Transport_Mode, InterFacility_Transfer, Trauma_Type, Injury_Intent, Mechanism_of_Injury, WorkRelated, AIS_Severity__Maximum_Severity_of_Injury_in_the_Head, AIS_Severity__Maximum_Severity_of_Injury_in_the_Face, AIS_Severity__Maximum_Severity_of_Injury_in_the_Neck, AIS_Severity__Maximum_Severity_of_Injury_in_the_Thorax, AIS_Severity__Maximum_Severity_of_Injury_in_the_Abdomen, AIS_Severity__Maximum_Severity_of_Injury_in_the_Spine, AIS_Severity__Maximum_Severity_of_Injury_in_the_Upper_Extremity, AIS_Severity__Maximum_Severity_of_Injury_in_the_Lower_Extremity, AIS_Severity__Maximum_Severity_of_Injury_in_Unspecified_Body_Regions, AIS_derived_ISS, Blood_Transfusion, Neurosurgical_Intervention, Alcohol_Screen, Alcohol_Screen_Result, Drug_Screen__Amphetamine, Drug_Screen__Barbiturate, Drug_Screen__Benzodiazepines, Drug_Screen__Cannabinoid, Drug_Screen__Cocaine, Drug_Screen__MDMA_or_Ecstasy, Drug_Screen__Methadone, Drug_Screen__Methamphetamine, Drug_Screen__Opioid, Drug_Screen__Oxycodone, Drug_Screen__Phencyclidine, Drug_Screen__Tricyclic_Antidepressant, ACS_Verification_Level, Hospital_Type, Facility_Bed_Size, Primary_Method_of_Payment, Race, Cerebral_Monitoring, Protective_Device,],
outputs = [label]
)
y1_predict_btn_cb.click(
y1_predict_cb,
inputs = [Age, Sex, Ethnicity, Weight, Height, Systolic_Blood_Pressure, Pulse_Rate, Supplemental_Oxygen, Pulse_Oximetry, Respiratory_Assistance, Respiratory_Rate, Temperature, PreHospital_Cardiac_Arrest, GCS__Eye, GCS__Verbal, GCS__Motor, Total_GCS, Pupillary_Response, Midline_Shift, Current_Smoker, Comorbid_Condition__Alcohol_Use_Disorder, Comorbid_Condition__Substance_Abuse_Disorder, Comorbid_Condition__Diabetes_Mellitus, Comorbid_Condition__Hypertension, Comorbid_Condition__Congestive_Heart_Failure, History_of_Myocardial_Infarction, Comorbid_Condition__Angina_Pectoris, History_of_Cerebrovascular_Accident, Comorbid_Condition__Peripheral_Arterial_Disease, Comorbid_Condition__Chronic_Obstructive_Pulmonary_Disease, Comorbid_Condition__Chronic_Renal_Failure, Comorbid_Condition__Cirrhosis, Comorbid_Condition__Bleeding_Disorder, Comorbid_Condition__Disseminated_Cancer, Comorbid_Condition__Currently_Receiving_Chemotherapy_for_Cancer, Comorbid_Condition__Dementia, Comorbid_Condition__Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder, Comorbid_Condition__Mental_or_Personality_Disorder, Ability_to_Complete_AgeAppropriate_ADL, Pregnancy, Anticoagulant_Therapy, Steroid_Use, Advanced_Directive_Limiting_Care, Days_from_Incident_to_ED_or_Hospital_Arrival, Transport_Mode, InterFacility_Transfer, Trauma_Type, Injury_Intent, Mechanism_of_Injury, WorkRelated, AIS_Severity__Maximum_Severity_of_Injury_in_the_Head, AIS_Severity__Maximum_Severity_of_Injury_in_the_Face, AIS_Severity__Maximum_Severity_of_Injury_in_the_Neck, AIS_Severity__Maximum_Severity_of_Injury_in_the_Thorax, AIS_Severity__Maximum_Severity_of_Injury_in_the_Abdomen, AIS_Severity__Maximum_Severity_of_Injury_in_the_Spine, AIS_Severity__Maximum_Severity_of_Injury_in_the_Upper_Extremity, AIS_Severity__Maximum_Severity_of_Injury_in_the_Lower_Extremity, AIS_Severity__Maximum_Severity_of_Injury_in_Unspecified_Body_Regions, AIS_derived_ISS, Blood_Transfusion, Neurosurgical_Intervention, Alcohol_Screen, Alcohol_Screen_Result, Drug_Screen__Amphetamine, Drug_Screen__Barbiturate, Drug_Screen__Benzodiazepines, Drug_Screen__Cannabinoid, Drug_Screen__Cocaine, Drug_Screen__MDMA_or_Ecstasy, Drug_Screen__Methadone, Drug_Screen__Methamphetamine, Drug_Screen__Opioid, Drug_Screen__Oxycodone, Drug_Screen__Phencyclidine, Drug_Screen__Tricyclic_Antidepressant, ACS_Verification_Level, Hospital_Type, Facility_Bed_Size, Primary_Method_of_Payment, Race, Cerebral_Monitoring, Protective_Device,],
outputs = [label]
)
y1_predict_btn_rf.click(
y1_predict_rf,
inputs = [Age, Sex, Ethnicity, Weight, Height, Systolic_Blood_Pressure, Pulse_Rate, Supplemental_Oxygen, Pulse_Oximetry, Respiratory_Assistance, Respiratory_Rate, Temperature, PreHospital_Cardiac_Arrest, GCS__Eye, GCS__Verbal, GCS__Motor, Total_GCS, Pupillary_Response, Midline_Shift, Current_Smoker, Comorbid_Condition__Alcohol_Use_Disorder, Comorbid_Condition__Substance_Abuse_Disorder, Comorbid_Condition__Diabetes_Mellitus, Comorbid_Condition__Hypertension, Comorbid_Condition__Congestive_Heart_Failure, History_of_Myocardial_Infarction, Comorbid_Condition__Angina_Pectoris, History_of_Cerebrovascular_Accident, Comorbid_Condition__Peripheral_Arterial_Disease, Comorbid_Condition__Chronic_Obstructive_Pulmonary_Disease, Comorbid_Condition__Chronic_Renal_Failure, Comorbid_Condition__Cirrhosis, Comorbid_Condition__Bleeding_Disorder, Comorbid_Condition__Disseminated_Cancer, Comorbid_Condition__Currently_Receiving_Chemotherapy_for_Cancer, Comorbid_Condition__Dementia, Comorbid_Condition__Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder, Comorbid_Condition__Mental_or_Personality_Disorder, Ability_to_Complete_AgeAppropriate_ADL, Pregnancy, Anticoagulant_Therapy, Steroid_Use, Advanced_Directive_Limiting_Care, Days_from_Incident_to_ED_or_Hospital_Arrival, Transport_Mode, InterFacility_Transfer, Trauma_Type, Injury_Intent, Mechanism_of_Injury, WorkRelated, AIS_Severity__Maximum_Severity_of_Injury_in_the_Head, AIS_Severity__Maximum_Severity_of_Injury_in_the_Face, AIS_Severity__Maximum_Severity_of_Injury_in_the_Neck, AIS_Severity__Maximum_Severity_of_Injury_in_the_Thorax, AIS_Severity__Maximum_Severity_of_Injury_in_the_Abdomen, AIS_Severity__Maximum_Severity_of_Injury_in_the_Spine, AIS_Severity__Maximum_Severity_of_Injury_in_the_Upper_Extremity, AIS_Severity__Maximum_Severity_of_Injury_in_the_Lower_Extremity, AIS_Severity__Maximum_Severity_of_Injury_in_Unspecified_Body_Regions, AIS_derived_ISS, Blood_Transfusion, Neurosurgical_Intervention, Alcohol_Screen, Alcohol_Screen_Result, Drug_Screen__Amphetamine, Drug_Screen__Barbiturate, Drug_Screen__Benzodiazepines, Drug_Screen__Cannabinoid, Drug_Screen__Cocaine, Drug_Screen__MDMA_or_Ecstasy, Drug_Screen__Methadone, Drug_Screen__Methamphetamine, Drug_Screen__Opioid, Drug_Screen__Oxycodone, Drug_Screen__Phencyclidine, Drug_Screen__Tricyclic_Antidepressant, ACS_Verification_Level, Hospital_Type, Facility_Bed_Size, Primary_Method_of_Payment, Race, Cerebral_Monitoring, Protective_Device,],
outputs = [label]
)
y1_interpret_btn_xgb.click(
y1_interpret_xgb,
inputs = [Age, Sex, Ethnicity, Weight, Height, Systolic_Blood_Pressure, Pulse_Rate, Supplemental_Oxygen, Pulse_Oximetry, Respiratory_Assistance, Respiratory_Rate, Temperature, PreHospital_Cardiac_Arrest, GCS__Eye, GCS__Verbal, GCS__Motor, Total_GCS, Pupillary_Response, Midline_Shift, Current_Smoker, Comorbid_Condition__Alcohol_Use_Disorder, Comorbid_Condition__Substance_Abuse_Disorder, Comorbid_Condition__Diabetes_Mellitus, Comorbid_Condition__Hypertension, Comorbid_Condition__Congestive_Heart_Failure, History_of_Myocardial_Infarction, Comorbid_Condition__Angina_Pectoris, History_of_Cerebrovascular_Accident, Comorbid_Condition__Peripheral_Arterial_Disease, Comorbid_Condition__Chronic_Obstructive_Pulmonary_Disease, Comorbid_Condition__Chronic_Renal_Failure, Comorbid_Condition__Cirrhosis, Comorbid_Condition__Bleeding_Disorder, Comorbid_Condition__Disseminated_Cancer, Comorbid_Condition__Currently_Receiving_Chemotherapy_for_Cancer, Comorbid_Condition__Dementia, Comorbid_Condition__Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder, Comorbid_Condition__Mental_or_Personality_Disorder, Ability_to_Complete_AgeAppropriate_ADL, Pregnancy, Anticoagulant_Therapy, Steroid_Use, Advanced_Directive_Limiting_Care, Days_from_Incident_to_ED_or_Hospital_Arrival, Transport_Mode, InterFacility_Transfer, Trauma_Type, Injury_Intent, Mechanism_of_Injury, WorkRelated, AIS_Severity__Maximum_Severity_of_Injury_in_the_Head, AIS_Severity__Maximum_Severity_of_Injury_in_the_Face, AIS_Severity__Maximum_Severity_of_Injury_in_the_Neck, AIS_Severity__Maximum_Severity_of_Injury_in_the_Thorax, AIS_Severity__Maximum_Severity_of_Injury_in_the_Abdomen, AIS_Severity__Maximum_Severity_of_Injury_in_the_Spine, AIS_Severity__Maximum_Severity_of_Injury_in_the_Upper_Extremity, AIS_Severity__Maximum_Severity_of_Injury_in_the_Lower_Extremity, AIS_Severity__Maximum_Severity_of_Injury_in_Unspecified_Body_Regions, AIS_derived_ISS, Blood_Transfusion, Neurosurgical_Intervention, Alcohol_Screen, Alcohol_Screen_Result, Drug_Screen__Amphetamine, Drug_Screen__Barbiturate, Drug_Screen__Benzodiazepines, Drug_Screen__Cannabinoid, Drug_Screen__Cocaine, Drug_Screen__MDMA_or_Ecstasy, Drug_Screen__Methadone, Drug_Screen__Methamphetamine, Drug_Screen__Opioid, Drug_Screen__Oxycodone, Drug_Screen__Phencyclidine, Drug_Screen__Tricyclic_Antidepressant, ACS_Verification_Level, Hospital_Type, Facility_Bed_Size, Primary_Method_of_Payment, Race, Cerebral_Monitoring, Protective_Device,],
outputs = [plot],
)
y1_interpret_btn_lgb.click(
y1_interpret_lgb,
inputs = [Age, Sex, Ethnicity, Weight, Height, Systolic_Blood_Pressure, Pulse_Rate, Supplemental_Oxygen, Pulse_Oximetry, Respiratory_Assistance, Respiratory_Rate, Temperature, PreHospital_Cardiac_Arrest, GCS__Eye, GCS__Verbal, GCS__Motor, Total_GCS, Pupillary_Response, Midline_Shift, Current_Smoker, Comorbid_Condition__Alcohol_Use_Disorder, Comorbid_Condition__Substance_Abuse_Disorder, Comorbid_Condition__Diabetes_Mellitus, Comorbid_Condition__Hypertension, Comorbid_Condition__Congestive_Heart_Failure, History_of_Myocardial_Infarction, Comorbid_Condition__Angina_Pectoris, History_of_Cerebrovascular_Accident, Comorbid_Condition__Peripheral_Arterial_Disease, Comorbid_Condition__Chronic_Obstructive_Pulmonary_Disease, Comorbid_Condition__Chronic_Renal_Failure, Comorbid_Condition__Cirrhosis, Comorbid_Condition__Bleeding_Disorder, Comorbid_Condition__Disseminated_Cancer, Comorbid_Condition__Currently_Receiving_Chemotherapy_for_Cancer, Comorbid_Condition__Dementia, Comorbid_Condition__Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder, Comorbid_Condition__Mental_or_Personality_Disorder, Ability_to_Complete_AgeAppropriate_ADL, Pregnancy, Anticoagulant_Therapy, Steroid_Use, Advanced_Directive_Limiting_Care, Days_from_Incident_to_ED_or_Hospital_Arrival, Transport_Mode, InterFacility_Transfer, Trauma_Type, Injury_Intent, Mechanism_of_Injury, WorkRelated, AIS_Severity__Maximum_Severity_of_Injury_in_the_Head, AIS_Severity__Maximum_Severity_of_Injury_in_the_Face, AIS_Severity__Maximum_Severity_of_Injury_in_the_Neck, AIS_Severity__Maximum_Severity_of_Injury_in_the_Thorax, AIS_Severity__Maximum_Severity_of_Injury_in_the_Abdomen, AIS_Severity__Maximum_Severity_of_Injury_in_the_Spine, AIS_Severity__Maximum_Severity_of_Injury_in_the_Upper_Extremity, AIS_Severity__Maximum_Severity_of_Injury_in_the_Lower_Extremity, AIS_Severity__Maximum_Severity_of_Injury_in_Unspecified_Body_Regions, AIS_derived_ISS, Blood_Transfusion, Neurosurgical_Intervention, Alcohol_Screen, Alcohol_Screen_Result, Drug_Screen__Amphetamine, Drug_Screen__Barbiturate, Drug_Screen__Benzodiazepines, Drug_Screen__Cannabinoid, Drug_Screen__Cocaine, Drug_Screen__MDMA_or_Ecstasy, Drug_Screen__Methadone, Drug_Screen__Methamphetamine, Drug_Screen__Opioid, Drug_Screen__Oxycodone, Drug_Screen__Phencyclidine, Drug_Screen__Tricyclic_Antidepressant, ACS_Verification_Level, Hospital_Type, Facility_Bed_Size, Primary_Method_of_Payment, Race, Cerebral_Monitoring, Protective_Device,],
outputs = [plot],
)
y1_interpret_btn_cb.click(
y1_interpret_cb,
inputs = [Age, Sex, Ethnicity, Weight, Height, Systolic_Blood_Pressure, Pulse_Rate, Supplemental_Oxygen, Pulse_Oximetry, Respiratory_Assistance, Respiratory_Rate, Temperature, PreHospital_Cardiac_Arrest, GCS__Eye, GCS__Verbal, GCS__Motor, Total_GCS, Pupillary_Response, Midline_Shift, Current_Smoker, Comorbid_Condition__Alcohol_Use_Disorder, Comorbid_Condition__Substance_Abuse_Disorder, Comorbid_Condition__Diabetes_Mellitus, Comorbid_Condition__Hypertension, Comorbid_Condition__Congestive_Heart_Failure, History_of_Myocardial_Infarction, Comorbid_Condition__Angina_Pectoris, History_of_Cerebrovascular_Accident, Comorbid_Condition__Peripheral_Arterial_Disease, Comorbid_Condition__Chronic_Obstructive_Pulmonary_Disease, Comorbid_Condition__Chronic_Renal_Failure, Comorbid_Condition__Cirrhosis, Comorbid_Condition__Bleeding_Disorder, Comorbid_Condition__Disseminated_Cancer, Comorbid_Condition__Currently_Receiving_Chemotherapy_for_Cancer, Comorbid_Condition__Dementia, Comorbid_Condition__Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder, Comorbid_Condition__Mental_or_Personality_Disorder, Ability_to_Complete_AgeAppropriate_ADL, Pregnancy, Anticoagulant_Therapy, Steroid_Use, Advanced_Directive_Limiting_Care, Days_from_Incident_to_ED_or_Hospital_Arrival, Transport_Mode, InterFacility_Transfer, Trauma_Type, Injury_Intent, Mechanism_of_Injury, WorkRelated, AIS_Severity__Maximum_Severity_of_Injury_in_the_Head, AIS_Severity__Maximum_Severity_of_Injury_in_the_Face, AIS_Severity__Maximum_Severity_of_Injury_in_the_Neck, AIS_Severity__Maximum_Severity_of_Injury_in_the_Thorax, AIS_Severity__Maximum_Severity_of_Injury_in_the_Abdomen, AIS_Severity__Maximum_Severity_of_Injury_in_the_Spine, AIS_Severity__Maximum_Severity_of_Injury_in_the_Upper_Extremity, AIS_Severity__Maximum_Severity_of_Injury_in_the_Lower_Extremity, AIS_Severity__Maximum_Severity_of_Injury_in_Unspecified_Body_Regions, AIS_derived_ISS, Blood_Transfusion, Neurosurgical_Intervention, Alcohol_Screen, Alcohol_Screen_Result, Drug_Screen__Amphetamine, Drug_Screen__Barbiturate, Drug_Screen__Benzodiazepines, Drug_Screen__Cannabinoid, Drug_Screen__Cocaine, Drug_Screen__MDMA_or_Ecstasy, Drug_Screen__Methadone, Drug_Screen__Methamphetamine, Drug_Screen__Opioid, Drug_Screen__Oxycodone, Drug_Screen__Phencyclidine, Drug_Screen__Tricyclic_Antidepressant, ACS_Verification_Level, Hospital_Type, Facility_Bed_Size, Primary_Method_of_Payment, Race, Cerebral_Monitoring, Protective_Device,],
outputs = [plot],
)
y1_interpret_btn_rf.click(
y1_interpret_rf,
inputs = [Age, Sex, Ethnicity, Weight, Height, Systolic_Blood_Pressure, Pulse_Rate, Supplemental_Oxygen, Pulse_Oximetry, Respiratory_Assistance, Respiratory_Rate, Temperature, PreHospital_Cardiac_Arrest, GCS__Eye, GCS__Verbal, GCS__Motor, Total_GCS, Pupillary_Response, Midline_Shift, Current_Smoker, Comorbid_Condition__Alcohol_Use_Disorder, Comorbid_Condition__Substance_Abuse_Disorder, Comorbid_Condition__Diabetes_Mellitus, Comorbid_Condition__Hypertension, Comorbid_Condition__Congestive_Heart_Failure, History_of_Myocardial_Infarction, Comorbid_Condition__Angina_Pectoris, History_of_Cerebrovascular_Accident, Comorbid_Condition__Peripheral_Arterial_Disease, Comorbid_Condition__Chronic_Obstructive_Pulmonary_Disease, Comorbid_Condition__Chronic_Renal_Failure, Comorbid_Condition__Cirrhosis, Comorbid_Condition__Bleeding_Disorder, Comorbid_Condition__Disseminated_Cancer, Comorbid_Condition__Currently_Receiving_Chemotherapy_for_Cancer, Comorbid_Condition__Dementia, Comorbid_Condition__Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder, Comorbid_Condition__Mental_or_Personality_Disorder, Ability_to_Complete_AgeAppropriate_ADL, Pregnancy, Anticoagulant_Therapy, Steroid_Use, Advanced_Directive_Limiting_Care, Days_from_Incident_to_ED_or_Hospital_Arrival, Transport_Mode, InterFacility_Transfer, Trauma_Type, Injury_Intent, Mechanism_of_Injury, WorkRelated, AIS_Severity__Maximum_Severity_of_Injury_in_the_Head, AIS_Severity__Maximum_Severity_of_Injury_in_the_Face, AIS_Severity__Maximum_Severity_of_Injury_in_the_Neck, AIS_Severity__Maximum_Severity_of_Injury_in_the_Thorax, AIS_Severity__Maximum_Severity_of_Injury_in_the_Abdomen, AIS_Severity__Maximum_Severity_of_Injury_in_the_Spine, AIS_Severity__Maximum_Severity_of_Injury_in_the_Upper_Extremity, AIS_Severity__Maximum_Severity_of_Injury_in_the_Lower_Extremity, AIS_Severity__Maximum_Severity_of_Injury_in_Unspecified_Body_Regions, AIS_derived_ISS, Blood_Transfusion, Neurosurgical_Intervention, Alcohol_Screen, Alcohol_Screen_Result, Drug_Screen__Amphetamine, Drug_Screen__Barbiturate, Drug_Screen__Benzodiazepines, Drug_Screen__Cannabinoid, Drug_Screen__Cocaine, Drug_Screen__MDMA_or_Ecstasy, Drug_Screen__Methadone, Drug_Screen__Methamphetamine, Drug_Screen__Opioid, Drug_Screen__Oxycodone, Drug_Screen__Phencyclidine, Drug_Screen__Tricyclic_Antidepressant, ACS_Verification_Level, Hospital_Type, Facility_Bed_Size, Primary_Method_of_Payment, Race, Cerebral_Monitoring, Protective_Device,],
outputs = [plot],
)
demo.launch() |