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 as plt import xgboost as xgb import lightgbm as lgb import catboost as cb from catboost import Pool from sklearn.ensemble import RandomForestClassifier from sklearn.linear_model import LogisticRegression import shap import gradio as gr import random import re import textwrap from datasets import load_dataset #Read data training data. x1 = load_dataset("mertkarabacak/TQP-cSCI", data_files="mortality_data_train.csv", use_auth_token = HF_TOKEN) x1 = pd.DataFrame(x1['train']) variables1 = ['Age', 'Sex', 'Ethnicity', 'Weight', 'Height', 'Systolic_Blood_Pressure', 'Pulse_Rate', 'Supplemental_Oxygen', 'Pulse_Oximetry', 'Respiratory_Assistance', 'Respiratory_Rate', 'Temperature', 'GCS__Eye', 'GCS__Verbal', 'GCS__Motor', 'Total_GCS', 'Fracture_of_C1_Vertebra', 'Fracture_of_C2_Vertebra', 'Fracture_of_C3_Vertebra', 'Fracture_of_C4_Vertebra', 'Fracture_of_C5_Vertebra', 'Fracture_of_C6_Vertebra', 'Fracture_of_C7_Vertebra', 'Rupture_of_Cervical_Intervertebral_Disc', 'Subluxation_and_Dislocation_of_C0/C1_Vertebrae', 'Subluxation_and_Dislocation_of_C1/C2_Vertebrae', 'Subluxation_and_Dislocation_of_C2/C3_Vertebrae', 'Subluxation_and_Dislocation_of_C3/C4_Vertebrae', 'Subluxation_and_Dislocation_of_C4/C5_Vertebrae', 'Subluxation_and_Dislocation_of_C5/C6_Vertebrae', 'Subluxation_and_Dislocation_of_C6/C7_Vertebrae', 'Subluxation_and_Dislocation_of_C7/T1_Vertebrae', 'Concussion_and_Edema_of_cSC', 'Complete_Lesion_of_cSC', 'Anterior_Cord_Syndrome_of_cSC', 'BrownSequard_Syndrome_of_cSC', 'Other_Incomplete_Lesions_of_cSC', 'Current_Smoker', 'Alcohol_Use_Disorder', 'Substance_Abuse_Disorder', 'Diabetes_Mellitus', 'Hypertension', 'Congestive_Heart_Failure', 'History_of_Myocardial_Infarction', 'Angina_Pectoris', 'History_of_Cerebrovascular_Accident', 'Peripheral_Arterial_Disease', 'Chronic_Obstructive_Pulmonary_Disease', 'Chronic_Renal_Failure', 'Cirrhosis', 'Bleeding_Disorder', 'Disseminated_Cancer', 'Currently_Receiving_Chemotherapy_for_Cancer', 'Dementia', 'Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder', 'Mental_or_Personality_Disorder', 'Ability_to_Complete_AgeAppropriate_ADL', 'Pregnancy', 'Anticoagulant_Therapy', 'Steroid_Use', 'Days_from_Incident_to_ED_or_Hospital_Arrival', 'Transport_Mode', 'InterFacility_Transfer', 'Trauma_Type', 'Injury_Intent', 'Mechanism_of_Injury', 'WorkRelated', 'Blood_Transfusion', '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', 'Protective_Device', 'Surgical_Intervention', 'OUTCOME'] x1 = x1[variables1] x2 = load_dataset("mertkarabacak/TQP-cSCI", data_files="discharge_data_train.csv", use_auth_token = HF_TOKEN) x2 = pd.DataFrame(x2['train']) variables2 = ['Age', 'Sex', 'Ethnicity', 'Weight', 'Height', 'Systolic_Blood_Pressure', 'Pulse_Rate', 'Supplemental_Oxygen', 'Pulse_Oximetry', 'Respiratory_Assistance', 'Respiratory_Rate', 'Temperature', 'GCS__Eye', 'GCS__Verbal', 'GCS__Motor', 'Total_GCS', 'Fracture_of_C1_Vertebra', 'Fracture_of_C2_Vertebra', 'Fracture_of_C3_Vertebra', 'Fracture_of_C4_Vertebra', 'Fracture_of_C5_Vertebra', 'Fracture_of_C6_Vertebra', 'Fracture_of_C7_Vertebra', 'Rupture_of_Cervical_Intervertebral_Disc', 'Subluxation_and_Dislocation_of_C0/C1_Vertebrae', 'Subluxation_and_Dislocation_of_C1/C2_Vertebrae', 'Subluxation_and_Dislocation_of_C2/C3_Vertebrae', 'Subluxation_and_Dislocation_of_C3/C4_Vertebrae', 'Subluxation_and_Dislocation_of_C4/C5_Vertebrae', 'Subluxation_and_Dislocation_of_C5/C6_Vertebrae', 'Subluxation_and_Dislocation_of_C6/C7_Vertebrae', 'Subluxation_and_Dislocation_of_C7/T1_Vertebrae', 'Concussion_and_Edema_of_cSC', 'Complete_Lesion_of_cSC', 'Anterior_Cord_Syndrome_of_cSC', 'BrownSequard_Syndrome_of_cSC', 'Other_Incomplete_Lesions_of_cSC', 'Current_Smoker', 'Alcohol_Use_Disorder', 'Substance_Abuse_Disorder', 'Diabetes_Mellitus', 'Hypertension', 'Congestive_Heart_Failure', 'History_of_Myocardial_Infarction', 'Angina_Pectoris', 'History_of_Cerebrovascular_Accident', 'Peripheral_Arterial_Disease', 'Chronic_Obstructive_Pulmonary_Disease', 'Chronic_Renal_Failure', 'Cirrhosis', 'Bleeding_Disorder', 'Disseminated_Cancer', 'Currently_Receiving_Chemotherapy_for_Cancer', 'Dementia', 'Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder', 'Mental_or_Personality_Disorder', 'Ability_to_Complete_AgeAppropriate_ADL', 'Pregnancy', 'Anticoagulant_Therapy', 'Steroid_Use', 'Days_from_Incident_to_ED_or_Hospital_Arrival', 'Transport_Mode', 'InterFacility_Transfer', 'Trauma_Type', 'Injury_Intent', 'Mechanism_of_Injury', 'WorkRelated', 'Blood_Transfusion', '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', 'Protective_Device', 'Surgical_Intervention', 'OUTCOME'] x2 = x2[variables2] x3 = load_dataset("mertkarabacak/TQP-cSCI", data_files="los_data_train.csv", use_auth_token = HF_TOKEN) x3 = pd.DataFrame(x3['train']) variables3 = ['Age', 'Sex', 'Ethnicity', 'Weight', 'Height', 'Systolic_Blood_Pressure', 'Pulse_Rate', 'Supplemental_Oxygen', 'Pulse_Oximetry', 'Respiratory_Assistance', 'Respiratory_Rate', 'Temperature', 'GCS__Eye', 'GCS__Verbal', 'GCS__Motor', 'Total_GCS', 'Fracture_of_C1_Vertebra', 'Fracture_of_C2_Vertebra', 'Fracture_of_C3_Vertebra', 'Fracture_of_C4_Vertebra', 'Fracture_of_C5_Vertebra', 'Fracture_of_C6_Vertebra', 'Fracture_of_C7_Vertebra', 'Rupture_of_Cervical_Intervertebral_Disc', 'Subluxation_and_Dislocation_of_C0/C1_Vertebrae', 'Subluxation_and_Dislocation_of_C1/C2_Vertebrae', 'Subluxation_and_Dislocation_of_C2/C3_Vertebrae', 'Subluxation_and_Dislocation_of_C3/C4_Vertebrae', 'Subluxation_and_Dislocation_of_C4/C5_Vertebrae', 'Subluxation_and_Dislocation_of_C5/C6_Vertebrae', 'Subluxation_and_Dislocation_of_C6/C7_Vertebrae', 'Subluxation_and_Dislocation_of_C7/T1_Vertebrae', 'Concussion_and_Edema_of_cSC', 'Complete_Lesion_of_cSC', 'Anterior_Cord_Syndrome_of_cSC', 'BrownSequard_Syndrome_of_cSC', 'Other_Incomplete_Lesions_of_cSC', 'Current_Smoker', 'Alcohol_Use_Disorder', 'Substance_Abuse_Disorder', 'Diabetes_Mellitus', 'Hypertension', 'Congestive_Heart_Failure', 'History_of_Myocardial_Infarction', 'Angina_Pectoris', 'History_of_Cerebrovascular_Accident', 'Peripheral_Arterial_Disease', 'Chronic_Obstructive_Pulmonary_Disease', 'Chronic_Renal_Failure', 'Cirrhosis', 'Bleeding_Disorder', 'Disseminated_Cancer', 'Currently_Receiving_Chemotherapy_for_Cancer', 'Dementia', 'Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder', 'Mental_or_Personality_Disorder', 'Ability_to_Complete_AgeAppropriate_ADL', 'Pregnancy', 'Anticoagulant_Therapy', 'Steroid_Use', 'Days_from_Incident_to_ED_or_Hospital_Arrival', 'Transport_Mode', 'InterFacility_Transfer', 'Trauma_Type', 'Injury_Intent', 'Mechanism_of_Injury', 'WorkRelated', 'Blood_Transfusion', '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', 'Protective_Device', 'Surgical_Intervention', 'OUTCOME'] x3 = x3[variables3] x4 = load_dataset("mertkarabacak/TQP-cSCI", data_files="iculos_data_train.csv", use_auth_token = HF_TOKEN) x4 = pd.DataFrame(x4['train']) variables4 = ['Age', 'Sex', 'Ethnicity', 'Weight', 'Height', 'Systolic_Blood_Pressure', 'Pulse_Rate', 'Supplemental_Oxygen', 'Pulse_Oximetry', 'Respiratory_Assistance', 'Respiratory_Rate', 'Temperature', 'GCS__Eye', 'GCS__Verbal', 'GCS__Motor', 'Total_GCS', 'Fracture_of_C1_Vertebra', 'Fracture_of_C2_Vertebra', 'Fracture_of_C3_Vertebra', 'Fracture_of_C4_Vertebra', 'Fracture_of_C5_Vertebra', 'Fracture_of_C6_Vertebra', 'Fracture_of_C7_Vertebra', 'Rupture_of_Cervical_Intervertebral_Disc', 'Subluxation_and_Dislocation_of_C0/C1_Vertebrae', 'Subluxation_and_Dislocation_of_C1/C2_Vertebrae', 'Subluxation_and_Dislocation_of_C2/C3_Vertebrae', 'Subluxation_and_Dislocation_of_C3/C4_Vertebrae', 'Subluxation_and_Dislocation_of_C4/C5_Vertebrae', 'Subluxation_and_Dislocation_of_C5/C6_Vertebrae', 'Subluxation_and_Dislocation_of_C6/C7_Vertebrae', 'Subluxation_and_Dislocation_of_C7/T1_Vertebrae', 'Concussion_and_Edema_of_cSC', 'Complete_Lesion_of_cSC', 'Anterior_Cord_Syndrome_of_cSC', 'BrownSequard_Syndrome_of_cSC', 'Other_Incomplete_Lesions_of_cSC', 'Current_Smoker', 'Alcohol_Use_Disorder', 'Substance_Abuse_Disorder', 'Diabetes_Mellitus', 'Hypertension', 'Congestive_Heart_Failure', 'History_of_Myocardial_Infarction', 'Angina_Pectoris', 'History_of_Cerebrovascular_Accident', 'Peripheral_Arterial_Disease', 'Chronic_Obstructive_Pulmonary_Disease', 'Chronic_Renal_Failure', 'Cirrhosis', 'Bleeding_Disorder', 'Disseminated_Cancer', 'Currently_Receiving_Chemotherapy_for_Cancer', 'Dementia', 'Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder', 'Mental_or_Personality_Disorder', 'Ability_to_Complete_AgeAppropriate_ADL', 'Pregnancy', 'Anticoagulant_Therapy', 'Steroid_Use', 'Days_from_Incident_to_ED_or_Hospital_Arrival', 'Transport_Mode', 'InterFacility_Transfer', 'Trauma_Type', 'Injury_Intent', 'Mechanism_of_Injury', 'WorkRelated', 'Blood_Transfusion', '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', 'Protective_Device', 'Surgical_Intervention', 'OUTCOME'] x4 = x4[variables4] x5 = load_dataset("mertkarabacak/TQP-cSCI", data_files="complications_data_train.csv", use_auth_token = HF_TOKEN) x5 = pd.DataFrame(x5['train']) variables5 = ['Age', 'Sex', 'Ethnicity', 'Weight', 'Height', 'Systolic_Blood_Pressure', 'Pulse_Rate', 'Supplemental_Oxygen', 'Pulse_Oximetry', 'Respiratory_Assistance', 'Respiratory_Rate', 'Temperature', 'GCS__Eye', 'GCS__Verbal', 'GCS__Motor', 'Total_GCS', 'Fracture_of_C1_Vertebra', 'Fracture_of_C2_Vertebra', 'Fracture_of_C3_Vertebra', 'Fracture_of_C4_Vertebra', 'Fracture_of_C5_Vertebra', 'Fracture_of_C6_Vertebra', 'Fracture_of_C7_Vertebra', 'Rupture_of_Cervical_Intervertebral_Disc', 'Subluxation_and_Dislocation_of_C0/C1_Vertebrae', 'Subluxation_and_Dislocation_of_C1/C2_Vertebrae', 'Subluxation_and_Dislocation_of_C2/C3_Vertebrae', 'Subluxation_and_Dislocation_of_C3/C4_Vertebrae', 'Subluxation_and_Dislocation_of_C4/C5_Vertebrae', 'Subluxation_and_Dislocation_of_C5/C6_Vertebrae', 'Subluxation_and_Dislocation_of_C6/C7_Vertebrae', 'Subluxation_and_Dislocation_of_C7/T1_Vertebrae', 'Concussion_and_Edema_of_cSC', 'Complete_Lesion_of_cSC', 'Anterior_Cord_Syndrome_of_cSC', 'BrownSequard_Syndrome_of_cSC', 'Other_Incomplete_Lesions_of_cSC', 'Current_Smoker', 'Alcohol_Use_Disorder', 'Substance_Abuse_Disorder', 'Diabetes_Mellitus', 'Hypertension', 'Congestive_Heart_Failure', 'History_of_Myocardial_Infarction', 'Angina_Pectoris', 'History_of_Cerebrovascular_Accident', 'Peripheral_Arterial_Disease', 'Chronic_Obstructive_Pulmonary_Disease', 'Chronic_Renal_Failure', 'Cirrhosis', 'Bleeding_Disorder', 'Disseminated_Cancer', 'Currently_Receiving_Chemotherapy_for_Cancer', 'Dementia', 'Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder', 'Mental_or_Personality_Disorder', 'Ability_to_Complete_AgeAppropriate_ADL', 'Pregnancy', 'Anticoagulant_Therapy', 'Steroid_Use', 'Days_from_Incident_to_ED_or_Hospital_Arrival', 'Transport_Mode', 'InterFacility_Transfer', 'Trauma_Type', 'Injury_Intent', 'Mechanism_of_Injury', 'WorkRelated', 'Blood_Transfusion', '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', 'Protective_Device', 'Surgical_Intervention', 'OUTCOME'] x5 = x5[variables5] #Read validation data. x1_valid = load_dataset("mertkarabacak/TQP-cSCI", data_files="mortality_data_valid.csv", use_auth_token = HF_TOKEN) x1_valid = pd.DataFrame(x1_valid['train']) variables1 = ['Age', 'Sex', 'Ethnicity', 'Weight', 'Height', 'Systolic_Blood_Pressure', 'Pulse_Rate', 'Supplemental_Oxygen', 'Pulse_Oximetry', 'Respiratory_Assistance', 'Respiratory_Rate', 'Temperature', 'GCS__Eye', 'GCS__Verbal', 'GCS__Motor', 'Total_GCS', 'Fracture_of_C1_Vertebra', 'Fracture_of_C2_Vertebra', 'Fracture_of_C3_Vertebra', 'Fracture_of_C4_Vertebra', 'Fracture_of_C5_Vertebra', 'Fracture_of_C6_Vertebra', 'Fracture_of_C7_Vertebra', 'Rupture_of_Cervical_Intervertebral_Disc', 'Subluxation_and_Dislocation_of_C0/C1_Vertebrae', 'Subluxation_and_Dislocation_of_C1/C2_Vertebrae', 'Subluxation_and_Dislocation_of_C2/C3_Vertebrae', 'Subluxation_and_Dislocation_of_C3/C4_Vertebrae', 'Subluxation_and_Dislocation_of_C4/C5_Vertebrae', 'Subluxation_and_Dislocation_of_C5/C6_Vertebrae', 'Subluxation_and_Dislocation_of_C6/C7_Vertebrae', 'Subluxation_and_Dislocation_of_C7/T1_Vertebrae', 'Concussion_and_Edema_of_cSC', 'Complete_Lesion_of_cSC', 'Anterior_Cord_Syndrome_of_cSC', 'BrownSequard_Syndrome_of_cSC', 'Other_Incomplete_Lesions_of_cSC', 'Current_Smoker', 'Alcohol_Use_Disorder', 'Substance_Abuse_Disorder', 'Diabetes_Mellitus', 'Hypertension', 'Congestive_Heart_Failure', 'History_of_Myocardial_Infarction', 'Angina_Pectoris', 'History_of_Cerebrovascular_Accident', 'Peripheral_Arterial_Disease', 'Chronic_Obstructive_Pulmonary_Disease', 'Chronic_Renal_Failure', 'Cirrhosis', 'Bleeding_Disorder', 'Disseminated_Cancer', 'Currently_Receiving_Chemotherapy_for_Cancer', 'Dementia', 'Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder', 'Mental_or_Personality_Disorder', 'Ability_to_Complete_AgeAppropriate_ADL', 'Pregnancy', 'Anticoagulant_Therapy', 'Steroid_Use', 'Days_from_Incident_to_ED_or_Hospital_Arrival', 'Transport_Mode', 'InterFacility_Transfer', 'Trauma_Type', 'Injury_Intent', 'Mechanism_of_Injury', 'WorkRelated', 'Blood_Transfusion', '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', 'Protective_Device', 'Surgical_Intervention', 'OUTCOME'] x1_valid = x1_valid[variables1] x2_valid = load_dataset("mertkarabacak/TQP-cSCI", data_files="discharge_data_valid.csv", use_auth_token = HF_TOKEN) x2_valid = pd.DataFrame(x2_valid['train']) variables1 = ['Age', 'Sex', 'Ethnicity', 'Weight', 'Height', 'Systolic_Blood_Pressure', 'Pulse_Rate', 'Supplemental_Oxygen', 'Pulse_Oximetry', 'Respiratory_Assistance', 'Respiratory_Rate', 'Temperature', 'GCS__Eye', 'GCS__Verbal', 'GCS__Motor', 'Total_GCS', 'Fracture_of_C1_Vertebra', 'Fracture_of_C2_Vertebra', 'Fracture_of_C3_Vertebra', 'Fracture_of_C4_Vertebra', 'Fracture_of_C5_Vertebra', 'Fracture_of_C6_Vertebra', 'Fracture_of_C7_Vertebra', 'Rupture_of_Cervical_Intervertebral_Disc', 'Subluxation_and_Dislocation_of_C0/C1_Vertebrae', 'Subluxation_and_Dislocation_of_C1/C2_Vertebrae', 'Subluxation_and_Dislocation_of_C2/C3_Vertebrae', 'Subluxation_and_Dislocation_of_C3/C4_Vertebrae', 'Subluxation_and_Dislocation_of_C4/C5_Vertebrae', 'Subluxation_and_Dislocation_of_C5/C6_Vertebrae', 'Subluxation_and_Dislocation_of_C6/C7_Vertebrae', 'Subluxation_and_Dislocation_of_C7/T1_Vertebrae', 'Concussion_and_Edema_of_cSC', 'Complete_Lesion_of_cSC', 'Anterior_Cord_Syndrome_of_cSC', 'BrownSequard_Syndrome_of_cSC', 'Other_Incomplete_Lesions_of_cSC', 'Current_Smoker', 'Alcohol_Use_Disorder', 'Substance_Abuse_Disorder', 'Diabetes_Mellitus', 'Hypertension', 'Congestive_Heart_Failure', 'History_of_Myocardial_Infarction', 'Angina_Pectoris', 'History_of_Cerebrovascular_Accident', 'Peripheral_Arterial_Disease', 'Chronic_Obstructive_Pulmonary_Disease', 'Chronic_Renal_Failure', 'Cirrhosis', 'Bleeding_Disorder', 'Disseminated_Cancer', 'Currently_Receiving_Chemotherapy_for_Cancer', 'Dementia', 'Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder', 'Mental_or_Personality_Disorder', 'Ability_to_Complete_AgeAppropriate_ADL', 'Pregnancy', 'Anticoagulant_Therapy', 'Steroid_Use', 'Days_from_Incident_to_ED_or_Hospital_Arrival', 'Transport_Mode', 'InterFacility_Transfer', 'Trauma_Type', 'Injury_Intent', 'Mechanism_of_Injury', 'WorkRelated', 'Blood_Transfusion', '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', 'Protective_Device', 'Surgical_Intervention', 'OUTCOME'] x2_valid = x2_valid[variables1] x3_valid = load_dataset("mertkarabacak/TQP-cSCI", data_files="los_data_valid.csv", use_auth_token = HF_TOKEN) x3_valid = pd.DataFrame(x3_valid['train']) variables1 = ['Age', 'Sex', 'Ethnicity', 'Weight', 'Height', 'Systolic_Blood_Pressure', 'Pulse_Rate', 'Supplemental_Oxygen', 'Pulse_Oximetry', 'Respiratory_Assistance', 'Respiratory_Rate', 'Temperature', 'GCS__Eye', 'GCS__Verbal', 'GCS__Motor', 'Total_GCS', 'Fracture_of_C1_Vertebra', 'Fracture_of_C2_Vertebra', 'Fracture_of_C3_Vertebra', 'Fracture_of_C4_Vertebra', 'Fracture_of_C5_Vertebra', 'Fracture_of_C6_Vertebra', 'Fracture_of_C7_Vertebra', 'Rupture_of_Cervical_Intervertebral_Disc', 'Subluxation_and_Dislocation_of_C0/C1_Vertebrae', 'Subluxation_and_Dislocation_of_C1/C2_Vertebrae', 'Subluxation_and_Dislocation_of_C2/C3_Vertebrae', 'Subluxation_and_Dislocation_of_C3/C4_Vertebrae', 'Subluxation_and_Dislocation_of_C4/C5_Vertebrae', 'Subluxation_and_Dislocation_of_C5/C6_Vertebrae', 'Subluxation_and_Dislocation_of_C6/C7_Vertebrae', 'Subluxation_and_Dislocation_of_C7/T1_Vertebrae', 'Concussion_and_Edema_of_cSC', 'Complete_Lesion_of_cSC', 'Anterior_Cord_Syndrome_of_cSC', 'BrownSequard_Syndrome_of_cSC', 'Other_Incomplete_Lesions_of_cSC', 'Current_Smoker', 'Alcohol_Use_Disorder', 'Substance_Abuse_Disorder', 'Diabetes_Mellitus', 'Hypertension', 'Congestive_Heart_Failure', 'History_of_Myocardial_Infarction', 'Angina_Pectoris', 'History_of_Cerebrovascular_Accident', 'Peripheral_Arterial_Disease', 'Chronic_Obstructive_Pulmonary_Disease', 'Chronic_Renal_Failure', 'Cirrhosis', 'Bleeding_Disorder', 'Disseminated_Cancer', 'Currently_Receiving_Chemotherapy_for_Cancer', 'Dementia', 'Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder', 'Mental_or_Personality_Disorder', 'Ability_to_Complete_AgeAppropriate_ADL', 'Pregnancy', 'Anticoagulant_Therapy', 'Steroid_Use', 'Days_from_Incident_to_ED_or_Hospital_Arrival', 'Transport_Mode', 'InterFacility_Transfer', 'Trauma_Type', 'Injury_Intent', 'Mechanism_of_Injury', 'WorkRelated', 'Blood_Transfusion', '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', 'Protective_Device', 'Surgical_Intervention', 'OUTCOME'] x3_valid = x3_valid[variables1] x4_valid = load_dataset("mertkarabacak/TQP-cSCI", data_files="iculos_data_valid.csv", use_auth_token = HF_TOKEN) x4_valid = pd.DataFrame(x4_valid['train']) variables1 = ['Age', 'Sex', 'Ethnicity', 'Weight', 'Height', 'Systolic_Blood_Pressure', 'Pulse_Rate', 'Supplemental_Oxygen', 'Pulse_Oximetry', 'Respiratory_Assistance', 'Respiratory_Rate', 'Temperature', 'GCS__Eye', 'GCS__Verbal', 'GCS__Motor', 'Total_GCS', 'Fracture_of_C1_Vertebra', 'Fracture_of_C2_Vertebra', 'Fracture_of_C3_Vertebra', 'Fracture_of_C4_Vertebra', 'Fracture_of_C5_Vertebra', 'Fracture_of_C6_Vertebra', 'Fracture_of_C7_Vertebra', 'Rupture_of_Cervical_Intervertebral_Disc', 'Subluxation_and_Dislocation_of_C0/C1_Vertebrae', 'Subluxation_and_Dislocation_of_C1/C2_Vertebrae', 'Subluxation_and_Dislocation_of_C2/C3_Vertebrae', 'Subluxation_and_Dislocation_of_C3/C4_Vertebrae', 'Subluxation_and_Dislocation_of_C4/C5_Vertebrae', 'Subluxation_and_Dislocation_of_C5/C6_Vertebrae', 'Subluxation_and_Dislocation_of_C6/C7_Vertebrae', 'Subluxation_and_Dislocation_of_C7/T1_Vertebrae', 'Concussion_and_Edema_of_cSC', 'Complete_Lesion_of_cSC', 'Anterior_Cord_Syndrome_of_cSC', 'BrownSequard_Syndrome_of_cSC', 'Other_Incomplete_Lesions_of_cSC', 'Current_Smoker', 'Alcohol_Use_Disorder', 'Substance_Abuse_Disorder', 'Diabetes_Mellitus', 'Hypertension', 'Congestive_Heart_Failure', 'History_of_Myocardial_Infarction', 'Angina_Pectoris', 'History_of_Cerebrovascular_Accident', 'Peripheral_Arterial_Disease', 'Chronic_Obstructive_Pulmonary_Disease', 'Chronic_Renal_Failure', 'Cirrhosis', 'Bleeding_Disorder', 'Disseminated_Cancer', 'Currently_Receiving_Chemotherapy_for_Cancer', 'Dementia', 'Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder', 'Mental_or_Personality_Disorder', 'Ability_to_Complete_AgeAppropriate_ADL', 'Pregnancy', 'Anticoagulant_Therapy', 'Steroid_Use', 'Days_from_Incident_to_ED_or_Hospital_Arrival', 'Transport_Mode', 'InterFacility_Transfer', 'Trauma_Type', 'Injury_Intent', 'Mechanism_of_Injury', 'WorkRelated', 'Blood_Transfusion', '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', 'Protective_Device', 'Surgical_Intervention', 'OUTCOME'] x4_valid = x4_valid[variables1] x5_valid = load_dataset("mertkarabacak/TQP-cSCI", data_files="complications_data_valid.csv", use_auth_token = HF_TOKEN) x5_valid = pd.DataFrame(x5_valid['train']) variables1 = ['Age', 'Sex', 'Ethnicity', 'Weight', 'Height', 'Systolic_Blood_Pressure', 'Pulse_Rate', 'Supplemental_Oxygen', 'Pulse_Oximetry', 'Respiratory_Assistance', 'Respiratory_Rate', 'Temperature', 'GCS__Eye', 'GCS__Verbal', 'GCS__Motor', 'Total_GCS', 'Fracture_of_C1_Vertebra', 'Fracture_of_C2_Vertebra', 'Fracture_of_C3_Vertebra', 'Fracture_of_C4_Vertebra', 'Fracture_of_C5_Vertebra', 'Fracture_of_C6_Vertebra', 'Fracture_of_C7_Vertebra', 'Rupture_of_Cervical_Intervertebral_Disc', 'Subluxation_and_Dislocation_of_C0/C1_Vertebrae', 'Subluxation_and_Dislocation_of_C1/C2_Vertebrae', 'Subluxation_and_Dislocation_of_C2/C3_Vertebrae', 'Subluxation_and_Dislocation_of_C3/C4_Vertebrae', 'Subluxation_and_Dislocation_of_C4/C5_Vertebrae', 'Subluxation_and_Dislocation_of_C5/C6_Vertebrae', 'Subluxation_and_Dislocation_of_C6/C7_Vertebrae', 'Subluxation_and_Dislocation_of_C7/T1_Vertebrae', 'Concussion_and_Edema_of_cSC', 'Complete_Lesion_of_cSC', 'Anterior_Cord_Syndrome_of_cSC', 'BrownSequard_Syndrome_of_cSC', 'Other_Incomplete_Lesions_of_cSC', 'Current_Smoker', 'Alcohol_Use_Disorder', 'Substance_Abuse_Disorder', 'Diabetes_Mellitus', 'Hypertension', 'Congestive_Heart_Failure', 'History_of_Myocardial_Infarction', 'Angina_Pectoris', 'History_of_Cerebrovascular_Accident', 'Peripheral_Arterial_Disease', 'Chronic_Obstructive_Pulmonary_Disease', 'Chronic_Renal_Failure', 'Cirrhosis', 'Bleeding_Disorder', 'Disseminated_Cancer', 'Currently_Receiving_Chemotherapy_for_Cancer', 'Dementia', 'Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder', 'Mental_or_Personality_Disorder', 'Ability_to_Complete_AgeAppropriate_ADL', 'Pregnancy', 'Anticoagulant_Therapy', 'Steroid_Use', 'Days_from_Incident_to_ED_or_Hospital_Arrival', 'Transport_Mode', 'InterFacility_Transfer', 'Trauma_Type', 'Injury_Intent', 'Mechanism_of_Injury', 'WorkRelated', 'Blood_Transfusion', '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', 'Protective_Device', 'Surgical_Intervention', 'OUTCOME'] x5_valid = x5_valid[variables1] #Define feature names. f1_names = list(x1.columns) f1_names = [f1.replace('__', ' - ') for f1 in f1_names] f1_names = [f1.replace('_', ' ') for f1 in f1_names] f2_names = list(x2.columns) f2_names = [f2.replace('__', ' - ') for f2 in f2_names] f2_names = [f2.replace('_', ' ') for f2 in f2_names] f3_names = list(x3.columns) f3_names = [f3.replace('__', ' - ') for f3 in f3_names] f3_names = [f3.replace('_', ' ') for f3 in f3_names] f4_names = list(x4.columns) f4_names = [f4.replace('__', ' - ') for f4 in f4_names] f4_names = [f4.replace('_', ' ') for f4 in f4_names] f5_names = list(x5.columns) f5_names = [f5.replace('__', ' - ') for f5 in f5_names] f5_names = [f5.replace('_', ' ') for f5 in f5_names] #Assign unique values as answer options. unique_SEX = ['Male', 'Female', 'Non-Binary', '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_C1FRACTURE = ['No', 'Yes'] unique_C2FRACTURE = ['No', 'Yes'] unique_C3FRACTURE = ['No', 'Yes'] unique_C4FRACTURE = ['No', 'Yes'] unique_C5FRACTURE = ['No', 'Yes'] unique_C6FRACTURE = ['No', 'Yes'] unique_C7FRACTURE = ['No', 'Yes'] unique_IVDRUPTURE = ['No', 'Yes'] unique_C01SUBDIS = ['No', 'Yes'] unique_C12SUBDIS = ['No', 'Yes'] unique_C23SUBDIS = ['No', 'Yes'] unique_C34SUBDIS = ['No', 'Yes'] unique_C45SUBDIS = ['No', 'Yes'] unique_C56SUBDIS = ['No', 'Yes'] unique_C67SUBDIS = ['No', 'Yes'] unique_C71SUBDIS = ['No', 'Yes'] unique_SCEDEMA = ['No', 'Yes'] unique_SCCOMPLETE = ['No', 'Yes'] unique_SCANTCORD = ['No', 'Yes'] unique_SCBROWNSEQ = ['No', 'Yes'] unique_SCINCOMPLETE = ['No', 'Yes'] unique_CC_SMOKING = ['No', 'Yes', 'Unknown'] unique_CC_ALCOHOLISM = ['No', 'Yes', 'Unknown'] unique_CC_SUBSTANCEABUSE = ['No', 'Yes', 'Unknown'] unique_CC_DIABETES = ['No', 'Yes', 'Unknown'] unique_CC_HYPERTENSION = ['No', 'Yes', 'Unknown'] unique_CC_CHF = ['No', 'Yes', 'Unknown'] unique_CC_MI = ['No', 'Yes', 'Unknown'] unique_CC_ANGINAPECTORIS = ['No', 'Yes', 'Unknown'] unique_CC_CVA = ['No', 'Yes', 'Unknown'] unique_CC_PAD = ['No', 'Yes', 'Unknown'] unique_CC_COPD = ['No', 'Yes', 'Unknown'] unique_CC_RENAL = ['No', 'Yes', 'Unknown'] unique_CC_CIRRHOSIS = ['No', 'Yes', 'Unknown'] unique_CC_BLEEDING = ['No', 'Yes', 'Unknown'] unique_CC_DISCANCER = ['No', 'Yes', 'Unknown'] unique_CC_CHEMO = ['No', 'Yes', 'Unknown'] unique_CC_DEMENTIA = ['No', 'Yes', 'Unknown'] unique_CC_ADHD = ['No', 'Yes', 'Unknown'] unique_CC_MENTALPERSONALITY = ['No', 'Yes', 'Unknown'] unique_CC_FUNCTIONAL = ['No', 'Yes', 'Unknown'] unique_CC_PREGNANCY = ['Not applicable (male patient)', 'No', 'Yes', 'Unknown'] unique_CC_ANTICOAGULANT = ['No', 'Yes', 'Unknown'] unique_CC_STEROID = ['No', 'Yes', 'Unknown'] unique_TRANSPORTMODE = ['Ground ambulance', 'Private vehicle/public vehicle/walk-in', 'Air ambulance', 'Other/police/unknown/etc.'] unique_INTERFACILITYTRANSFER = ['No', 'Yes'] unique_TRAUMATYPE = ['Blunt', 'Penetrating', 'Other/unknown'] unique_INTENT = ['Unintentional', 'Assault', 'Self-inflicted', 'Other/unknown'] unique_MECHANISM = ['Fall', 'MVT occupant', 'Struck by or against', 'Other transport or MVT', 'MVT motorcyclist', 'MVT pedestrian', 'Other pedal cyclist', 'Firearm', 'MVT pedal cyclist', 'Natural or environmental', 'Other pedestrian', 'Cut/pierce', 'Machinery', 'Other/unspecified/unknown'] unique_PROTDEV = ['None', 'Belt', 'Airbag present', 'Helmet', 'Protective clothing', 'Protective non-clothing gear', 'Eye protection', 'Other'] unique_WORKRELATED = ['No', 'Yes'] unique_INTERVENTION = ['No', 'Yes'] unique_ICP = ['None', 'Intraventricular drain/catheter', 'Intraparenchymal oxygen/pressure monitor', 'Jugular venous bulb', '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 = ['Medicare', 'Private/commercial insurance', 'Medicaid', 'Self-pay', 'Not billed', 'Other/Unknown'] #Prepare training data for the outcome 1 (mortality). y1 = x1.pop('OUTCOME') x1.loc[x1['Sex'] == 'Male', 'Sex'] = 0 x1.loc[x1['Sex'] == 'Female', 'Sex'] = 1 x1.loc[x1['Sex'] == 'Non-Binary', 'Sex'] = 2 x1.loc[x1['Sex'] == 'Unknown', 'Sex'] = 3 x1.loc[x1['Race'] == 'White', 'Race'] = 0 x1.loc[x1['Race'] == 'Black', 'Race'] = 1 x1.loc[x1['Race'] == 'Asian', 'Race'] = 2 x1.loc[x1['Race'] == 'Other/unknown', 'Race'] = 5 x1.loc[x1['Ethnicity'] == 'Not Hispanic or Latino', 'Ethnicity'] = 0 x1.loc[x1['Ethnicity'] == 'Hispanic or Latino', 'Ethnicity'] = 1 x1.loc[x1['Ethnicity'] == 'Unknown', 'Ethnicity'] = 2 x1.loc[x1['Supplemental_Oxygen'] == 'No supplemental oxygen', 'Supplemental_Oxygen'] = 0 x1.loc[x1['Supplemental_Oxygen'] == 'Supplemental oxygen', 'Supplemental_Oxygen'] = 1 x1.loc[x1['Supplemental_Oxygen'] == 'Unknown', 'Supplemental_Oxygen'] = 2 x1.loc[x1['Respiratory_Assistance'] == 'Unassisted respiratory rate', 'Respiratory_Assistance'] = 0 x1.loc[x1['Respiratory_Assistance'] == 'Assisted respiratory rate', 'Respiratory_Assistance'] = 1 x1.loc[x1['Respiratory_Assistance'] == 'Unknown', 'Respiratory_Assistance'] = 2 x1.loc[x1['Fracture_of_C1_Vertebra'] == 'No', 'Fracture_of_C1_Vertebra'] = 0 x1.loc[x1['Fracture_of_C1_Vertebra'] == 'Yes', 'Fracture_of_C1_Vertebra'] = 1 x1.loc[x1['Fracture_of_C2_Vertebra'] == 'No', 'Fracture_of_C2_Vertebra'] = 0 x1.loc[x1['Fracture_of_C2_Vertebra'] == 'Yes', 'Fracture_of_C2_Vertebra'] = 1 x1.loc[x1['Fracture_of_C3_Vertebra'] == 'No', 'Fracture_of_C3_Vertebra'] = 0 x1.loc[x1['Fracture_of_C3_Vertebra'] == 'Yes', 'Fracture_of_C3_Vertebra'] = 1 x1.loc[x1['Fracture_of_C4_Vertebra'] == 'No', 'Fracture_of_C4_Vertebra'] = 0 x1.loc[x1['Fracture_of_C4_Vertebra'] == 'Yes', 'Fracture_of_C4_Vertebra'] = 1 x1.loc[x1['Fracture_of_C5_Vertebra'] == 'No', 'Fracture_of_C5_Vertebra'] = 0 x1.loc[x1['Fracture_of_C5_Vertebra'] == 'Yes', 'Fracture_of_C5_Vertebra'] = 1 x1.loc[x1['Fracture_of_C6_Vertebra'] == 'No', 'Fracture_of_C6_Vertebra'] = 0 x1.loc[x1['Fracture_of_C6_Vertebra'] == 'Yes', 'Fracture_of_C6_Vertebra'] = 1 x1.loc[x1['Fracture_of_C7_Vertebra'] == 'No', 'Fracture_of_C7_Vertebra'] = 0 x1.loc[x1['Fracture_of_C7_Vertebra'] == 'Yes', 'Fracture_of_C7_Vertebra'] = 1 x1.loc[x1['Rupture_of_Cervical_Intervertebral_Disc'] == 'No', 'Rupture_of_Cervical_Intervertebral_Disc'] = 0 x1.loc[x1['Rupture_of_Cervical_Intervertebral_Disc'] == 'Yes', 'Rupture_of_Cervical_Intervertebral_Disc'] = 1 x1.loc[x1['Subluxation_and_Dislocation_of_C0/C1_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C0/C1_Vertebrae'] = 0 x1.loc[x1['Subluxation_and_Dislocation_of_C0/C1_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C0/C1_Vertebrae'] = 1 x1.loc[x1['Subluxation_and_Dislocation_of_C1/C2_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C1/C2_Vertebrae'] = 0 x1.loc[x1['Subluxation_and_Dislocation_of_C1/C2_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C1/C2_Vertebrae'] = 1 x1.loc[x1['Subluxation_and_Dislocation_of_C2/C3_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C2/C3_Vertebrae'] = 0 x1.loc[x1['Subluxation_and_Dislocation_of_C2/C3_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C2/C3_Vertebrae'] = 1 x1.loc[x1['Subluxation_and_Dislocation_of_C3/C4_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C3/C4_Vertebrae'] = 0 x1.loc[x1['Subluxation_and_Dislocation_of_C3/C4_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C3/C4_Vertebrae'] = 1 x1.loc[x1['Subluxation_and_Dislocation_of_C4/C5_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C4/C5_Vertebrae'] = 0 x1.loc[x1['Subluxation_and_Dislocation_of_C4/C5_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C4/C5_Vertebrae'] = 1 x1.loc[x1['Subluxation_and_Dislocation_of_C5/C6_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C5/C6_Vertebrae'] = 0 x1.loc[x1['Subluxation_and_Dislocation_of_C5/C6_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C5/C6_Vertebrae'] = 1 x1.loc[x1['Subluxation_and_Dislocation_of_C6/C7_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C6/C7_Vertebrae'] = 0 x1.loc[x1['Subluxation_and_Dislocation_of_C6/C7_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C6/C7_Vertebrae'] = 1 x1.loc[x1['Subluxation_and_Dislocation_of_C7/T1_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C7/T1_Vertebrae'] = 0 x1.loc[x1['Subluxation_and_Dislocation_of_C7/T1_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C7/T1_Vertebrae'] = 1 x1.loc[x1['Concussion_and_Edema_of_cSC'] == 'No', 'Concussion_and_Edema_of_cSC'] = 0 x1.loc[x1['Concussion_and_Edema_of_cSC'] == 'Yes', 'Concussion_and_Edema_of_cSC'] = 1 x1.loc[x1['Complete_Lesion_of_cSC'] == 'No', 'Complete_Lesion_of_cSC'] = 0 x1.loc[x1['Complete_Lesion_of_cSC'] == 'Yes', 'Complete_Lesion_of_cSC'] = 1 x1.loc[x1['Anterior_Cord_Syndrome_of_cSC'] == 'No', 'Anterior_Cord_Syndrome_of_cSC'] = 0 x1.loc[x1['Anterior_Cord_Syndrome_of_cSC'] == 'Yes', 'Anterior_Cord_Syndrome_of_cSC'] = 1 x1.loc[x1['BrownSequard_Syndrome_of_cSC'] == 'No', 'BrownSequard_Syndrome_of_cSC'] = 0 x1.loc[x1['BrownSequard_Syndrome_of_cSC'] == 'Yes', 'BrownSequard_Syndrome_of_cSC'] = 1 x1.loc[x1['Other_Incomplete_Lesions_of_cSC'] == 'No', 'Other_Incomplete_Lesions_of_cSC'] = 0 x1.loc[x1['Other_Incomplete_Lesions_of_cSC'] == 'Yes', 'Other_Incomplete_Lesions_of_cSC'] = 1 x1.loc[x1['Current_Smoker'] == 'No', 'Current_Smoker'] = 0 x1.loc[x1['Current_Smoker'] == 'Yes', 'Current_Smoker'] = 1 x1.loc[x1['Current_Smoker'] == 'Unknown', 'Current_Smoker'] = 2 x1.loc[x1['Alcohol_Use_Disorder'] == 'No', 'Alcohol_Use_Disorder'] = 0 x1.loc[x1['Alcohol_Use_Disorder'] == 'Yes', 'Alcohol_Use_Disorder'] = 1 x1.loc[x1['Alcohol_Use_Disorder'] == 'Unknown', 'Alcohol_Use_Disorder'] = 2 x1.loc[x1['Substance_Abuse_Disorder'] == 'No', 'Substance_Abuse_Disorder'] = 0 x1.loc[x1['Substance_Abuse_Disorder'] == 'Yes', 'Substance_Abuse_Disorder'] = 1 x1.loc[x1['Substance_Abuse_Disorder'] == 'Unknown', 'Substance_Abuse_Disorder'] = 2 x1.loc[x1['Diabetes_Mellitus'] == 'No', 'Diabetes_Mellitus'] = 0 x1.loc[x1['Diabetes_Mellitus'] == 'Yes', 'Diabetes_Mellitus'] = 1 x1.loc[x1['Diabetes_Mellitus'] == 'Unknown', 'Diabetes_Mellitus'] = 2 x1.loc[x1['Hypertension'] == 'No', 'Hypertension'] = 0 x1.loc[x1['Hypertension'] == 'Yes', 'Hypertension'] = 1 x1.loc[x1['Hypertension'] == 'Unknown', 'Hypertension'] = 2 x1.loc[x1['Congestive_Heart_Failure'] == 'No', 'Congestive_Heart_Failure'] = 0 x1.loc[x1['Congestive_Heart_Failure'] == 'Yes', 'Congestive_Heart_Failure'] = 1 x1.loc[x1['Congestive_Heart_Failure'] == 'Unknown', 'Congestive_Heart_Failure'] = 2 x1.loc[x1['History_of_Myocardial_Infarction'] == 'No', 'History_of_Myocardial_Infarction'] = 0 x1.loc[x1['History_of_Myocardial_Infarction'] == 'Yes', 'History_of_Myocardial_Infarction'] = 1 x1.loc[x1['History_of_Myocardial_Infarction'] == 'Unknown', 'History_of_Myocardial_Infarction'] = 2 x1.loc[x1['Angina_Pectoris'] == 'No', 'Angina_Pectoris'] = 0 x1.loc[x1['Angina_Pectoris'] == 'Yes', 'Angina_Pectoris'] = 1 x1.loc[x1['Angina_Pectoris'] == 'Unknown', 'Angina_Pectoris'] = 2 x1.loc[x1['History_of_Cerebrovascular_Accident'] == 'No', 'History_of_Cerebrovascular_Accident'] = 0 x1.loc[x1['History_of_Cerebrovascular_Accident'] == 'Yes', 'History_of_Cerebrovascular_Accident'] = 1 x1.loc[x1['History_of_Cerebrovascular_Accident'] == 'Unknown', 'History_of_Cerebrovascular_Accident'] = 2 x1.loc[x1['Peripheral_Arterial_Disease'] == 'No', 'Peripheral_Arterial_Disease'] = 0 x1.loc[x1['Peripheral_Arterial_Disease'] == 'Yes', 'Peripheral_Arterial_Disease'] = 1 x1.loc[x1['Peripheral_Arterial_Disease'] == 'Unknown', 'Peripheral_Arterial_Disease'] = 2 x1.loc[x1['Chronic_Obstructive_Pulmonary_Disease'] == 'No', 'Chronic_Obstructive_Pulmonary_Disease'] = 0 x1.loc[x1['Chronic_Obstructive_Pulmonary_Disease'] == 'Yes', 'Chronic_Obstructive_Pulmonary_Disease'] = 1 x1.loc[x1['Chronic_Obstructive_Pulmonary_Disease'] == 'Unknown', 'Chronic_Obstructive_Pulmonary_Disease'] = 2 x1.loc[x1['Chronic_Renal_Failure'] == 'No', 'Chronic_Renal_Failure'] = 0 x1.loc[x1['Chronic_Renal_Failure'] == 'Yes', 'Chronic_Renal_Failure'] = 1 x1.loc[x1['Chronic_Renal_Failure'] == 'Unknown', 'Chronic_Renal_Failure'] = 2 x1.loc[x1['Cirrhosis'] == 'No', 'Cirrhosis'] = 0 x1.loc[x1['Cirrhosis'] == 'Yes', 'Cirrhosis'] = 1 x1.loc[x1['Cirrhosis'] == 'Unknown', 'Cirrhosis'] = 2 x1.loc[x1['Bleeding_Disorder'] == 'No', 'Bleeding_Disorder'] = 0 x1.loc[x1['Bleeding_Disorder'] == 'Yes', 'Bleeding_Disorder'] = 1 x1.loc[x1['Bleeding_Disorder'] == 'Unknown', 'Bleeding_Disorder'] = 2 x1.loc[x1['Disseminated_Cancer'] == 'No', 'Disseminated_Cancer'] = 0 x1.loc[x1['Disseminated_Cancer'] == 'Yes', 'Disseminated_Cancer'] = 1 x1.loc[x1['Disseminated_Cancer'] == 'Unknown', 'Disseminated_Cancer'] = 2 x1.loc[x1['Currently_Receiving_Chemotherapy_for_Cancer'] == 'No', 'Currently_Receiving_Chemotherapy_for_Cancer'] = 0 x1.loc[x1['Currently_Receiving_Chemotherapy_for_Cancer'] == 'Yes', 'Currently_Receiving_Chemotherapy_for_Cancer'] = 1 x1.loc[x1['Currently_Receiving_Chemotherapy_for_Cancer'] == 'Unknown', 'Currently_Receiving_Chemotherapy_for_Cancer'] = 2 x1.loc[x1['Dementia'] == 'No', 'Dementia'] = 0 x1.loc[x1['Dementia'] == 'Yes', 'Dementia'] = 1 x1.loc[x1['Dementia'] == 'Unknown', 'Dementia'] = 2 x1.loc[x1['Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder'] == 'No', 'Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder'] = 0 x1.loc[x1['Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder'] == 'Yes', 'Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder'] = 1 x1.loc[x1['Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder'] == 'Unknown', 'Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder'] = 2 x1.loc[x1['Mental_or_Personality_Disorder'] == 'No', 'Mental_or_Personality_Disorder'] = 0 x1.loc[x1['Mental_or_Personality_Disorder'] == 'Yes', 'Mental_or_Personality_Disorder'] = 1 x1.loc[x1['Mental_or_Personality_Disorder'] == 'Unknown', 'Mental_or_Personality_Disorder'] = 2 x1.loc[x1['Ability_to_Complete_AgeAppropriate_ADL'] == 'No', 'Ability_to_Complete_AgeAppropriate_ADL'] = 0 x1.loc[x1['Ability_to_Complete_AgeAppropriate_ADL'] == 'Yes', 'Ability_to_Complete_AgeAppropriate_ADL'] = 1 x1.loc[x1['Ability_to_Complete_AgeAppropriate_ADL'] == 'Unknown', 'Ability_to_Complete_AgeAppropriate_ADL'] = 2 x1.loc[x1['Pregnancy'] == 'Not applicable (male patient)', 'Pregnancy'] = 0 x1.loc[x1['Pregnancy'] == 'No', 'Pregnancy'] = 1 x1.loc[x1['Pregnancy'] == 'Yes', 'Pregnancy'] = 2 x1.loc[x1['Pregnancy'] == 'Unkown', 'Pregnancy'] = 3 x1.loc[x1['Anticoagulant_Therapy'] == 'No', 'Anticoagulant_Therapy'] = 0 x1.loc[x1['Anticoagulant_Therapy'] == 'Yes', 'Anticoagulant_Therapy'] = 1 x1.loc[x1['Anticoagulant_Therapy'] == 'Unknown', 'Anticoagulant_Therapy'] = 2 x1.loc[x1['Steroid_Use'] == 'No', 'Steroid_Use'] = 0 x1.loc[x1['Steroid_Use'] == 'Yes', 'Steroid_Use'] = 1 x1.loc[x1['Steroid_Use'] == 'Unknown', 'Steroid_Use'] = 2 x1.loc[x1['Transport_Mode'] == 'Ground ambulance', 'Transport_Mode'] = 0 x1.loc[x1['Transport_Mode'] == 'Private/public vehicle/walk-in', 'Transport_Mode'] = 1 x1.loc[x1['Transport_Mode'] == 'Air ambulance', 'Transport_Mode'] = 2 x1.loc[x1['Transport_Mode'] == 'Other/unknown', 'Transport_Mode'] = 3 x1.loc[x1['InterFacility_Transfer'] == 'No', 'InterFacility_Transfer'] = 0 x1.loc[x1['InterFacility_Transfer'] == 'Yes', 'InterFacility_Transfer'] = 1 x1.loc[x1['InterFacility_Transfer'] == 'Unknown', 'InterFacility_Transfer'] = 2 x1.loc[x1['Trauma_Type'] == 'Blunt', 'Trauma_Type'] = 0 x1.loc[x1['Trauma_Type'] == 'Penetrating', 'Trauma_Type'] = 1 x1.loc[x1['Trauma_Type'] == 'Other/unknown', 'Trauma_Type'] = 2 x1.loc[x1['Injury_Intent'] == 'Unintentional', 'Injury_Intent'] = 0 x1.loc[x1['Injury_Intent'] == 'Assault', 'Injury_Intent'] = 1 x1.loc[x1['Injury_Intent'] == 'Other/unknown', 'Injury_Intent'] = 2 x1.loc[x1['Mechanism_of_Injury'] == 'Fall', 'Mechanism_of_Injury'] = 0 x1.loc[x1['Mechanism_of_Injury'] == 'MVT occupant', 'Mechanism_of_Injury'] = 1 x1.loc[x1['Mechanism_of_Injury'] == 'Struck by or against', 'Mechanism_of_Injury'] = 2 x1.loc[x1['Mechanism_of_Injury'] == 'Other MVT', 'Mechanism_of_Injury'] = 3 x1.loc[x1['Mechanism_of_Injury'] == 'MVT motorcyclist', 'Mechanism_of_Injury'] = 4 x1.loc[x1['Mechanism_of_Injury'] == 'Other transport', 'Mechanism_of_Injury'] = 5 x1.loc[x1['Mechanism_of_Injury'] == 'Other pedal cyclist', 'Mechanism_of_Injury'] = 6 x1.loc[x1['Mechanism_of_Injury'] == 'MVT pedestrian', 'Mechanism_of_Injury'] = 7 x1.loc[x1['Mechanism_of_Injury'] == 'Firearm', 'Mechanism_of_Injury'] = 8 x1.loc[x1['Mechanism_of_Injury'] == 'Other/unknown', 'Mechanism_of_Injury'] = 9 x1.loc[x1['Protective_Device'] == 'None', 'Protective_Device'] = 0 x1.loc[x1['Protective_Device'] == 'Belt', 'Protective_Device'] = 1 x1.loc[x1['Protective_Device'] == 'Airbag present', 'Protective_Device'] = 2 x1.loc[x1['Protective_Device'] == 'Helmet', 'Protective_Device'] = 3 x1.loc[x1['Protective_Device'] == 'Other/unknown', 'Protective_Device'] = 4 x1.loc[x1['WorkRelated'] == 'No/unknown', 'WorkRelated'] = 0 x1.loc[x1['WorkRelated'] == 'Yes', 'WorkRelated'] = 1 x1.loc[x1['Surgical_Intervention'] == 'No', 'Surgical_Intervention'] = 0 x1.loc[x1['Surgical_Intervention'] == 'Yes', 'Surgical_Intervention'] = 1 x1.loc[x1['Alcohol_Screen'] == 'No', 'Alcohol_Screen'] = 0 x1.loc[x1['Alcohol_Screen'] == 'Yes', 'Alcohol_Screen'] = 1 x1.loc[x1['Alcohol_Screen'] == 'Unknown', 'Alcohol_Screen'] = 2 x1.loc[x1['Drug_Screen__Amphetamine'] == 'No', 'Drug_Screen__Amphetamine'] = 0 x1.loc[x1['Drug_Screen__Amphetamine'] == 'Yes', 'Drug_Screen__Amphetamine'] = 1 x1.loc[x1['Drug_Screen__Amphetamine'] == 'Not tested', 'Drug_Screen__Amphetamine'] = 2 x1.loc[x1['Drug_Screen__Barbiturate'] == 'No', 'Drug_Screen__Barbiturate'] = 0 x1.loc[x1['Drug_Screen__Barbiturate'] == 'Yes', 'Drug_Screen__Barbiturate'] = 1 x1.loc[x1['Drug_Screen__Barbiturate'] == 'Not tested', 'Drug_Screen__Barbiturate'] = 2 x1.loc[x1['Drug_Screen__Benzodiazepines'] == 'No', 'Drug_Screen__Benzodiazepines'] = 0 x1.loc[x1['Drug_Screen__Benzodiazepines'] == 'Yes', 'Drug_Screen__Benzodiazepines'] = 1 x1.loc[x1['Drug_Screen__Benzodiazepines'] == 'Not tested', 'Drug_Screen__Benzodiazepines'] = 2 x1.loc[x1['Drug_Screen__Cannabinoid'] == 'No', 'Drug_Screen__Cannabinoid'] = 0 x1.loc[x1['Drug_Screen__Cannabinoid'] == 'Yes', 'Drug_Screen__Cannabinoid'] = 1 x1.loc[x1['Drug_Screen__Cannabinoid'] == 'Not tested', 'Drug_Screen__Cannabinoid'] = 2 x1.loc[x1['Drug_Screen__Cocaine'] == 'No', 'Drug_Screen__Cocaine'] = 0 x1.loc[x1['Drug_Screen__Cocaine'] == 'Yes', 'Drug_Screen__Cocaine'] = 1 x1.loc[x1['Drug_Screen__Cocaine'] == 'Not tested', 'Drug_Screen__Cocaine'] = 2 x1.loc[x1['Drug_Screen__MDMA_or_Ecstasy'] == 'No', 'Drug_Screen__MDMA_or_Ecstasy'] = 0 x1.loc[x1['Drug_Screen__MDMA_or_Ecstasy'] == 'Yes', 'Drug_Screen__MDMA_or_Ecstasy'] = 1 x1.loc[x1['Drug_Screen__MDMA_or_Ecstasy'] == 'Not tested', 'Drug_Screen__MDMA_or_Ecstasy'] = 2 x1.loc[x1['Drug_Screen__Methadone'] == 'No', 'Drug_Screen__Methadone'] = 0 x1.loc[x1['Drug_Screen__Methadone'] == 'Yes', 'Drug_Screen__Methadone'] = 1 x1.loc[x1['Drug_Screen__Methadone'] == 'Not tested', 'Drug_Screen__Methadone'] = 2 x1.loc[x1['Drug_Screen__Methamphetamine'] == 'No', 'Drug_Screen__Methamphetamine'] = 0 x1.loc[x1['Drug_Screen__Methamphetamine'] == 'Yes', 'Drug_Screen__Methamphetamine'] = 1 x1.loc[x1['Drug_Screen__Methamphetamine'] == 'Not tested', 'Drug_Screen__Methamphetamine'] = 2 x1.loc[x1['Drug_Screen__Opioid'] == 'No', 'Drug_Screen__Opioid'] = 0 x1.loc[x1['Drug_Screen__Opioid'] == 'Yes', 'Drug_Screen__Opioid'] = 1 x1.loc[x1['Drug_Screen__Opioid'] == 'Not tested', 'Drug_Screen__Opioid'] = 2 x1.loc[x1['Drug_Screen__Oxycodone'] == 'No', 'Drug_Screen__Oxycodone'] = 0 x1.loc[x1['Drug_Screen__Oxycodone'] == 'Yes', 'Drug_Screen__Oxycodone'] = 1 x1.loc[x1['Drug_Screen__Oxycodone'] == 'Not tested', 'Drug_Screen__Oxycodone'] = 2 x1.loc[x1['Drug_Screen__Phencyclidine'] == 'No', 'Drug_Screen__Phencyclidine'] = 0 x1.loc[x1['Drug_Screen__Phencyclidine'] == 'Yes', 'Drug_Screen__Phencyclidine'] = 1 x1.loc[x1['Drug_Screen__Phencyclidine'] == 'Not tested', 'Drug_Screen__Phencyclidine'] = 2 x1.loc[x1['Drug_Screen__Tricyclic_Antidepressant'] == 'No', 'Drug_Screen__Tricyclic_Antidepressant'] = 0 x1.loc[x1['Drug_Screen__Tricyclic_Antidepressant'] == 'Yes', 'Drug_Screen__Tricyclic_Antidepressant'] = 1 x1.loc[x1['Drug_Screen__Tricyclic_Antidepressant'] == 'Not tested', 'Drug_Screen__Tricyclic_Antidepressant'] = 2 x1.loc[x1['ACS_Verification_Level'] == 'Level I Trauma Center', 'ACS_Verification_Level'] = 0 x1.loc[x1['ACS_Verification_Level'] == 'Level II Trauma Center', 'ACS_Verification_Level'] = 1 x1.loc[x1['ACS_Verification_Level'] == 'Level III Trauma Center', 'ACS_Verification_Level'] = 2 x1.loc[x1['ACS_Verification_Level'] == 'Unknown', 'ACS_Verification_Level'] = 3 x1.loc[x1['Hospital_Type'] == 'Non-profit', 'Hospital_Type'] = 0 x1.loc[x1['Hospital_Type'] == 'For profit', 'Hospital_Type'] = 1 x1.loc[x1['Hospital_Type'] == 'Government', 'Hospital_Type'] = 2 x1.loc[x1['Hospital_Type'] == 'Unknown', 'Hospital_Type'] = 3 x1.loc[x1['Facility_Bed_Size'] == 'More than 600', 'Facility_Bed_Size'] = 0 x1.loc[x1['Facility_Bed_Size'] == '401 to 600', 'Facility_Bed_Size'] = 1 x1.loc[x1['Facility_Bed_Size'] == '201 to 400', 'Facility_Bed_Size'] = 2 x1.loc[x1['Facility_Bed_Size'] == '200 or fewer', 'Facility_Bed_Size'] = 3 x1.loc[x1['Primary_Method_of_Payment'] == 'Medicare', 'Primary_Method_of_Payment'] = 0 x1.loc[x1['Primary_Method_of_Payment'] == 'Private/commercial insurance', 'Primary_Method_of_Payment'] = 1 x1.loc[x1['Primary_Method_of_Payment'] == 'Medicaid', 'Primary_Method_of_Payment'] = 2 x1.loc[x1['Primary_Method_of_Payment'] == 'Self-pay', 'Primary_Method_of_Payment'] = 3 x1.loc[x1['Primary_Method_of_Payment'] == 'Other/unknown', 'Primary_Method_of_Payment'] = 4 #Prepare validation data for the outcome 1 (mortality). y1_valid = x1_valid.pop('OUTCOME') x1_valid.loc[x1_valid['Sex'] == 'Male', 'Sex'] = 0 x1_valid.loc[x1_valid['Sex'] == 'Female', 'Sex'] = 1 x1_valid.loc[x1_valid['Sex'] == 'Non-Binary', 'Sex'] = 2 x1_valid.loc[x1_valid['Sex'] == 'Unknown', 'Sex'] = 3 x1_valid.loc[x1_valid['Race'] == 'White', 'Race'] = 0 x1_valid.loc[x1_valid['Race'] == 'Black', 'Race'] = 1 x1_valid.loc[x1_valid['Race'] == 'Asian', 'Race'] = 2 x1_valid.loc[x1_valid['Race'] == 'Other/unknown', 'Race'] = 5 x1_valid.loc[x1_valid['Ethnicity'] == 'Not Hispanic or Latino', 'Ethnicity'] = 0 x1_valid.loc[x1_valid['Ethnicity'] == 'Hispanic or Latino', 'Ethnicity'] = 1 x1_valid.loc[x1_valid['Ethnicity'] == 'Unknown', 'Ethnicity'] = 2 x1_valid.loc[x1_valid['Supplemental_Oxygen'] == 'No supplemental oxygen', 'Supplemental_Oxygen'] = 0 x1_valid.loc[x1_valid['Supplemental_Oxygen'] == 'Supplemental oxygen', 'Supplemental_Oxygen'] = 1 x1_valid.loc[x1_valid['Supplemental_Oxygen'] == 'Unknown', 'Supplemental_Oxygen'] = 2 x1_valid.loc[x1_valid['Respiratory_Assistance'] == 'Unassisted respiratory rate', 'Respiratory_Assistance'] = 0 x1_valid.loc[x1_valid['Respiratory_Assistance'] == 'Assisted respiratory rate', 'Respiratory_Assistance'] = 1 x1_valid.loc[x1_valid['Respiratory_Assistance'] == 'Unknown', 'Respiratory_Assistance'] = 2 x1_valid.loc[x1_valid['Fracture_of_C1_Vertebra'] == 'No', 'Fracture_of_C1_Vertebra'] = 0 x1_valid.loc[x1_valid['Fracture_of_C1_Vertebra'] == 'Yes', 'Fracture_of_C1_Vertebra'] = 1 x1_valid.loc[x1_valid['Fracture_of_C2_Vertebra'] == 'No', 'Fracture_of_C2_Vertebra'] = 0 x1_valid.loc[x1_valid['Fracture_of_C2_Vertebra'] == 'Yes', 'Fracture_of_C2_Vertebra'] = 1 x1_valid.loc[x1_valid['Fracture_of_C3_Vertebra'] == 'No', 'Fracture_of_C3_Vertebra'] = 0 x1_valid.loc[x1_valid['Fracture_of_C3_Vertebra'] == 'Yes', 'Fracture_of_C3_Vertebra'] = 1 x1_valid.loc[x1_valid['Fracture_of_C4_Vertebra'] == 'No', 'Fracture_of_C4_Vertebra'] = 0 x1_valid.loc[x1_valid['Fracture_of_C4_Vertebra'] == 'Yes', 'Fracture_of_C4_Vertebra'] = 1 x1_valid.loc[x1_valid['Fracture_of_C5_Vertebra'] == 'No', 'Fracture_of_C5_Vertebra'] = 0 x1_valid.loc[x1_valid['Fracture_of_C5_Vertebra'] == 'Yes', 'Fracture_of_C5_Vertebra'] = 1 x1_valid.loc[x1_valid['Fracture_of_C6_Vertebra'] == 'No', 'Fracture_of_C6_Vertebra'] = 0 x1_valid.loc[x1_valid['Fracture_of_C6_Vertebra'] == 'Yes', 'Fracture_of_C6_Vertebra'] = 1 x1_valid.loc[x1_valid['Fracture_of_C7_Vertebra'] == 'No', 'Fracture_of_C7_Vertebra'] = 0 x1_valid.loc[x1_valid['Fracture_of_C7_Vertebra'] == 'Yes', 'Fracture_of_C7_Vertebra'] = 1 x1_valid.loc[x1_valid['Rupture_of_Cervical_Intervertebral_Disc'] == 'No', 'Rupture_of_Cervical_Intervertebral_Disc'] = 0 x1_valid.loc[x1_valid['Rupture_of_Cervical_Intervertebral_Disc'] == 'Yes', 'Rupture_of_Cervical_Intervertebral_Disc'] = 1 x1_valid.loc[x1_valid['Subluxation_and_Dislocation_of_C0/C1_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C0/C1_Vertebrae'] = 0 x1_valid.loc[x1_valid['Subluxation_and_Dislocation_of_C0/C1_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C0/C1_Vertebrae'] = 1 x1_valid.loc[x1_valid['Subluxation_and_Dislocation_of_C1/C2_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C1/C2_Vertebrae'] = 0 x1_valid.loc[x1_valid['Subluxation_and_Dislocation_of_C1/C2_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C1/C2_Vertebrae'] = 1 x1_valid.loc[x1_valid['Subluxation_and_Dislocation_of_C2/C3_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C2/C3_Vertebrae'] = 0 x1_valid.loc[x1_valid['Subluxation_and_Dislocation_of_C2/C3_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C2/C3_Vertebrae'] = 1 x1_valid.loc[x1_valid['Subluxation_and_Dislocation_of_C3/C4_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C3/C4_Vertebrae'] = 0 x1_valid.loc[x1_valid['Subluxation_and_Dislocation_of_C3/C4_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C3/C4_Vertebrae'] = 1 x1_valid.loc[x1_valid['Subluxation_and_Dislocation_of_C4/C5_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C4/C5_Vertebrae'] = 0 x1_valid.loc[x1_valid['Subluxation_and_Dislocation_of_C4/C5_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C4/C5_Vertebrae'] = 1 x1_valid.loc[x1_valid['Subluxation_and_Dislocation_of_C5/C6_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C5/C6_Vertebrae'] = 0 x1_valid.loc[x1_valid['Subluxation_and_Dislocation_of_C5/C6_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C5/C6_Vertebrae'] = 1 x1_valid.loc[x1_valid['Subluxation_and_Dislocation_of_C6/C7_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C6/C7_Vertebrae'] = 0 x1_valid.loc[x1_valid['Subluxation_and_Dislocation_of_C6/C7_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C6/C7_Vertebrae'] = 1 x1_valid.loc[x1_valid['Subluxation_and_Dislocation_of_C7/T1_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C7/T1_Vertebrae'] = 0 x1_valid.loc[x1_valid['Subluxation_and_Dislocation_of_C7/T1_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C7/T1_Vertebrae'] = 1 x1_valid.loc[x1_valid['Concussion_and_Edema_of_cSC'] == 'No', 'Concussion_and_Edema_of_cSC'] = 0 x1_valid.loc[x1_valid['Concussion_and_Edema_of_cSC'] == 'Yes', 'Concussion_and_Edema_of_cSC'] = 1 x1_valid.loc[x1_valid['Complete_Lesion_of_cSC'] == 'No', 'Complete_Lesion_of_cSC'] = 0 x1_valid.loc[x1_valid['Complete_Lesion_of_cSC'] == 'Yes', 'Complete_Lesion_of_cSC'] = 1 x1_valid.loc[x1_valid['Anterior_Cord_Syndrome_of_cSC'] == 'No', 'Anterior_Cord_Syndrome_of_cSC'] = 0 x1_valid.loc[x1_valid['Anterior_Cord_Syndrome_of_cSC'] == 'Yes', 'Anterior_Cord_Syndrome_of_cSC'] = 1 x1_valid.loc[x1_valid['BrownSequard_Syndrome_of_cSC'] == 'No', 'BrownSequard_Syndrome_of_cSC'] = 0 x1_valid.loc[x1_valid['BrownSequard_Syndrome_of_cSC'] == 'Yes', 'BrownSequard_Syndrome_of_cSC'] = 1 x1_valid.loc[x1_valid['Other_Incomplete_Lesions_of_cSC'] == 'No', 'Other_Incomplete_Lesions_of_cSC'] = 0 x1_valid.loc[x1_valid['Other_Incomplete_Lesions_of_cSC'] == 'Yes', 'Other_Incomplete_Lesions_of_cSC'] = 1 x1_valid.loc[x1_valid['Current_Smoker'] == 'No', 'Current_Smoker'] = 0 x1_valid.loc[x1_valid['Current_Smoker'] == 'Yes', 'Current_Smoker'] = 1 x1_valid.loc[x1_valid['Current_Smoker'] == 'Unknown', 'Current_Smoker'] = 2 x1_valid.loc[x1_valid['Alcohol_Use_Disorder'] == 'No', 'Alcohol_Use_Disorder'] = 0 x1_valid.loc[x1_valid['Alcohol_Use_Disorder'] == 'Yes', 'Alcohol_Use_Disorder'] = 1 x1_valid.loc[x1_valid['Alcohol_Use_Disorder'] == 'Unknown', 'Alcohol_Use_Disorder'] = 2 x1_valid.loc[x1_valid['Substance_Abuse_Disorder'] == 'No', 'Substance_Abuse_Disorder'] = 0 x1_valid.loc[x1_valid['Substance_Abuse_Disorder'] == 'Yes', 'Substance_Abuse_Disorder'] = 1 x1_valid.loc[x1_valid['Substance_Abuse_Disorder'] == 'Unknown', 'Substance_Abuse_Disorder'] = 2 x1_valid.loc[x1_valid['Diabetes_Mellitus'] == 'No', 'Diabetes_Mellitus'] = 0 x1_valid.loc[x1_valid['Diabetes_Mellitus'] == 'Yes', 'Diabetes_Mellitus'] = 1 x1_valid.loc[x1_valid['Diabetes_Mellitus'] == 'Unknown', 'Diabetes_Mellitus'] = 2 x1_valid.loc[x1_valid['Hypertension'] == 'No', 'Hypertension'] = 0 x1_valid.loc[x1_valid['Hypertension'] == 'Yes', 'Hypertension'] = 1 x1_valid.loc[x1_valid['Hypertension'] == 'Unknown', 'Hypertension'] = 2 x1_valid.loc[x1_valid['Congestive_Heart_Failure'] == 'No', 'Congestive_Heart_Failure'] = 0 x1_valid.loc[x1_valid['Congestive_Heart_Failure'] == 'Yes', 'Congestive_Heart_Failure'] = 1 x1_valid.loc[x1_valid['Congestive_Heart_Failure'] == 'Unknown', 'Congestive_Heart_Failure'] = 2 x1_valid.loc[x1_valid['History_of_Myocardial_Infarction'] == 'No', 'History_of_Myocardial_Infarction'] = 0 x1_valid.loc[x1_valid['History_of_Myocardial_Infarction'] == 'Yes', 'History_of_Myocardial_Infarction'] = 1 x1_valid.loc[x1_valid['History_of_Myocardial_Infarction'] == 'Unknown', 'History_of_Myocardial_Infarction'] = 2 x1_valid.loc[x1_valid['Angina_Pectoris'] == 'No', 'Angina_Pectoris'] = 0 x1_valid.loc[x1_valid['Angina_Pectoris'] == 'Yes', 'Angina_Pectoris'] = 1 x1_valid.loc[x1_valid['Angina_Pectoris'] == 'Unknown', 'Angina_Pectoris'] = 2 x1_valid.loc[x1_valid['History_of_Cerebrovascular_Accident'] == 'No', 'History_of_Cerebrovascular_Accident'] = 0 x1_valid.loc[x1_valid['History_of_Cerebrovascular_Accident'] == 'Yes', 'History_of_Cerebrovascular_Accident'] = 1 x1_valid.loc[x1_valid['History_of_Cerebrovascular_Accident'] == 'Unknown', 'History_of_Cerebrovascular_Accident'] = 2 x1_valid.loc[x1_valid['Peripheral_Arterial_Disease'] == 'No', 'Peripheral_Arterial_Disease'] = 0 x1_valid.loc[x1_valid['Peripheral_Arterial_Disease'] == 'Yes', 'Peripheral_Arterial_Disease'] = 1 x1_valid.loc[x1_valid['Peripheral_Arterial_Disease'] == 'Unknown', 'Peripheral_Arterial_Disease'] = 2 x1_valid.loc[x1_valid['Chronic_Obstructive_Pulmonary_Disease'] == 'No', 'Chronic_Obstructive_Pulmonary_Disease'] = 0 x1_valid.loc[x1_valid['Chronic_Obstructive_Pulmonary_Disease'] == 'Yes', 'Chronic_Obstructive_Pulmonary_Disease'] = 1 x1_valid.loc[x1_valid['Chronic_Obstructive_Pulmonary_Disease'] == 'Unknown', 'Chronic_Obstructive_Pulmonary_Disease'] = 2 x1_valid.loc[x1_valid['Chronic_Renal_Failure'] == 'No', 'Chronic_Renal_Failure'] = 0 x1_valid.loc[x1_valid['Chronic_Renal_Failure'] == 'Yes', 'Chronic_Renal_Failure'] = 1 x1_valid.loc[x1_valid['Chronic_Renal_Failure'] == 'Unknown', 'Chronic_Renal_Failure'] = 2 x1_valid.loc[x1_valid['Cirrhosis'] == 'No', 'Cirrhosis'] = 0 x1_valid.loc[x1_valid['Cirrhosis'] == 'Yes', 'Cirrhosis'] = 1 x1_valid.loc[x1_valid['Cirrhosis'] == 'Unknown', 'Cirrhosis'] = 2 x1_valid.loc[x1_valid['Bleeding_Disorder'] == 'No', 'Bleeding_Disorder'] = 0 x1_valid.loc[x1_valid['Bleeding_Disorder'] == 'Yes', 'Bleeding_Disorder'] = 1 x1_valid.loc[x1_valid['Bleeding_Disorder'] == 'Unknown', 'Bleeding_Disorder'] = 2 x1_valid.loc[x1_valid['Disseminated_Cancer'] == 'No', 'Disseminated_Cancer'] = 0 x1_valid.loc[x1_valid['Disseminated_Cancer'] == 'Yes', 'Disseminated_Cancer'] = 1 x1_valid.loc[x1_valid['Disseminated_Cancer'] == 'Unknown', 'Disseminated_Cancer'] = 2 x1_valid.loc[x1_valid['Currently_Receiving_Chemotherapy_for_Cancer'] == 'No', 'Currently_Receiving_Chemotherapy_for_Cancer'] = 0 x1_valid.loc[x1_valid['Currently_Receiving_Chemotherapy_for_Cancer'] == 'Yes', 'Currently_Receiving_Chemotherapy_for_Cancer'] = 1 x1_valid.loc[x1_valid['Currently_Receiving_Chemotherapy_for_Cancer'] == 'Unknown', 'Currently_Receiving_Chemotherapy_for_Cancer'] = 2 x1_valid.loc[x1_valid['Dementia'] == 'No', 'Dementia'] = 0 x1_valid.loc[x1_valid['Dementia'] == 'Yes', 'Dementia'] = 1 x1_valid.loc[x1_valid['Dementia'] == 'Unknown', 'Dementia'] = 2 x1_valid.loc[x1_valid['Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder'] == 'No', 'Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder'] = 0 x1_valid.loc[x1_valid['Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder'] == 'Yes', 'Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder'] = 1 x1_valid.loc[x1_valid['Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder'] == 'Unknown', 'Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder'] = 2 x1_valid.loc[x1_valid['Mental_or_Personality_Disorder'] == 'No', 'Mental_or_Personality_Disorder'] = 0 x1_valid.loc[x1_valid['Mental_or_Personality_Disorder'] == 'Yes', 'Mental_or_Personality_Disorder'] = 1 x1_valid.loc[x1_valid['Mental_or_Personality_Disorder'] == 'Unknown', 'Mental_or_Personality_Disorder'] = 2 x1_valid.loc[x1_valid['Ability_to_Complete_AgeAppropriate_ADL'] == 'No', 'Ability_to_Complete_AgeAppropriate_ADL'] = 0 x1_valid.loc[x1_valid['Ability_to_Complete_AgeAppropriate_ADL'] == 'Yes', 'Ability_to_Complete_AgeAppropriate_ADL'] = 1 x1_valid.loc[x1_valid['Ability_to_Complete_AgeAppropriate_ADL'] == 'Unknown', 'Ability_to_Complete_AgeAppropriate_ADL'] = 2 x1_valid.loc[x1_valid['Pregnancy'] == 'Not applicable (male patient)', 'Pregnancy'] = 0 x1_valid.loc[x1_valid['Pregnancy'] == 'No', 'Pregnancy'] = 1 x1_valid.loc[x1_valid['Pregnancy'] == 'Yes', 'Pregnancy'] = 2 x1_valid.loc[x1_valid['Pregnancy'] == 'Unkown', 'Pregnancy'] = 3 x1_valid.loc[x1_valid['Anticoagulant_Therapy'] == 'No', 'Anticoagulant_Therapy'] = 0 x1_valid.loc[x1_valid['Anticoagulant_Therapy'] == 'Yes', 'Anticoagulant_Therapy'] = 1 x1_valid.loc[x1_valid['Anticoagulant_Therapy'] == 'Unknown', 'Anticoagulant_Therapy'] = 2 x1_valid.loc[x1_valid['Steroid_Use'] == 'No', 'Steroid_Use'] = 0 x1_valid.loc[x1_valid['Steroid_Use'] == 'Yes', 'Steroid_Use'] = 1 x1_valid.loc[x1_valid['Steroid_Use'] == 'Unknown', 'Steroid_Use'] = 2 x1_valid.loc[x1_valid['Transport_Mode'] == 'Ground ambulance', 'Transport_Mode'] = 0 x1_valid.loc[x1_valid['Transport_Mode'] == 'Private/public vehicle/walk-in', 'Transport_Mode'] = 1 x1_valid.loc[x1_valid['Transport_Mode'] == 'Air ambulance', 'Transport_Mode'] = 2 x1_valid.loc[x1_valid['Transport_Mode'] == 'Other/unknown', 'Transport_Mode'] = 3 x1_valid.loc[x1_valid['InterFacility_Transfer'] == 'No', 'InterFacility_Transfer'] = 0 x1_valid.loc[x1_valid['InterFacility_Transfer'] == 'Yes', 'InterFacility_Transfer'] = 1 x1_valid.loc[x1_valid['InterFacility_Transfer'] == 'Unknown', 'InterFacility_Transfer'] = 2 x1_valid.loc[x1_valid['Trauma_Type'] == 'Blunt', 'Trauma_Type'] = 0 x1_valid.loc[x1_valid['Trauma_Type'] == 'Penetrating', 'Trauma_Type'] = 1 x1_valid.loc[x1_valid['Trauma_Type'] == 'Other/unknown', 'Trauma_Type'] = 2 x1_valid.loc[x1_valid['Injury_Intent'] == 'Unintentional', 'Injury_Intent'] = 0 x1_valid.loc[x1_valid['Injury_Intent'] == 'Assault', 'Injury_Intent'] = 1 x1_valid.loc[x1_valid['Injury_Intent'] == 'Other/unknown', 'Injury_Intent'] = 2 x1_valid.loc[x1_valid['Mechanism_of_Injury'] == 'Fall', 'Mechanism_of_Injury'] = 0 x1_valid.loc[x1_valid['Mechanism_of_Injury'] == 'MVT occupant', 'Mechanism_of_Injury'] = 1 x1_valid.loc[x1_valid['Mechanism_of_Injury'] == 'Struck by or against', 'Mechanism_of_Injury'] = 2 x1_valid.loc[x1_valid['Mechanism_of_Injury'] == 'Other MVT', 'Mechanism_of_Injury'] = 3 x1_valid.loc[x1_valid['Mechanism_of_Injury'] == 'MVT motorcyclist', 'Mechanism_of_Injury'] = 4 x1_valid.loc[x1_valid['Mechanism_of_Injury'] == 'Other transport', 'Mechanism_of_Injury'] = 5 x1_valid.loc[x1_valid['Mechanism_of_Injury'] == 'Other pedal cyclist', 'Mechanism_of_Injury'] = 6 x1_valid.loc[x1_valid['Mechanism_of_Injury'] == 'MVT pedestrian', 'Mechanism_of_Injury'] = 7 x1_valid.loc[x1_valid['Mechanism_of_Injury'] == 'Firearm', 'Mechanism_of_Injury'] = 8 x1_valid.loc[x1_valid['Mechanism_of_Injury'] == 'Other/unknown', 'Mechanism_of_Injury'] = 9 x1_valid.loc[x1_valid['Protective_Device'] == 'None', 'Protective_Device'] = 0 x1_valid.loc[x1_valid['Protective_Device'] == 'Belt', 'Protective_Device'] = 1 x1_valid.loc[x1_valid['Protective_Device'] == 'Airbag present', 'Protective_Device'] = 2 x1_valid.loc[x1_valid['Protective_Device'] == 'Helmet', 'Protective_Device'] = 3 x1_valid.loc[x1_valid['Protective_Device'] == 'Other/unknown', 'Protective_Device'] = 4 x1_valid.loc[x1_valid['WorkRelated'] == 'No/unknown', 'WorkRelated'] = 0 x1_valid.loc[x1_valid['WorkRelated'] == 'Yes', 'WorkRelated'] = 1 x1_valid.loc[x1_valid['Surgical_Intervention'] == 'No', 'Surgical_Intervention'] = 0 x1_valid.loc[x1_valid['Surgical_Intervention'] == 'Yes', 'Surgical_Intervention'] = 1 x1_valid.loc[x1_valid['Alcohol_Screen'] == 'No', 'Alcohol_Screen'] = 0 x1_valid.loc[x1_valid['Alcohol_Screen'] == 'Yes', 'Alcohol_Screen'] = 1 x1_valid.loc[x1_valid['Alcohol_Screen'] == 'Unknown', 'Alcohol_Screen'] = 2 x1_valid.loc[x1_valid['Drug_Screen__Amphetamine'] == 'No', 'Drug_Screen__Amphetamine'] = 0 x1_valid.loc[x1_valid['Drug_Screen__Amphetamine'] == 'Yes', 'Drug_Screen__Amphetamine'] = 1 x1_valid.loc[x1_valid['Drug_Screen__Amphetamine'] == 'Not tested', 'Drug_Screen__Amphetamine'] = 2 x1_valid.loc[x1_valid['Drug_Screen__Barbiturate'] == 'No', 'Drug_Screen__Barbiturate'] = 0 x1_valid.loc[x1_valid['Drug_Screen__Barbiturate'] == 'Yes', 'Drug_Screen__Barbiturate'] = 1 x1_valid.loc[x1_valid['Drug_Screen__Barbiturate'] == 'Not tested', 'Drug_Screen__Barbiturate'] = 2 x1_valid.loc[x1_valid['Drug_Screen__Benzodiazepines'] == 'No', 'Drug_Screen__Benzodiazepines'] = 0 x1_valid.loc[x1_valid['Drug_Screen__Benzodiazepines'] == 'Yes', 'Drug_Screen__Benzodiazepines'] = 1 x1_valid.loc[x1_valid['Drug_Screen__Benzodiazepines'] == 'Not tested', 'Drug_Screen__Benzodiazepines'] = 2 x1_valid.loc[x1_valid['Drug_Screen__Cannabinoid'] == 'No', 'Drug_Screen__Cannabinoid'] = 0 x1_valid.loc[x1_valid['Drug_Screen__Cannabinoid'] == 'Yes', 'Drug_Screen__Cannabinoid'] = 1 x1_valid.loc[x1_valid['Drug_Screen__Cannabinoid'] == 'Not tested', 'Drug_Screen__Cannabinoid'] = 2 x1_valid.loc[x1_valid['Drug_Screen__Cocaine'] == 'No', 'Drug_Screen__Cocaine'] = 0 x1_valid.loc[x1_valid['Drug_Screen__Cocaine'] == 'Yes', 'Drug_Screen__Cocaine'] = 1 x1_valid.loc[x1_valid['Drug_Screen__Cocaine'] == 'Not tested', 'Drug_Screen__Cocaine'] = 2 x1_valid.loc[x1_valid['Drug_Screen__MDMA_or_Ecstasy'] == 'No', 'Drug_Screen__MDMA_or_Ecstasy'] = 0 x1_valid.loc[x1_valid['Drug_Screen__MDMA_or_Ecstasy'] == 'Yes', 'Drug_Screen__MDMA_or_Ecstasy'] = 1 x1_valid.loc[x1_valid['Drug_Screen__MDMA_or_Ecstasy'] == 'Not tested', 'Drug_Screen__MDMA_or_Ecstasy'] = 2 x1_valid.loc[x1_valid['Drug_Screen__Methadone'] == 'No', 'Drug_Screen__Methadone'] = 0 x1_valid.loc[x1_valid['Drug_Screen__Methadone'] == 'Yes', 'Drug_Screen__Methadone'] = 1 x1_valid.loc[x1_valid['Drug_Screen__Methadone'] == 'Not tested', 'Drug_Screen__Methadone'] = 2 x1_valid.loc[x1_valid['Drug_Screen__Methamphetamine'] == 'No', 'Drug_Screen__Methamphetamine'] = 0 x1_valid.loc[x1_valid['Drug_Screen__Methamphetamine'] == 'Yes', 'Drug_Screen__Methamphetamine'] = 1 x1_valid.loc[x1_valid['Drug_Screen__Methamphetamine'] == 'Not tested', 'Drug_Screen__Methamphetamine'] = 2 x1_valid.loc[x1_valid['Drug_Screen__Opioid'] == 'No', 'Drug_Screen__Opioid'] = 0 x1_valid.loc[x1_valid['Drug_Screen__Opioid'] == 'Yes', 'Drug_Screen__Opioid'] = 1 x1_valid.loc[x1_valid['Drug_Screen__Opioid'] == 'Not tested', 'Drug_Screen__Opioid'] = 2 x1_valid.loc[x1_valid['Drug_Screen__Oxycodone'] == 'No', 'Drug_Screen__Oxycodone'] = 0 x1_valid.loc[x1_valid['Drug_Screen__Oxycodone'] == 'Yes', 'Drug_Screen__Oxycodone'] = 1 x1_valid.loc[x1_valid['Drug_Screen__Oxycodone'] == 'Not tested', 'Drug_Screen__Oxycodone'] = 2 x1_valid.loc[x1_valid['Drug_Screen__Phencyclidine'] == 'No', 'Drug_Screen__Phencyclidine'] = 0 x1_valid.loc[x1_valid['Drug_Screen__Phencyclidine'] == 'Yes', 'Drug_Screen__Phencyclidine'] = 1 x1_valid.loc[x1_valid['Drug_Screen__Phencyclidine'] == 'Not tested', 'Drug_Screen__Phencyclidine'] = 2 x1_valid.loc[x1_valid['Drug_Screen__Tricyclic_Antidepressant'] == 'No', 'Drug_Screen__Tricyclic_Antidepressant'] = 0 x1_valid.loc[x1_valid['Drug_Screen__Tricyclic_Antidepressant'] == 'Yes', 'Drug_Screen__Tricyclic_Antidepressant'] = 1 x1_valid.loc[x1_valid['Drug_Screen__Tricyclic_Antidepressant'] == 'Not tested', 'Drug_Screen__Tricyclic_Antidepressant'] = 2 x1_valid.loc[x1_valid['ACS_Verification_Level'] == 'Level I Trauma Center', 'ACS_Verification_Level'] = 0 x1_valid.loc[x1_valid['ACS_Verification_Level'] == 'Level II Trauma Center', 'ACS_Verification_Level'] = 1 x1_valid.loc[x1_valid['ACS_Verification_Level'] == 'Level III Trauma Center', 'ACS_Verification_Level'] = 2 x1_valid.loc[x1_valid['ACS_Verification_Level'] == 'Unknown', 'ACS_Verification_Level'] = 3 x1_valid.loc[x1_valid['Hospital_Type'] == 'Non-profit', 'Hospital_Type'] = 0 x1_valid.loc[x1_valid['Hospital_Type'] == 'For profit', 'Hospital_Type'] = 1 x1_valid.loc[x1_valid['Hospital_Type'] == 'Government', 'Hospital_Type'] = 2 x1_valid.loc[x1_valid['Hospital_Type'] == 'Unknown', 'Hospital_Type'] = 3 x1_valid.loc[x1_valid['Facility_Bed_Size'] == 'More than 600', 'Facility_Bed_Size'] = 0 x1_valid.loc[x1_valid['Facility_Bed_Size'] == '401 to 600', 'Facility_Bed_Size'] = 1 x1_valid.loc[x1_valid['Facility_Bed_Size'] == '201 to 400', 'Facility_Bed_Size'] = 2 x1_valid.loc[x1_valid['Facility_Bed_Size'] == '200 or fewer', 'Facility_Bed_Size'] = 3 x1_valid.loc[x1_valid['Primary_Method_of_Payment'] == 'Medicare', 'Primary_Method_of_Payment'] = 0 x1_valid.loc[x1_valid['Primary_Method_of_Payment'] == 'Private/commercial insurance', 'Primary_Method_of_Payment'] = 1 x1_valid.loc[x1_valid['Primary_Method_of_Payment'] == 'Medicaid', 'Primary_Method_of_Payment'] = 2 x1_valid.loc[x1_valid['Primary_Method_of_Payment'] == 'Self-pay', 'Primary_Method_of_Payment'] = 3 x1_valid.loc[x1_valid['Primary_Method_of_Payment'] == 'Other/unknown', 'Primary_Method_of_Payment'] = 4 #Prepare training data for the outcome 2 (discharge). y2 = x2.pop('OUTCOME') x2.loc[x2['Sex'] == 'Male', 'Sex'] = 0 x2.loc[x2['Sex'] == 'Female', 'Sex'] = 1 x2.loc[x2['Sex'] == 'Non-Binary', 'Sex'] = 2 x2.loc[x2['Sex'] == 'Unknown', 'Sex'] = 3 x2.loc[x2['Race'] == 'White', 'Race'] = 0 x2.loc[x2['Race'] == 'Black', 'Race'] = 1 x2.loc[x2['Race'] == 'Asian', 'Race'] = 2 x2.loc[x2['Race'] == 'Other/unknown', 'Race'] = 5 x2.loc[x2['Ethnicity'] == 'Not Hispanic or Latino', 'Ethnicity'] = 0 x2.loc[x2['Ethnicity'] == 'Hispanic or Latino', 'Ethnicity'] = 1 x2.loc[x2['Ethnicity'] == 'Unknown', 'Ethnicity'] = 2 x2.loc[x2['Supplemental_Oxygen'] == 'No supplemental oxygen', 'Supplemental_Oxygen'] = 0 x2.loc[x2['Supplemental_Oxygen'] == 'Supplemental oxygen', 'Supplemental_Oxygen'] = 1 x2.loc[x2['Supplemental_Oxygen'] == 'Unknown', 'Supplemental_Oxygen'] = 2 x2.loc[x2['Respiratory_Assistance'] == 'Unassisted respiratory rate', 'Respiratory_Assistance'] = 0 x2.loc[x2['Respiratory_Assistance'] == 'Assisted respiratory rate', 'Respiratory_Assistance'] = 1 x2.loc[x2['Respiratory_Assistance'] == 'Unknown', 'Respiratory_Assistance'] = 2 x2.loc[x2['Fracture_of_C1_Vertebra'] == 'No', 'Fracture_of_C1_Vertebra'] = 0 x2.loc[x2['Fracture_of_C1_Vertebra'] == 'Yes', 'Fracture_of_C1_Vertebra'] = 1 x2.loc[x2['Fracture_of_C2_Vertebra'] == 'No', 'Fracture_of_C2_Vertebra'] = 0 x2.loc[x2['Fracture_of_C2_Vertebra'] == 'Yes', 'Fracture_of_C2_Vertebra'] = 1 x2.loc[x2['Fracture_of_C3_Vertebra'] == 'No', 'Fracture_of_C3_Vertebra'] = 0 x2.loc[x2['Fracture_of_C3_Vertebra'] == 'Yes', 'Fracture_of_C3_Vertebra'] = 1 x2.loc[x2['Fracture_of_C4_Vertebra'] == 'No', 'Fracture_of_C4_Vertebra'] = 0 x2.loc[x2['Fracture_of_C4_Vertebra'] == 'Yes', 'Fracture_of_C4_Vertebra'] = 1 x2.loc[x2['Fracture_of_C5_Vertebra'] == 'No', 'Fracture_of_C5_Vertebra'] = 0 x2.loc[x2['Fracture_of_C5_Vertebra'] == 'Yes', 'Fracture_of_C5_Vertebra'] = 1 x2.loc[x2['Fracture_of_C6_Vertebra'] == 'No', 'Fracture_of_C6_Vertebra'] = 0 x2.loc[x2['Fracture_of_C6_Vertebra'] == 'Yes', 'Fracture_of_C6_Vertebra'] = 1 x2.loc[x2['Fracture_of_C7_Vertebra'] == 'No', 'Fracture_of_C7_Vertebra'] = 0 x2.loc[x2['Fracture_of_C7_Vertebra'] == 'Yes', 'Fracture_of_C7_Vertebra'] = 1 x2.loc[x2['Rupture_of_Cervical_Intervertebral_Disc'] == 'No', 'Rupture_of_Cervical_Intervertebral_Disc'] = 0 x2.loc[x2['Rupture_of_Cervical_Intervertebral_Disc'] == 'Yes', 'Rupture_of_Cervical_Intervertebral_Disc'] = 1 x2.loc[x2['Subluxation_and_Dislocation_of_C0/C1_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C0/C1_Vertebrae'] = 0 x2.loc[x2['Subluxation_and_Dislocation_of_C0/C1_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C0/C1_Vertebrae'] = 1 x2.loc[x2['Subluxation_and_Dislocation_of_C1/C2_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C1/C2_Vertebrae'] = 0 x2.loc[x2['Subluxation_and_Dislocation_of_C1/C2_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C1/C2_Vertebrae'] = 1 x2.loc[x2['Subluxation_and_Dislocation_of_C2/C3_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C2/C3_Vertebrae'] = 0 x2.loc[x2['Subluxation_and_Dislocation_of_C2/C3_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C2/C3_Vertebrae'] = 1 x2.loc[x2['Subluxation_and_Dislocation_of_C3/C4_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C3/C4_Vertebrae'] = 0 x2.loc[x2['Subluxation_and_Dislocation_of_C3/C4_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C3/C4_Vertebrae'] = 1 x2.loc[x2['Subluxation_and_Dislocation_of_C4/C5_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C4/C5_Vertebrae'] = 0 x2.loc[x2['Subluxation_and_Dislocation_of_C4/C5_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C4/C5_Vertebrae'] = 1 x2.loc[x2['Subluxation_and_Dislocation_of_C5/C6_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C5/C6_Vertebrae'] = 0 x2.loc[x2['Subluxation_and_Dislocation_of_C5/C6_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C5/C6_Vertebrae'] = 1 x2.loc[x2['Subluxation_and_Dislocation_of_C6/C7_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C6/C7_Vertebrae'] = 0 x2.loc[x2['Subluxation_and_Dislocation_of_C6/C7_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C6/C7_Vertebrae'] = 1 x2.loc[x2['Subluxation_and_Dislocation_of_C7/T1_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C7/T1_Vertebrae'] = 0 x2.loc[x2['Subluxation_and_Dislocation_of_C7/T1_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C7/T1_Vertebrae'] = 1 x2.loc[x2['Concussion_and_Edema_of_cSC'] == 'No', 'Concussion_and_Edema_of_cSC'] = 0 x2.loc[x2['Concussion_and_Edema_of_cSC'] == 'Yes', 'Concussion_and_Edema_of_cSC'] = 1 x2.loc[x2['Complete_Lesion_of_cSC'] == 'No', 'Complete_Lesion_of_cSC'] = 0 x2.loc[x2['Complete_Lesion_of_cSC'] == 'Yes', 'Complete_Lesion_of_cSC'] = 1 x2.loc[x2['Anterior_Cord_Syndrome_of_cSC'] == 'No', 'Anterior_Cord_Syndrome_of_cSC'] = 0 x2.loc[x2['Anterior_Cord_Syndrome_of_cSC'] == 'Yes', 'Anterior_Cord_Syndrome_of_cSC'] = 1 x2.loc[x2['BrownSequard_Syndrome_of_cSC'] == 'No', 'BrownSequard_Syndrome_of_cSC'] = 0 x2.loc[x2['BrownSequard_Syndrome_of_cSC'] == 'Yes', 'BrownSequard_Syndrome_of_cSC'] = 1 x2.loc[x2['Other_Incomplete_Lesions_of_cSC'] == 'No', 'Other_Incomplete_Lesions_of_cSC'] = 0 x2.loc[x2['Other_Incomplete_Lesions_of_cSC'] == 'Yes', 'Other_Incomplete_Lesions_of_cSC'] = 1 x2.loc[x2['Current_Smoker'] == 'No', 'Current_Smoker'] = 0 x2.loc[x2['Current_Smoker'] == 'Yes', 'Current_Smoker'] = 1 x2.loc[x2['Current_Smoker'] == 'Unknown', 'Current_Smoker'] = 2 x2.loc[x2['Alcohol_Use_Disorder'] == 'No', 'Alcohol_Use_Disorder'] = 0 x2.loc[x2['Alcohol_Use_Disorder'] == 'Yes', 'Alcohol_Use_Disorder'] = 1 x2.loc[x2['Alcohol_Use_Disorder'] == 'Unknown', 'Alcohol_Use_Disorder'] = 2 x2.loc[x2['Substance_Abuse_Disorder'] == 'No', 'Substance_Abuse_Disorder'] = 0 x2.loc[x2['Substance_Abuse_Disorder'] == 'Yes', 'Substance_Abuse_Disorder'] = 1 x2.loc[x2['Substance_Abuse_Disorder'] == 'Unknown', 'Substance_Abuse_Disorder'] = 2 x2.loc[x2['Diabetes_Mellitus'] == 'No', 'Diabetes_Mellitus'] = 0 x2.loc[x2['Diabetes_Mellitus'] == 'Yes', 'Diabetes_Mellitus'] = 1 x2.loc[x2['Diabetes_Mellitus'] == 'Unknown', 'Diabetes_Mellitus'] = 2 x2.loc[x2['Hypertension'] == 'No', 'Hypertension'] = 0 x2.loc[x2['Hypertension'] == 'Yes', 'Hypertension'] = 1 x2.loc[x2['Hypertension'] == 'Unknown', 'Hypertension'] = 2 x2.loc[x2['Congestive_Heart_Failure'] == 'No', 'Congestive_Heart_Failure'] = 0 x2.loc[x2['Congestive_Heart_Failure'] == 'Yes', 'Congestive_Heart_Failure'] = 1 x2.loc[x2['Congestive_Heart_Failure'] == 'Unknown', 'Congestive_Heart_Failure'] = 2 x2.loc[x2['History_of_Myocardial_Infarction'] == 'No', 'History_of_Myocardial_Infarction'] = 0 x2.loc[x2['History_of_Myocardial_Infarction'] == 'Yes', 'History_of_Myocardial_Infarction'] = 1 x2.loc[x2['History_of_Myocardial_Infarction'] == 'Unknown', 'History_of_Myocardial_Infarction'] = 2 x2.loc[x2['Angina_Pectoris'] == 'No', 'Angina_Pectoris'] = 0 x2.loc[x2['Angina_Pectoris'] == 'Yes', 'Angina_Pectoris'] = 1 x2.loc[x2['Angina_Pectoris'] == 'Unknown', 'Angina_Pectoris'] = 2 x2.loc[x2['History_of_Cerebrovascular_Accident'] == 'No', 'History_of_Cerebrovascular_Accident'] = 0 x2.loc[x2['History_of_Cerebrovascular_Accident'] == 'Yes', 'History_of_Cerebrovascular_Accident'] = 1 x2.loc[x2['History_of_Cerebrovascular_Accident'] == 'Unknown', 'History_of_Cerebrovascular_Accident'] = 2 x2.loc[x2['Peripheral_Arterial_Disease'] == 'No', 'Peripheral_Arterial_Disease'] = 0 x2.loc[x2['Peripheral_Arterial_Disease'] == 'Yes', 'Peripheral_Arterial_Disease'] = 1 x2.loc[x2['Peripheral_Arterial_Disease'] == 'Unknown', 'Peripheral_Arterial_Disease'] = 2 x2.loc[x2['Chronic_Obstructive_Pulmonary_Disease'] == 'No', 'Chronic_Obstructive_Pulmonary_Disease'] = 0 x2.loc[x2['Chronic_Obstructive_Pulmonary_Disease'] == 'Yes', 'Chronic_Obstructive_Pulmonary_Disease'] = 1 x2.loc[x2['Chronic_Obstructive_Pulmonary_Disease'] == 'Unknown', 'Chronic_Obstructive_Pulmonary_Disease'] = 2 x2.loc[x2['Chronic_Renal_Failure'] == 'No', 'Chronic_Renal_Failure'] = 0 x2.loc[x2['Chronic_Renal_Failure'] == 'Yes', 'Chronic_Renal_Failure'] = 1 x2.loc[x2['Chronic_Renal_Failure'] == 'Unknown', 'Chronic_Renal_Failure'] = 2 x2.loc[x2['Cirrhosis'] == 'No', 'Cirrhosis'] = 0 x2.loc[x2['Cirrhosis'] == 'Yes', 'Cirrhosis'] = 1 x2.loc[x2['Cirrhosis'] == 'Unknown', 'Cirrhosis'] = 2 x2.loc[x2['Bleeding_Disorder'] == 'No', 'Bleeding_Disorder'] = 0 x2.loc[x2['Bleeding_Disorder'] == 'Yes', 'Bleeding_Disorder'] = 1 x2.loc[x2['Bleeding_Disorder'] == 'Unknown', 'Bleeding_Disorder'] = 2 x2.loc[x2['Disseminated_Cancer'] == 'No', 'Disseminated_Cancer'] = 0 x2.loc[x2['Disseminated_Cancer'] == 'Yes', 'Disseminated_Cancer'] = 1 x2.loc[x2['Disseminated_Cancer'] == 'Unknown', 'Disseminated_Cancer'] = 2 x2.loc[x2['Currently_Receiving_Chemotherapy_for_Cancer'] == 'No', 'Currently_Receiving_Chemotherapy_for_Cancer'] = 0 x2.loc[x2['Currently_Receiving_Chemotherapy_for_Cancer'] == 'Yes', 'Currently_Receiving_Chemotherapy_for_Cancer'] = 1 x2.loc[x2['Currently_Receiving_Chemotherapy_for_Cancer'] == 'Unknown', 'Currently_Receiving_Chemotherapy_for_Cancer'] = 2 x2.loc[x2['Dementia'] == 'No', 'Dementia'] = 0 x2.loc[x2['Dementia'] == 'Yes', 'Dementia'] = 1 x2.loc[x2['Dementia'] == 'Unknown', 'Dementia'] = 2 x2.loc[x2['Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder'] == 'No', 'Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder'] = 0 x2.loc[x2['Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder'] == 'Yes', 'Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder'] = 1 x2.loc[x2['Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder'] == 'Unknown', 'Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder'] = 2 x2.loc[x2['Mental_or_Personality_Disorder'] == 'No', 'Mental_or_Personality_Disorder'] = 0 x2.loc[x2['Mental_or_Personality_Disorder'] == 'Yes', 'Mental_or_Personality_Disorder'] = 1 x2.loc[x2['Mental_or_Personality_Disorder'] == 'Unknown', 'Mental_or_Personality_Disorder'] = 2 x2.loc[x2['Ability_to_Complete_AgeAppropriate_ADL'] == 'No', 'Ability_to_Complete_AgeAppropriate_ADL'] = 0 x2.loc[x2['Ability_to_Complete_AgeAppropriate_ADL'] == 'Yes', 'Ability_to_Complete_AgeAppropriate_ADL'] = 1 x2.loc[x2['Ability_to_Complete_AgeAppropriate_ADL'] == 'Unknown', 'Ability_to_Complete_AgeAppropriate_ADL'] = 2 x2.loc[x2['Pregnancy'] == 'Not applicable (male patient)', 'Pregnancy'] = 0 x2.loc[x2['Pregnancy'] == 'No', 'Pregnancy'] = 1 x2.loc[x2['Pregnancy'] == 'Yes', 'Pregnancy'] = 2 x2.loc[x2['Pregnancy'] == 'Unkown', 'Pregnancy'] = 3 x2.loc[x2['Anticoagulant_Therapy'] == 'No', 'Anticoagulant_Therapy'] = 0 x2.loc[x2['Anticoagulant_Therapy'] == 'Yes', 'Anticoagulant_Therapy'] = 1 x2.loc[x2['Anticoagulant_Therapy'] == 'Unknown', 'Anticoagulant_Therapy'] = 2 x2.loc[x2['Steroid_Use'] == 'No', 'Steroid_Use'] = 0 x2.loc[x2['Steroid_Use'] == 'Yes', 'Steroid_Use'] = 1 x2.loc[x2['Steroid_Use'] == 'Unknown', 'Steroid_Use'] = 2 x2.loc[x2['Transport_Mode'] == 'Ground ambulance', 'Transport_Mode'] = 0 x2.loc[x2['Transport_Mode'] == 'Private/public vehicle/walk-in', 'Transport_Mode'] = 1 x2.loc[x2['Transport_Mode'] == 'Air ambulance', 'Transport_Mode'] = 2 x2.loc[x2['Transport_Mode'] == 'Other/unknown', 'Transport_Mode'] = 3 x2.loc[x2['InterFacility_Transfer'] == 'No', 'InterFacility_Transfer'] = 0 x2.loc[x2['InterFacility_Transfer'] == 'Yes', 'InterFacility_Transfer'] = 1 x2.loc[x2['InterFacility_Transfer'] == 'Unknown', 'InterFacility_Transfer'] = 2 x2.loc[x2['Trauma_Type'] == 'Blunt', 'Trauma_Type'] = 0 x2.loc[x2['Trauma_Type'] == 'Penetrating', 'Trauma_Type'] = 1 x2.loc[x2['Trauma_Type'] == 'Other/unknown', 'Trauma_Type'] = 2 x2.loc[x2['Injury_Intent'] == 'Unintentional', 'Injury_Intent'] = 0 x2.loc[x2['Injury_Intent'] == 'Assault', 'Injury_Intent'] = 1 x2.loc[x2['Injury_Intent'] == 'Other/unknown', 'Injury_Intent'] = 2 x2.loc[x2['Mechanism_of_Injury'] == 'Fall', 'Mechanism_of_Injury'] = 0 x2.loc[x2['Mechanism_of_Injury'] == 'MVT occupant', 'Mechanism_of_Injury'] = 1 x2.loc[x2['Mechanism_of_Injury'] == 'Struck by or against', 'Mechanism_of_Injury'] = 2 x2.loc[x2['Mechanism_of_Injury'] == 'Other MVT', 'Mechanism_of_Injury'] = 3 x2.loc[x2['Mechanism_of_Injury'] == 'MVT motorcyclist', 'Mechanism_of_Injury'] = 4 x2.loc[x2['Mechanism_of_Injury'] == 'Other transport', 'Mechanism_of_Injury'] = 5 x2.loc[x2['Mechanism_of_Injury'] == 'Other pedal cyclist', 'Mechanism_of_Injury'] = 6 x2.loc[x2['Mechanism_of_Injury'] == 'MVT pedestrian', 'Mechanism_of_Injury'] = 7 x2.loc[x2['Mechanism_of_Injury'] == 'Firearm', 'Mechanism_of_Injury'] = 8 x2.loc[x2['Mechanism_of_Injury'] == 'Other/unknown', 'Mechanism_of_Injury'] = 9 x2.loc[x2['Protective_Device'] == 'None', 'Protective_Device'] = 0 x2.loc[x2['Protective_Device'] == 'Belt', 'Protective_Device'] = 1 x2.loc[x2['Protective_Device'] == 'Airbag present', 'Protective_Device'] = 2 x2.loc[x2['Protective_Device'] == 'Helmet', 'Protective_Device'] = 3 x2.loc[x2['Protective_Device'] == 'Other/unknown', 'Protective_Device'] = 4 x2.loc[x2['WorkRelated'] == 'No/unknown', 'WorkRelated'] = 0 x2.loc[x2['WorkRelated'] == 'Yes', 'WorkRelated'] = 1 x2.loc[x2['Surgical_Intervention'] == 'No', 'Surgical_Intervention'] = 0 x2.loc[x2['Surgical_Intervention'] == 'Yes', 'Surgical_Intervention'] = 1 x2.loc[x2['Alcohol_Screen'] == 'No', 'Alcohol_Screen'] = 0 x2.loc[x2['Alcohol_Screen'] == 'Yes', 'Alcohol_Screen'] = 1 x2.loc[x2['Alcohol_Screen'] == 'Unknown', 'Alcohol_Screen'] = 2 x2.loc[x2['Drug_Screen__Amphetamine'] == 'No', 'Drug_Screen__Amphetamine'] = 0 x2.loc[x2['Drug_Screen__Amphetamine'] == 'Yes', 'Drug_Screen__Amphetamine'] = 1 x2.loc[x2['Drug_Screen__Amphetamine'] == 'Not tested', 'Drug_Screen__Amphetamine'] = 2 x2.loc[x2['Drug_Screen__Barbiturate'] == 'No', 'Drug_Screen__Barbiturate'] = 0 x2.loc[x2['Drug_Screen__Barbiturate'] == 'Yes', 'Drug_Screen__Barbiturate'] = 1 x2.loc[x2['Drug_Screen__Barbiturate'] == 'Not tested', 'Drug_Screen__Barbiturate'] = 2 x2.loc[x2['Drug_Screen__Benzodiazepines'] == 'No', 'Drug_Screen__Benzodiazepines'] = 0 x2.loc[x2['Drug_Screen__Benzodiazepines'] == 'Yes', 'Drug_Screen__Benzodiazepines'] = 1 x2.loc[x2['Drug_Screen__Benzodiazepines'] == 'Not tested', 'Drug_Screen__Benzodiazepines'] = 2 x2.loc[x2['Drug_Screen__Cannabinoid'] == 'No', 'Drug_Screen__Cannabinoid'] = 0 x2.loc[x2['Drug_Screen__Cannabinoid'] == 'Yes', 'Drug_Screen__Cannabinoid'] = 1 x2.loc[x2['Drug_Screen__Cannabinoid'] == 'Not tested', 'Drug_Screen__Cannabinoid'] = 2 x2.loc[x2['Drug_Screen__Cocaine'] == 'No', 'Drug_Screen__Cocaine'] = 0 x2.loc[x2['Drug_Screen__Cocaine'] == 'Yes', 'Drug_Screen__Cocaine'] = 1 x2.loc[x2['Drug_Screen__Cocaine'] == 'Not tested', 'Drug_Screen__Cocaine'] = 2 x2.loc[x2['Drug_Screen__MDMA_or_Ecstasy'] == 'No', 'Drug_Screen__MDMA_or_Ecstasy'] = 0 x2.loc[x2['Drug_Screen__MDMA_or_Ecstasy'] == 'Yes', 'Drug_Screen__MDMA_or_Ecstasy'] = 1 x2.loc[x2['Drug_Screen__MDMA_or_Ecstasy'] == 'Not tested', 'Drug_Screen__MDMA_or_Ecstasy'] = 2 x2.loc[x2['Drug_Screen__Methadone'] == 'No', 'Drug_Screen__Methadone'] = 0 x2.loc[x2['Drug_Screen__Methadone'] == 'Yes', 'Drug_Screen__Methadone'] = 1 x2.loc[x2['Drug_Screen__Methadone'] == 'Not tested', 'Drug_Screen__Methadone'] = 2 x2.loc[x2['Drug_Screen__Methamphetamine'] == 'No', 'Drug_Screen__Methamphetamine'] = 0 x2.loc[x2['Drug_Screen__Methamphetamine'] == 'Yes', 'Drug_Screen__Methamphetamine'] = 1 x2.loc[x2['Drug_Screen__Methamphetamine'] == 'Not tested', 'Drug_Screen__Methamphetamine'] = 2 x2.loc[x2['Drug_Screen__Opioid'] == 'No', 'Drug_Screen__Opioid'] = 0 x2.loc[x2['Drug_Screen__Opioid'] == 'Yes', 'Drug_Screen__Opioid'] = 1 x2.loc[x2['Drug_Screen__Opioid'] == 'Not tested', 'Drug_Screen__Opioid'] = 2 x2.loc[x2['Drug_Screen__Oxycodone'] == 'No', 'Drug_Screen__Oxycodone'] = 0 x2.loc[x2['Drug_Screen__Oxycodone'] == 'Yes', 'Drug_Screen__Oxycodone'] = 1 x2.loc[x2['Drug_Screen__Oxycodone'] == 'Not tested', 'Drug_Screen__Oxycodone'] = 2 x2.loc[x2['Drug_Screen__Phencyclidine'] == 'No', 'Drug_Screen__Phencyclidine'] = 0 x2.loc[x2['Drug_Screen__Phencyclidine'] == 'Yes', 'Drug_Screen__Phencyclidine'] = 1 x2.loc[x2['Drug_Screen__Phencyclidine'] == 'Not tested', 'Drug_Screen__Phencyclidine'] = 2 x2.loc[x2['Drug_Screen__Tricyclic_Antidepressant'] == 'No', 'Drug_Screen__Tricyclic_Antidepressant'] = 0 x2.loc[x2['Drug_Screen__Tricyclic_Antidepressant'] == 'Yes', 'Drug_Screen__Tricyclic_Antidepressant'] = 1 x2.loc[x2['Drug_Screen__Tricyclic_Antidepressant'] == 'Not tested', 'Drug_Screen__Tricyclic_Antidepressant'] = 2 x2.loc[x2['ACS_Verification_Level'] == 'Level I Trauma Center', 'ACS_Verification_Level'] = 0 x2.loc[x2['ACS_Verification_Level'] == 'Level II Trauma Center', 'ACS_Verification_Level'] = 1 x2.loc[x2['ACS_Verification_Level'] == 'Level III Trauma Center', 'ACS_Verification_Level'] = 2 x2.loc[x2['ACS_Verification_Level'] == 'Unknown', 'ACS_Verification_Level'] = 3 x2.loc[x2['Hospital_Type'] == 'Non-profit', 'Hospital_Type'] = 0 x2.loc[x2['Hospital_Type'] == 'For profit', 'Hospital_Type'] = 1 x2.loc[x2['Hospital_Type'] == 'Government', 'Hospital_Type'] = 2 x2.loc[x2['Hospital_Type'] == 'Unknown', 'Hospital_Type'] = 3 x2.loc[x2['Facility_Bed_Size'] == 'More than 600', 'Facility_Bed_Size'] = 0 x2.loc[x2['Facility_Bed_Size'] == '401 to 600', 'Facility_Bed_Size'] = 1 x2.loc[x2['Facility_Bed_Size'] == '201 to 400', 'Facility_Bed_Size'] = 2 x2.loc[x2['Facility_Bed_Size'] == '200 or fewer', 'Facility_Bed_Size'] = 3 x2.loc[x2['Primary_Method_of_Payment'] == 'Medicare', 'Primary_Method_of_Payment'] = 0 x2.loc[x2['Primary_Method_of_Payment'] == 'Private/commercial insurance', 'Primary_Method_of_Payment'] = 1 x2.loc[x2['Primary_Method_of_Payment'] == 'Medicaid', 'Primary_Method_of_Payment'] = 2 x2.loc[x2['Primary_Method_of_Payment'] == 'Self-pay', 'Primary_Method_of_Payment'] = 3 x2.loc[x2['Primary_Method_of_Payment'] == 'Other/unknown', 'Primary_Method_of_Payment'] = 4 #Prepare validation data for the outcome 2 (discharge). y2_valid = x2_valid.pop('OUTCOME') x2_valid.loc[x2_valid['Sex'] == 'Male', 'Sex'] = 0 x2_valid.loc[x2_valid['Sex'] == 'Female', 'Sex'] = 1 x2_valid.loc[x2_valid['Sex'] == 'Non-Binary', 'Sex'] = 2 x2_valid.loc[x2_valid['Sex'] == 'Unknown', 'Sex'] = 3 x2_valid.loc[x2_valid['Race'] == 'White', 'Race'] = 0 x2_valid.loc[x2_valid['Race'] == 'Black', 'Race'] = 1 x2_valid.loc[x2_valid['Race'] == 'Asian', 'Race'] = 2 x2_valid.loc[x2_valid['Race'] == 'Other/unknown', 'Race'] = 5 x2_valid.loc[x2_valid['Ethnicity'] == 'Not Hispanic or Latino', 'Ethnicity'] = 0 x2_valid.loc[x2_valid['Ethnicity'] == 'Hispanic or Latino', 'Ethnicity'] = 1 x2_valid.loc[x2_valid['Ethnicity'] == 'Unknown', 'Ethnicity'] = 2 x2_valid.loc[x2_valid['Supplemental_Oxygen'] == 'No supplemental oxygen', 'Supplemental_Oxygen'] = 0 x2_valid.loc[x2_valid['Supplemental_Oxygen'] == 'Supplemental oxygen', 'Supplemental_Oxygen'] = 1 x2_valid.loc[x2_valid['Supplemental_Oxygen'] == 'Unknown', 'Supplemental_Oxygen'] = 2 x2_valid.loc[x2_valid['Respiratory_Assistance'] == 'Unassisted respiratory rate', 'Respiratory_Assistance'] = 0 x2_valid.loc[x2_valid['Respiratory_Assistance'] == 'Assisted respiratory rate', 'Respiratory_Assistance'] = 1 x2_valid.loc[x2_valid['Respiratory_Assistance'] == 'Unknown', 'Respiratory_Assistance'] = 2 x2_valid.loc[x2_valid['Fracture_of_C1_Vertebra'] == 'No', 'Fracture_of_C1_Vertebra'] = 0 x2_valid.loc[x2_valid['Fracture_of_C1_Vertebra'] == 'Yes', 'Fracture_of_C1_Vertebra'] = 1 x2_valid.loc[x2_valid['Fracture_of_C2_Vertebra'] == 'No', 'Fracture_of_C2_Vertebra'] = 0 x2_valid.loc[x2_valid['Fracture_of_C2_Vertebra'] == 'Yes', 'Fracture_of_C2_Vertebra'] = 1 x2_valid.loc[x2_valid['Fracture_of_C3_Vertebra'] == 'No', 'Fracture_of_C3_Vertebra'] = 0 x2_valid.loc[x2_valid['Fracture_of_C3_Vertebra'] == 'Yes', 'Fracture_of_C3_Vertebra'] = 1 x2_valid.loc[x2_valid['Fracture_of_C4_Vertebra'] == 'No', 'Fracture_of_C4_Vertebra'] = 0 x2_valid.loc[x2_valid['Fracture_of_C4_Vertebra'] == 'Yes', 'Fracture_of_C4_Vertebra'] = 1 x2_valid.loc[x2_valid['Fracture_of_C5_Vertebra'] == 'No', 'Fracture_of_C5_Vertebra'] = 0 x2_valid.loc[x2_valid['Fracture_of_C5_Vertebra'] == 'Yes', 'Fracture_of_C5_Vertebra'] = 1 x2_valid.loc[x2_valid['Fracture_of_C6_Vertebra'] == 'No', 'Fracture_of_C6_Vertebra'] = 0 x2_valid.loc[x2_valid['Fracture_of_C6_Vertebra'] == 'Yes', 'Fracture_of_C6_Vertebra'] = 1 x2_valid.loc[x2_valid['Fracture_of_C7_Vertebra'] == 'No', 'Fracture_of_C7_Vertebra'] = 0 x2_valid.loc[x2_valid['Fracture_of_C7_Vertebra'] == 'Yes', 'Fracture_of_C7_Vertebra'] = 1 x2_valid.loc[x2_valid['Rupture_of_Cervical_Intervertebral_Disc'] == 'No', 'Rupture_of_Cervical_Intervertebral_Disc'] = 0 x2_valid.loc[x2_valid['Rupture_of_Cervical_Intervertebral_Disc'] == 'Yes', 'Rupture_of_Cervical_Intervertebral_Disc'] = 1 x2_valid.loc[x2_valid['Subluxation_and_Dislocation_of_C0/C1_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C0/C1_Vertebrae'] = 0 x2_valid.loc[x2_valid['Subluxation_and_Dislocation_of_C0/C1_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C0/C1_Vertebrae'] = 1 x2_valid.loc[x2_valid['Subluxation_and_Dislocation_of_C1/C2_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C1/C2_Vertebrae'] = 0 x2_valid.loc[x2_valid['Subluxation_and_Dislocation_of_C1/C2_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C1/C2_Vertebrae'] = 1 x2_valid.loc[x2_valid['Subluxation_and_Dislocation_of_C2/C3_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C2/C3_Vertebrae'] = 0 x2_valid.loc[x2_valid['Subluxation_and_Dislocation_of_C2/C3_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C2/C3_Vertebrae'] = 1 x2_valid.loc[x2_valid['Subluxation_and_Dislocation_of_C3/C4_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C3/C4_Vertebrae'] = 0 x2_valid.loc[x2_valid['Subluxation_and_Dislocation_of_C3/C4_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C3/C4_Vertebrae'] = 1 x2_valid.loc[x2_valid['Subluxation_and_Dislocation_of_C4/C5_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C4/C5_Vertebrae'] = 0 x2_valid.loc[x2_valid['Subluxation_and_Dislocation_of_C4/C5_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C4/C5_Vertebrae'] = 1 x2_valid.loc[x2_valid['Subluxation_and_Dislocation_of_C5/C6_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C5/C6_Vertebrae'] = 0 x2_valid.loc[x2_valid['Subluxation_and_Dislocation_of_C5/C6_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C5/C6_Vertebrae'] = 1 x2_valid.loc[x2_valid['Subluxation_and_Dislocation_of_C6/C7_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C6/C7_Vertebrae'] = 0 x2_valid.loc[x2_valid['Subluxation_and_Dislocation_of_C6/C7_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C6/C7_Vertebrae'] = 1 x2_valid.loc[x2_valid['Subluxation_and_Dislocation_of_C7/T1_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C7/T1_Vertebrae'] = 0 x2_valid.loc[x2_valid['Subluxation_and_Dislocation_of_C7/T1_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C7/T1_Vertebrae'] = 1 x2_valid.loc[x2_valid['Concussion_and_Edema_of_cSC'] == 'No', 'Concussion_and_Edema_of_cSC'] = 0 x2_valid.loc[x2_valid['Concussion_and_Edema_of_cSC'] == 'Yes', 'Concussion_and_Edema_of_cSC'] = 1 x2_valid.loc[x2_valid['Complete_Lesion_of_cSC'] == 'No', 'Complete_Lesion_of_cSC'] = 0 x2_valid.loc[x2_valid['Complete_Lesion_of_cSC'] == 'Yes', 'Complete_Lesion_of_cSC'] = 1 x2_valid.loc[x2_valid['Anterior_Cord_Syndrome_of_cSC'] == 'No', 'Anterior_Cord_Syndrome_of_cSC'] = 0 x2_valid.loc[x2_valid['Anterior_Cord_Syndrome_of_cSC'] == 'Yes', 'Anterior_Cord_Syndrome_of_cSC'] = 1 x2_valid.loc[x2_valid['BrownSequard_Syndrome_of_cSC'] == 'No', 'BrownSequard_Syndrome_of_cSC'] = 0 x2_valid.loc[x2_valid['BrownSequard_Syndrome_of_cSC'] == 'Yes', 'BrownSequard_Syndrome_of_cSC'] = 1 x2_valid.loc[x2_valid['Other_Incomplete_Lesions_of_cSC'] == 'No', 'Other_Incomplete_Lesions_of_cSC'] = 0 x2_valid.loc[x2_valid['Other_Incomplete_Lesions_of_cSC'] == 'Yes', 'Other_Incomplete_Lesions_of_cSC'] = 1 x2_valid.loc[x2_valid['Current_Smoker'] == 'No', 'Current_Smoker'] = 0 x2_valid.loc[x2_valid['Current_Smoker'] == 'Yes', 'Current_Smoker'] = 1 x2_valid.loc[x2_valid['Current_Smoker'] == 'Unknown', 'Current_Smoker'] = 2 x2_valid.loc[x2_valid['Alcohol_Use_Disorder'] == 'No', 'Alcohol_Use_Disorder'] = 0 x2_valid.loc[x2_valid['Alcohol_Use_Disorder'] == 'Yes', 'Alcohol_Use_Disorder'] = 1 x2_valid.loc[x2_valid['Alcohol_Use_Disorder'] == 'Unknown', 'Alcohol_Use_Disorder'] = 2 x2_valid.loc[x2_valid['Substance_Abuse_Disorder'] == 'No', 'Substance_Abuse_Disorder'] = 0 x2_valid.loc[x2_valid['Substance_Abuse_Disorder'] == 'Yes', 'Substance_Abuse_Disorder'] = 1 x2_valid.loc[x2_valid['Substance_Abuse_Disorder'] == 'Unknown', 'Substance_Abuse_Disorder'] = 2 x2_valid.loc[x2_valid['Diabetes_Mellitus'] == 'No', 'Diabetes_Mellitus'] = 0 x2_valid.loc[x2_valid['Diabetes_Mellitus'] == 'Yes', 'Diabetes_Mellitus'] = 1 x2_valid.loc[x2_valid['Diabetes_Mellitus'] == 'Unknown', 'Diabetes_Mellitus'] = 2 x2_valid.loc[x2_valid['Hypertension'] == 'No', 'Hypertension'] = 0 x2_valid.loc[x2_valid['Hypertension'] == 'Yes', 'Hypertension'] = 1 x2_valid.loc[x2_valid['Hypertension'] == 'Unknown', 'Hypertension'] = 2 x2_valid.loc[x2_valid['Congestive_Heart_Failure'] == 'No', 'Congestive_Heart_Failure'] = 0 x2_valid.loc[x2_valid['Congestive_Heart_Failure'] == 'Yes', 'Congestive_Heart_Failure'] = 1 x2_valid.loc[x2_valid['Congestive_Heart_Failure'] == 'Unknown', 'Congestive_Heart_Failure'] = 2 x2_valid.loc[x2_valid['History_of_Myocardial_Infarction'] == 'No', 'History_of_Myocardial_Infarction'] = 0 x2_valid.loc[x2_valid['History_of_Myocardial_Infarction'] == 'Yes', 'History_of_Myocardial_Infarction'] = 1 x2_valid.loc[x2_valid['History_of_Myocardial_Infarction'] == 'Unknown', 'History_of_Myocardial_Infarction'] = 2 x2_valid.loc[x2_valid['Angina_Pectoris'] == 'No', 'Angina_Pectoris'] = 0 x2_valid.loc[x2_valid['Angina_Pectoris'] == 'Yes', 'Angina_Pectoris'] = 1 x2_valid.loc[x2_valid['Angina_Pectoris'] == 'Unknown', 'Angina_Pectoris'] = 2 x2_valid.loc[x2_valid['History_of_Cerebrovascular_Accident'] == 'No', 'History_of_Cerebrovascular_Accident'] = 0 x2_valid.loc[x2_valid['History_of_Cerebrovascular_Accident'] == 'Yes', 'History_of_Cerebrovascular_Accident'] = 1 x2_valid.loc[x2_valid['History_of_Cerebrovascular_Accident'] == 'Unknown', 'History_of_Cerebrovascular_Accident'] = 2 x2_valid.loc[x2_valid['Peripheral_Arterial_Disease'] == 'No', 'Peripheral_Arterial_Disease'] = 0 x2_valid.loc[x2_valid['Peripheral_Arterial_Disease'] == 'Yes', 'Peripheral_Arterial_Disease'] = 1 x2_valid.loc[x2_valid['Peripheral_Arterial_Disease'] == 'Unknown', 'Peripheral_Arterial_Disease'] = 2 x2_valid.loc[x2_valid['Chronic_Obstructive_Pulmonary_Disease'] == 'No', 'Chronic_Obstructive_Pulmonary_Disease'] = 0 x2_valid.loc[x2_valid['Chronic_Obstructive_Pulmonary_Disease'] == 'Yes', 'Chronic_Obstructive_Pulmonary_Disease'] = 1 x2_valid.loc[x2_valid['Chronic_Obstructive_Pulmonary_Disease'] == 'Unknown', 'Chronic_Obstructive_Pulmonary_Disease'] = 2 x2_valid.loc[x2_valid['Chronic_Renal_Failure'] == 'No', 'Chronic_Renal_Failure'] = 0 x2_valid.loc[x2_valid['Chronic_Renal_Failure'] == 'Yes', 'Chronic_Renal_Failure'] = 1 x2_valid.loc[x2_valid['Chronic_Renal_Failure'] == 'Unknown', 'Chronic_Renal_Failure'] = 2 x2_valid.loc[x2_valid['Cirrhosis'] == 'No', 'Cirrhosis'] = 0 x2_valid.loc[x2_valid['Cirrhosis'] == 'Yes', 'Cirrhosis'] = 1 x2_valid.loc[x2_valid['Cirrhosis'] == 'Unknown', 'Cirrhosis'] = 2 x2_valid.loc[x2_valid['Bleeding_Disorder'] == 'No', 'Bleeding_Disorder'] = 0 x2_valid.loc[x2_valid['Bleeding_Disorder'] == 'Yes', 'Bleeding_Disorder'] = 1 x2_valid.loc[x2_valid['Bleeding_Disorder'] == 'Unknown', 'Bleeding_Disorder'] = 2 x2_valid.loc[x2_valid['Disseminated_Cancer'] == 'No', 'Disseminated_Cancer'] = 0 x2_valid.loc[x2_valid['Disseminated_Cancer'] == 'Yes', 'Disseminated_Cancer'] = 1 x2_valid.loc[x2_valid['Disseminated_Cancer'] == 'Unknown', 'Disseminated_Cancer'] = 2 x2_valid.loc[x2_valid['Currently_Receiving_Chemotherapy_for_Cancer'] == 'No', 'Currently_Receiving_Chemotherapy_for_Cancer'] = 0 x2_valid.loc[x2_valid['Currently_Receiving_Chemotherapy_for_Cancer'] == 'Yes', 'Currently_Receiving_Chemotherapy_for_Cancer'] = 1 x2_valid.loc[x2_valid['Currently_Receiving_Chemotherapy_for_Cancer'] == 'Unknown', 'Currently_Receiving_Chemotherapy_for_Cancer'] = 2 x2_valid.loc[x2_valid['Dementia'] == 'No', 'Dementia'] = 0 x2_valid.loc[x2_valid['Dementia'] == 'Yes', 'Dementia'] = 1 x2_valid.loc[x2_valid['Dementia'] == 'Unknown', 'Dementia'] = 2 x2_valid.loc[x2_valid['Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder'] == 'No', 'Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder'] = 0 x2_valid.loc[x2_valid['Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder'] == 'Yes', 'Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder'] = 1 x2_valid.loc[x2_valid['Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder'] == 'Unknown', 'Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder'] = 2 x2_valid.loc[x2_valid['Mental_or_Personality_Disorder'] == 'No', 'Mental_or_Personality_Disorder'] = 0 x2_valid.loc[x2_valid['Mental_or_Personality_Disorder'] == 'Yes', 'Mental_or_Personality_Disorder'] = 1 x2_valid.loc[x2_valid['Mental_or_Personality_Disorder'] == 'Unknown', 'Mental_or_Personality_Disorder'] = 2 x2_valid.loc[x2_valid['Ability_to_Complete_AgeAppropriate_ADL'] == 'No', 'Ability_to_Complete_AgeAppropriate_ADL'] = 0 x2_valid.loc[x2_valid['Ability_to_Complete_AgeAppropriate_ADL'] == 'Yes', 'Ability_to_Complete_AgeAppropriate_ADL'] = 1 x2_valid.loc[x2_valid['Ability_to_Complete_AgeAppropriate_ADL'] == 'Unknown', 'Ability_to_Complete_AgeAppropriate_ADL'] = 2 x2_valid.loc[x2_valid['Pregnancy'] == 'Not applicable (male patient)', 'Pregnancy'] = 0 x2_valid.loc[x2_valid['Pregnancy'] == 'No', 'Pregnancy'] = 1 x2_valid.loc[x2_valid['Pregnancy'] == 'Yes', 'Pregnancy'] = 2 x2_valid.loc[x2_valid['Pregnancy'] == 'Unkown', 'Pregnancy'] = 3 x2_valid.loc[x2_valid['Anticoagulant_Therapy'] == 'No', 'Anticoagulant_Therapy'] = 0 x2_valid.loc[x2_valid['Anticoagulant_Therapy'] == 'Yes', 'Anticoagulant_Therapy'] = 1 x2_valid.loc[x2_valid['Anticoagulant_Therapy'] == 'Unknown', 'Anticoagulant_Therapy'] = 2 x2_valid.loc[x2_valid['Steroid_Use'] == 'No', 'Steroid_Use'] = 0 x2_valid.loc[x2_valid['Steroid_Use'] == 'Yes', 'Steroid_Use'] = 1 x2_valid.loc[x2_valid['Steroid_Use'] == 'Unknown', 'Steroid_Use'] = 2 x2_valid.loc[x2_valid['Transport_Mode'] == 'Ground ambulance', 'Transport_Mode'] = 0 x2_valid.loc[x2_valid['Transport_Mode'] == 'Private/public vehicle/walk-in', 'Transport_Mode'] = 1 x2_valid.loc[x2_valid['Transport_Mode'] == 'Air ambulance', 'Transport_Mode'] = 2 x2_valid.loc[x2_valid['Transport_Mode'] == 'Other/unknown', 'Transport_Mode'] = 3 x2_valid.loc[x2_valid['InterFacility_Transfer'] == 'No', 'InterFacility_Transfer'] = 0 x2_valid.loc[x2_valid['InterFacility_Transfer'] == 'Yes', 'InterFacility_Transfer'] = 1 x2_valid.loc[x2_valid['InterFacility_Transfer'] == 'Unknown', 'InterFacility_Transfer'] = 2 x2_valid.loc[x2_valid['Trauma_Type'] == 'Blunt', 'Trauma_Type'] = 0 x2_valid.loc[x2_valid['Trauma_Type'] == 'Penetrating', 'Trauma_Type'] = 1 x2_valid.loc[x2_valid['Trauma_Type'] == 'Other/unknown', 'Trauma_Type'] = 2 x2_valid.loc[x2_valid['Injury_Intent'] == 'Unintentional', 'Injury_Intent'] = 0 x2_valid.loc[x2_valid['Injury_Intent'] == 'Assault', 'Injury_Intent'] = 1 x2_valid.loc[x2_valid['Injury_Intent'] == 'Other/unknown', 'Injury_Intent'] = 2 x2_valid.loc[x2_valid['Mechanism_of_Injury'] == 'Fall', 'Mechanism_of_Injury'] = 0 x2_valid.loc[x2_valid['Mechanism_of_Injury'] == 'MVT occupant', 'Mechanism_of_Injury'] = 1 x2_valid.loc[x2_valid['Mechanism_of_Injury'] == 'Struck by or against', 'Mechanism_of_Injury'] = 2 x2_valid.loc[x2_valid['Mechanism_of_Injury'] == 'Other MVT', 'Mechanism_of_Injury'] = 3 x2_valid.loc[x2_valid['Mechanism_of_Injury'] == 'MVT motorcyclist', 'Mechanism_of_Injury'] = 4 x2_valid.loc[x2_valid['Mechanism_of_Injury'] == 'Other transport', 'Mechanism_of_Injury'] = 5 x2_valid.loc[x2_valid['Mechanism_of_Injury'] == 'Other pedal cyclist', 'Mechanism_of_Injury'] = 6 x2_valid.loc[x2_valid['Mechanism_of_Injury'] == 'MVT pedestrian', 'Mechanism_of_Injury'] = 7 x2_valid.loc[x2_valid['Mechanism_of_Injury'] == 'Firearm', 'Mechanism_of_Injury'] = 8 x2_valid.loc[x2_valid['Mechanism_of_Injury'] == 'Other/unknown', 'Mechanism_of_Injury'] = 9 x2_valid.loc[x2_valid['Protective_Device'] == 'None', 'Protective_Device'] = 0 x2_valid.loc[x2_valid['Protective_Device'] == 'Belt', 'Protective_Device'] = 1 x2_valid.loc[x2_valid['Protective_Device'] == 'Airbag present', 'Protective_Device'] = 2 x2_valid.loc[x2_valid['Protective_Device'] == 'Helmet', 'Protective_Device'] = 3 x2_valid.loc[x2_valid['Protective_Device'] == 'Other/unknown', 'Protective_Device'] = 4 x2_valid.loc[x2_valid['WorkRelated'] == 'No/unknown', 'WorkRelated'] = 0 x2_valid.loc[x2_valid['WorkRelated'] == 'Yes', 'WorkRelated'] = 1 x2_valid.loc[x2_valid['Surgical_Intervention'] == 'No', 'Surgical_Intervention'] = 0 x2_valid.loc[x2_valid['Surgical_Intervention'] == 'Yes', 'Surgical_Intervention'] = 1 x2_valid.loc[x2_valid['Alcohol_Screen'] == 'No', 'Alcohol_Screen'] = 0 x2_valid.loc[x2_valid['Alcohol_Screen'] == 'Yes', 'Alcohol_Screen'] = 1 x2_valid.loc[x2_valid['Alcohol_Screen'] == 'Unknown', 'Alcohol_Screen'] = 2 x2_valid.loc[x2_valid['Drug_Screen__Amphetamine'] == 'No', 'Drug_Screen__Amphetamine'] = 0 x2_valid.loc[x2_valid['Drug_Screen__Amphetamine'] == 'Yes', 'Drug_Screen__Amphetamine'] = 1 x2_valid.loc[x2_valid['Drug_Screen__Amphetamine'] == 'Not tested', 'Drug_Screen__Amphetamine'] = 2 x2_valid.loc[x2_valid['Drug_Screen__Barbiturate'] == 'No', 'Drug_Screen__Barbiturate'] = 0 x2_valid.loc[x2_valid['Drug_Screen__Barbiturate'] == 'Yes', 'Drug_Screen__Barbiturate'] = 1 x2_valid.loc[x2_valid['Drug_Screen__Barbiturate'] == 'Not tested', 'Drug_Screen__Barbiturate'] = 2 x2_valid.loc[x2_valid['Drug_Screen__Benzodiazepines'] == 'No', 'Drug_Screen__Benzodiazepines'] = 0 x2_valid.loc[x2_valid['Drug_Screen__Benzodiazepines'] == 'Yes', 'Drug_Screen__Benzodiazepines'] = 1 x2_valid.loc[x2_valid['Drug_Screen__Benzodiazepines'] == 'Not tested', 'Drug_Screen__Benzodiazepines'] = 2 x2_valid.loc[x2_valid['Drug_Screen__Cannabinoid'] == 'No', 'Drug_Screen__Cannabinoid'] = 0 x2_valid.loc[x2_valid['Drug_Screen__Cannabinoid'] == 'Yes', 'Drug_Screen__Cannabinoid'] = 1 x2_valid.loc[x2_valid['Drug_Screen__Cannabinoid'] == 'Not tested', 'Drug_Screen__Cannabinoid'] = 2 x2_valid.loc[x2_valid['Drug_Screen__Cocaine'] == 'No', 'Drug_Screen__Cocaine'] = 0 x2_valid.loc[x2_valid['Drug_Screen__Cocaine'] == 'Yes', 'Drug_Screen__Cocaine'] = 1 x2_valid.loc[x2_valid['Drug_Screen__Cocaine'] == 'Not tested', 'Drug_Screen__Cocaine'] = 2 x2_valid.loc[x2_valid['Drug_Screen__MDMA_or_Ecstasy'] == 'No', 'Drug_Screen__MDMA_or_Ecstasy'] = 0 x2_valid.loc[x2_valid['Drug_Screen__MDMA_or_Ecstasy'] == 'Yes', 'Drug_Screen__MDMA_or_Ecstasy'] = 1 x2_valid.loc[x2_valid['Drug_Screen__MDMA_or_Ecstasy'] == 'Not tested', 'Drug_Screen__MDMA_or_Ecstasy'] = 2 x2_valid.loc[x2_valid['Drug_Screen__Methadone'] == 'No', 'Drug_Screen__Methadone'] = 0 x2_valid.loc[x2_valid['Drug_Screen__Methadone'] == 'Yes', 'Drug_Screen__Methadone'] = 1 x2_valid.loc[x2_valid['Drug_Screen__Methadone'] == 'Not tested', 'Drug_Screen__Methadone'] = 2 x2_valid.loc[x2_valid['Drug_Screen__Methamphetamine'] == 'No', 'Drug_Screen__Methamphetamine'] = 0 x2_valid.loc[x2_valid['Drug_Screen__Methamphetamine'] == 'Yes', 'Drug_Screen__Methamphetamine'] = 1 x2_valid.loc[x2_valid['Drug_Screen__Methamphetamine'] == 'Not tested', 'Drug_Screen__Methamphetamine'] = 2 x2_valid.loc[x2_valid['Drug_Screen__Opioid'] == 'No', 'Drug_Screen__Opioid'] = 0 x2_valid.loc[x2_valid['Drug_Screen__Opioid'] == 'Yes', 'Drug_Screen__Opioid'] = 1 x2_valid.loc[x2_valid['Drug_Screen__Opioid'] == 'Not tested', 'Drug_Screen__Opioid'] = 2 x2_valid.loc[x2_valid['Drug_Screen__Oxycodone'] == 'No', 'Drug_Screen__Oxycodone'] = 0 x2_valid.loc[x2_valid['Drug_Screen__Oxycodone'] == 'Yes', 'Drug_Screen__Oxycodone'] = 1 x2_valid.loc[x2_valid['Drug_Screen__Oxycodone'] == 'Not tested', 'Drug_Screen__Oxycodone'] = 2 x2_valid.loc[x2_valid['Drug_Screen__Phencyclidine'] == 'No', 'Drug_Screen__Phencyclidine'] = 0 x2_valid.loc[x2_valid['Drug_Screen__Phencyclidine'] == 'Yes', 'Drug_Screen__Phencyclidine'] = 1 x2_valid.loc[x2_valid['Drug_Screen__Phencyclidine'] == 'Not tested', 'Drug_Screen__Phencyclidine'] = 2 x2_valid.loc[x2_valid['Drug_Screen__Tricyclic_Antidepressant'] == 'No', 'Drug_Screen__Tricyclic_Antidepressant'] = 0 x2_valid.loc[x2_valid['Drug_Screen__Tricyclic_Antidepressant'] == 'Yes', 'Drug_Screen__Tricyclic_Antidepressant'] = 1 x2_valid.loc[x2_valid['Drug_Screen__Tricyclic_Antidepressant'] == 'Not tested', 'Drug_Screen__Tricyclic_Antidepressant'] = 2 x2_valid.loc[x2_valid['ACS_Verification_Level'] == 'Level I Trauma Center', 'ACS_Verification_Level'] = 0 x2_valid.loc[x2_valid['ACS_Verification_Level'] == 'Level II Trauma Center', 'ACS_Verification_Level'] = 1 x2_valid.loc[x2_valid['ACS_Verification_Level'] == 'Level III Trauma Center', 'ACS_Verification_Level'] = 2 x2_valid.loc[x2_valid['ACS_Verification_Level'] == 'Unknown', 'ACS_Verification_Level'] = 3 x2_valid.loc[x2_valid['Hospital_Type'] == 'Non-profit', 'Hospital_Type'] = 0 x2_valid.loc[x2_valid['Hospital_Type'] == 'For profit', 'Hospital_Type'] = 1 x2_valid.loc[x2_valid['Hospital_Type'] == 'Government', 'Hospital_Type'] = 2 x2_valid.loc[x2_valid['Hospital_Type'] == 'Unknown', 'Hospital_Type'] = 3 x2_valid.loc[x2_valid['Facility_Bed_Size'] == 'More than 600', 'Facility_Bed_Size'] = 0 x2_valid.loc[x2_valid['Facility_Bed_Size'] == '401 to 600', 'Facility_Bed_Size'] = 1 x2_valid.loc[x2_valid['Facility_Bed_Size'] == '201 to 400', 'Facility_Bed_Size'] = 2 x2_valid.loc[x2_valid['Facility_Bed_Size'] == '200 or fewer', 'Facility_Bed_Size'] = 3 x2_valid.loc[x2_valid['Primary_Method_of_Payment'] == 'Medicare', 'Primary_Method_of_Payment'] = 0 x2_valid.loc[x2_valid['Primary_Method_of_Payment'] == 'Private/commercial insurance', 'Primary_Method_of_Payment'] = 1 x2_valid.loc[x2_valid['Primary_Method_of_Payment'] == 'Medicaid', 'Primary_Method_of_Payment'] = 2 x2_valid.loc[x2_valid['Primary_Method_of_Payment'] == 'Self-pay', 'Primary_Method_of_Payment'] = 3 x2_valid.loc[x2_valid['Primary_Method_of_Payment'] == 'Other/unknown', 'Primary_Method_of_Payment'] = 4 #Prepare training data for the outcome 3 (LOS). y3 = x3.pop('OUTCOME') x3.loc[x3['Sex'] == 'Male', 'Sex'] = 0 x3.loc[x3['Sex'] == 'Female', 'Sex'] = 1 x3.loc[x3['Sex'] == 'Non-Binary', 'Sex'] = 2 x3.loc[x3['Sex'] == 'Unknown', 'Sex'] = 3 x3.loc[x3['Race'] == 'White', 'Race'] = 0 x3.loc[x3['Race'] == 'Black', 'Race'] = 1 x3.loc[x3['Race'] == 'Asian', 'Race'] = 2 x3.loc[x3['Race'] == 'Other/unknown', 'Race'] = 5 x3.loc[x3['Ethnicity'] == 'Not Hispanic or Latino', 'Ethnicity'] = 0 x3.loc[x3['Ethnicity'] == 'Hispanic or Latino', 'Ethnicity'] = 1 x3.loc[x3['Ethnicity'] == 'Unknown', 'Ethnicity'] = 2 x3.loc[x3['Supplemental_Oxygen'] == 'No supplemental oxygen', 'Supplemental_Oxygen'] = 0 x3.loc[x3['Supplemental_Oxygen'] == 'Supplemental oxygen', 'Supplemental_Oxygen'] = 1 x3.loc[x3['Supplemental_Oxygen'] == 'Unknown', 'Supplemental_Oxygen'] = 2 x3.loc[x3['Respiratory_Assistance'] == 'Unassisted respiratory rate', 'Respiratory_Assistance'] = 0 x3.loc[x3['Respiratory_Assistance'] == 'Assisted respiratory rate', 'Respiratory_Assistance'] = 1 x3.loc[x3['Respiratory_Assistance'] == 'Unknown', 'Respiratory_Assistance'] = 2 x3.loc[x3['Fracture_of_C1_Vertebra'] == 'No', 'Fracture_of_C1_Vertebra'] = 0 x3.loc[x3['Fracture_of_C1_Vertebra'] == 'Yes', 'Fracture_of_C1_Vertebra'] = 1 x3.loc[x3['Fracture_of_C2_Vertebra'] == 'No', 'Fracture_of_C2_Vertebra'] = 0 x3.loc[x3['Fracture_of_C2_Vertebra'] == 'Yes', 'Fracture_of_C2_Vertebra'] = 1 x3.loc[x3['Fracture_of_C3_Vertebra'] == 'No', 'Fracture_of_C3_Vertebra'] = 0 x3.loc[x3['Fracture_of_C3_Vertebra'] == 'Yes', 'Fracture_of_C3_Vertebra'] = 1 x3.loc[x3['Fracture_of_C4_Vertebra'] == 'No', 'Fracture_of_C4_Vertebra'] = 0 x3.loc[x3['Fracture_of_C4_Vertebra'] == 'Yes', 'Fracture_of_C4_Vertebra'] = 1 x3.loc[x3['Fracture_of_C5_Vertebra'] == 'No', 'Fracture_of_C5_Vertebra'] = 0 x3.loc[x3['Fracture_of_C5_Vertebra'] == 'Yes', 'Fracture_of_C5_Vertebra'] = 1 x3.loc[x3['Fracture_of_C6_Vertebra'] == 'No', 'Fracture_of_C6_Vertebra'] = 0 x3.loc[x3['Fracture_of_C6_Vertebra'] == 'Yes', 'Fracture_of_C6_Vertebra'] = 1 x3.loc[x3['Fracture_of_C7_Vertebra'] == 'No', 'Fracture_of_C7_Vertebra'] = 0 x3.loc[x3['Fracture_of_C7_Vertebra'] == 'Yes', 'Fracture_of_C7_Vertebra'] = 1 x3.loc[x3['Rupture_of_Cervical_Intervertebral_Disc'] == 'No', 'Rupture_of_Cervical_Intervertebral_Disc'] = 0 x3.loc[x3['Rupture_of_Cervical_Intervertebral_Disc'] == 'Yes', 'Rupture_of_Cervical_Intervertebral_Disc'] = 1 x3.loc[x3['Subluxation_and_Dislocation_of_C0/C1_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C0/C1_Vertebrae'] = 0 x3.loc[x3['Subluxation_and_Dislocation_of_C0/C1_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C0/C1_Vertebrae'] = 1 x3.loc[x3['Subluxation_and_Dislocation_of_C1/C2_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C1/C2_Vertebrae'] = 0 x3.loc[x3['Subluxation_and_Dislocation_of_C1/C2_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C1/C2_Vertebrae'] = 1 x3.loc[x3['Subluxation_and_Dislocation_of_C2/C3_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C2/C3_Vertebrae'] = 0 x3.loc[x3['Subluxation_and_Dislocation_of_C2/C3_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C2/C3_Vertebrae'] = 1 x3.loc[x3['Subluxation_and_Dislocation_of_C3/C4_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C3/C4_Vertebrae'] = 0 x3.loc[x3['Subluxation_and_Dislocation_of_C3/C4_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C3/C4_Vertebrae'] = 1 x3.loc[x3['Subluxation_and_Dislocation_of_C4/C5_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C4/C5_Vertebrae'] = 0 x3.loc[x3['Subluxation_and_Dislocation_of_C4/C5_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C4/C5_Vertebrae'] = 1 x3.loc[x3['Subluxation_and_Dislocation_of_C5/C6_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C5/C6_Vertebrae'] = 0 x3.loc[x3['Subluxation_and_Dislocation_of_C5/C6_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C5/C6_Vertebrae'] = 1 x3.loc[x3['Subluxation_and_Dislocation_of_C6/C7_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C6/C7_Vertebrae'] = 0 x3.loc[x3['Subluxation_and_Dislocation_of_C6/C7_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C6/C7_Vertebrae'] = 1 x3.loc[x3['Subluxation_and_Dislocation_of_C7/T1_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C7/T1_Vertebrae'] = 0 x3.loc[x3['Subluxation_and_Dislocation_of_C7/T1_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C7/T1_Vertebrae'] = 1 x3.loc[x3['Concussion_and_Edema_of_cSC'] == 'No', 'Concussion_and_Edema_of_cSC'] = 0 x3.loc[x3['Concussion_and_Edema_of_cSC'] == 'Yes', 'Concussion_and_Edema_of_cSC'] = 1 x3.loc[x3['Complete_Lesion_of_cSC'] == 'No', 'Complete_Lesion_of_cSC'] = 0 x3.loc[x3['Complete_Lesion_of_cSC'] == 'Yes', 'Complete_Lesion_of_cSC'] = 1 x3.loc[x3['Anterior_Cord_Syndrome_of_cSC'] == 'No', 'Anterior_Cord_Syndrome_of_cSC'] = 0 x3.loc[x3['Anterior_Cord_Syndrome_of_cSC'] == 'Yes', 'Anterior_Cord_Syndrome_of_cSC'] = 1 x3.loc[x3['BrownSequard_Syndrome_of_cSC'] == 'No', 'BrownSequard_Syndrome_of_cSC'] = 0 x3.loc[x3['BrownSequard_Syndrome_of_cSC'] == 'Yes', 'BrownSequard_Syndrome_of_cSC'] = 1 x3.loc[x3['Other_Incomplete_Lesions_of_cSC'] == 'No', 'Other_Incomplete_Lesions_of_cSC'] = 0 x3.loc[x3['Other_Incomplete_Lesions_of_cSC'] == 'Yes', 'Other_Incomplete_Lesions_of_cSC'] = 1 x3.loc[x3['Current_Smoker'] == 'No', 'Current_Smoker'] = 0 x3.loc[x3['Current_Smoker'] == 'Yes', 'Current_Smoker'] = 1 x3.loc[x3['Current_Smoker'] == 'Unknown', 'Current_Smoker'] = 2 x3.loc[x3['Alcohol_Use_Disorder'] == 'No', 'Alcohol_Use_Disorder'] = 0 x3.loc[x3['Alcohol_Use_Disorder'] == 'Yes', 'Alcohol_Use_Disorder'] = 1 x3.loc[x3['Alcohol_Use_Disorder'] == 'Unknown', 'Alcohol_Use_Disorder'] = 2 x3.loc[x3['Substance_Abuse_Disorder'] == 'No', 'Substance_Abuse_Disorder'] = 0 x3.loc[x3['Substance_Abuse_Disorder'] == 'Yes', 'Substance_Abuse_Disorder'] = 1 x3.loc[x3['Substance_Abuse_Disorder'] == 'Unknown', 'Substance_Abuse_Disorder'] = 2 x3.loc[x3['Diabetes_Mellitus'] == 'No', 'Diabetes_Mellitus'] = 0 x3.loc[x3['Diabetes_Mellitus'] == 'Yes', 'Diabetes_Mellitus'] = 1 x3.loc[x3['Diabetes_Mellitus'] == 'Unknown', 'Diabetes_Mellitus'] = 2 x3.loc[x3['Hypertension'] == 'No', 'Hypertension'] = 0 x3.loc[x3['Hypertension'] == 'Yes', 'Hypertension'] = 1 x3.loc[x3['Hypertension'] == 'Unknown', 'Hypertension'] = 2 x3.loc[x3['Congestive_Heart_Failure'] == 'No', 'Congestive_Heart_Failure'] = 0 x3.loc[x3['Congestive_Heart_Failure'] == 'Yes', 'Congestive_Heart_Failure'] = 1 x3.loc[x3['Congestive_Heart_Failure'] == 'Unknown', 'Congestive_Heart_Failure'] = 2 x3.loc[x3['History_of_Myocardial_Infarction'] == 'No', 'History_of_Myocardial_Infarction'] = 0 x3.loc[x3['History_of_Myocardial_Infarction'] == 'Yes', 'History_of_Myocardial_Infarction'] = 1 x3.loc[x3['History_of_Myocardial_Infarction'] == 'Unknown', 'History_of_Myocardial_Infarction'] = 2 x3.loc[x3['Angina_Pectoris'] == 'No', 'Angina_Pectoris'] = 0 x3.loc[x3['Angina_Pectoris'] == 'Yes', 'Angina_Pectoris'] = 1 x3.loc[x3['Angina_Pectoris'] == 'Unknown', 'Angina_Pectoris'] = 2 x3.loc[x3['History_of_Cerebrovascular_Accident'] == 'No', 'History_of_Cerebrovascular_Accident'] = 0 x3.loc[x3['History_of_Cerebrovascular_Accident'] == 'Yes', 'History_of_Cerebrovascular_Accident'] = 1 x3.loc[x3['History_of_Cerebrovascular_Accident'] == 'Unknown', 'History_of_Cerebrovascular_Accident'] = 2 x3.loc[x3['Peripheral_Arterial_Disease'] == 'No', 'Peripheral_Arterial_Disease'] = 0 x3.loc[x3['Peripheral_Arterial_Disease'] == 'Yes', 'Peripheral_Arterial_Disease'] = 1 x3.loc[x3['Peripheral_Arterial_Disease'] == 'Unknown', 'Peripheral_Arterial_Disease'] = 2 x3.loc[x3['Chronic_Obstructive_Pulmonary_Disease'] == 'No', 'Chronic_Obstructive_Pulmonary_Disease'] = 0 x3.loc[x3['Chronic_Obstructive_Pulmonary_Disease'] == 'Yes', 'Chronic_Obstructive_Pulmonary_Disease'] = 1 x3.loc[x3['Chronic_Obstructive_Pulmonary_Disease'] == 'Unknown', 'Chronic_Obstructive_Pulmonary_Disease'] = 2 x3.loc[x3['Chronic_Renal_Failure'] == 'No', 'Chronic_Renal_Failure'] = 0 x3.loc[x3['Chronic_Renal_Failure'] == 'Yes', 'Chronic_Renal_Failure'] = 1 x3.loc[x3['Chronic_Renal_Failure'] == 'Unknown', 'Chronic_Renal_Failure'] = 2 x3.loc[x3['Cirrhosis'] == 'No', 'Cirrhosis'] = 0 x3.loc[x3['Cirrhosis'] == 'Yes', 'Cirrhosis'] = 1 x3.loc[x3['Cirrhosis'] == 'Unknown', 'Cirrhosis'] = 2 x3.loc[x3['Bleeding_Disorder'] == 'No', 'Bleeding_Disorder'] = 0 x3.loc[x3['Bleeding_Disorder'] == 'Yes', 'Bleeding_Disorder'] = 1 x3.loc[x3['Bleeding_Disorder'] == 'Unknown', 'Bleeding_Disorder'] = 2 x3.loc[x3['Disseminated_Cancer'] == 'No', 'Disseminated_Cancer'] = 0 x3.loc[x3['Disseminated_Cancer'] == 'Yes', 'Disseminated_Cancer'] = 1 x3.loc[x3['Disseminated_Cancer'] == 'Unknown', 'Disseminated_Cancer'] = 2 x3.loc[x3['Currently_Receiving_Chemotherapy_for_Cancer'] == 'No', 'Currently_Receiving_Chemotherapy_for_Cancer'] = 0 x3.loc[x3['Currently_Receiving_Chemotherapy_for_Cancer'] == 'Yes', 'Currently_Receiving_Chemotherapy_for_Cancer'] = 1 x3.loc[x3['Currently_Receiving_Chemotherapy_for_Cancer'] == 'Unknown', 'Currently_Receiving_Chemotherapy_for_Cancer'] = 2 x3.loc[x3['Dementia'] == 'No', 'Dementia'] = 0 x3.loc[x3['Dementia'] == 'Yes', 'Dementia'] = 1 x3.loc[x3['Dementia'] == 'Unknown', 'Dementia'] = 2 x3.loc[x3['Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder'] == 'No', 'Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder'] = 0 x3.loc[x3['Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder'] == 'Yes', 'Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder'] = 1 x3.loc[x3['Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder'] == 'Unknown', 'Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder'] = 2 x3.loc[x3['Mental_or_Personality_Disorder'] == 'No', 'Mental_or_Personality_Disorder'] = 0 x3.loc[x3['Mental_or_Personality_Disorder'] == 'Yes', 'Mental_or_Personality_Disorder'] = 1 x3.loc[x3['Mental_or_Personality_Disorder'] == 'Unknown', 'Mental_or_Personality_Disorder'] = 2 x3.loc[x3['Ability_to_Complete_AgeAppropriate_ADL'] == 'No', 'Ability_to_Complete_AgeAppropriate_ADL'] = 0 x3.loc[x3['Ability_to_Complete_AgeAppropriate_ADL'] == 'Yes', 'Ability_to_Complete_AgeAppropriate_ADL'] = 1 x3.loc[x3['Ability_to_Complete_AgeAppropriate_ADL'] == 'Unknown', 'Ability_to_Complete_AgeAppropriate_ADL'] = 2 x3.loc[x3['Pregnancy'] == 'Not applicable (male patient)', 'Pregnancy'] = 0 x3.loc[x3['Pregnancy'] == 'No', 'Pregnancy'] = 1 x3.loc[x3['Pregnancy'] == 'Yes', 'Pregnancy'] = 2 x3.loc[x3['Pregnancy'] == 'Unkown', 'Pregnancy'] = 3 x3.loc[x3['Anticoagulant_Therapy'] == 'No', 'Anticoagulant_Therapy'] = 0 x3.loc[x3['Anticoagulant_Therapy'] == 'Yes', 'Anticoagulant_Therapy'] = 1 x3.loc[x3['Anticoagulant_Therapy'] == 'Unknown', 'Anticoagulant_Therapy'] = 2 x3.loc[x3['Steroid_Use'] == 'No', 'Steroid_Use'] = 0 x3.loc[x3['Steroid_Use'] == 'Yes', 'Steroid_Use'] = 1 x3.loc[x3['Steroid_Use'] == 'Unknown', 'Steroid_Use'] = 2 x3.loc[x3['Transport_Mode'] == 'Ground ambulance', 'Transport_Mode'] = 0 x3.loc[x3['Transport_Mode'] == 'Private/public vehicle/walk-in', 'Transport_Mode'] = 1 x3.loc[x3['Transport_Mode'] == 'Air ambulance', 'Transport_Mode'] = 2 x3.loc[x3['Transport_Mode'] == 'Other/unknown', 'Transport_Mode'] = 3 x3.loc[x3['InterFacility_Transfer'] == 'No', 'InterFacility_Transfer'] = 0 x3.loc[x3['InterFacility_Transfer'] == 'Yes', 'InterFacility_Transfer'] = 1 x3.loc[x3['InterFacility_Transfer'] == 'Unknown', 'InterFacility_Transfer'] = 2 x3.loc[x3['Trauma_Type'] == 'Blunt', 'Trauma_Type'] = 0 x3.loc[x3['Trauma_Type'] == 'Penetrating', 'Trauma_Type'] = 1 x3.loc[x3['Trauma_Type'] == 'Other/unknown', 'Trauma_Type'] = 2 x3.loc[x3['Injury_Intent'] == 'Unintentional', 'Injury_Intent'] = 0 x3.loc[x3['Injury_Intent'] == 'Assault', 'Injury_Intent'] = 1 x3.loc[x3['Injury_Intent'] == 'Other/unknown', 'Injury_Intent'] = 2 x3.loc[x3['Mechanism_of_Injury'] == 'Fall', 'Mechanism_of_Injury'] = 0 x3.loc[x3['Mechanism_of_Injury'] == 'MVT occupant', 'Mechanism_of_Injury'] = 1 x3.loc[x3['Mechanism_of_Injury'] == 'Struck by or against', 'Mechanism_of_Injury'] = 2 x3.loc[x3['Mechanism_of_Injury'] == 'Other MVT', 'Mechanism_of_Injury'] = 3 x3.loc[x3['Mechanism_of_Injury'] == 'MVT motorcyclist', 'Mechanism_of_Injury'] = 4 x3.loc[x3['Mechanism_of_Injury'] == 'Other transport', 'Mechanism_of_Injury'] = 5 x3.loc[x3['Mechanism_of_Injury'] == 'Other pedal cyclist', 'Mechanism_of_Injury'] = 6 x3.loc[x3['Mechanism_of_Injury'] == 'MVT pedestrian', 'Mechanism_of_Injury'] = 7 x3.loc[x3['Mechanism_of_Injury'] == 'Firearm', 'Mechanism_of_Injury'] = 8 x3.loc[x3['Mechanism_of_Injury'] == 'Other/unknown', 'Mechanism_of_Injury'] = 9 x3.loc[x3['Protective_Device'] == 'None', 'Protective_Device'] = 0 x3.loc[x3['Protective_Device'] == 'Belt', 'Protective_Device'] = 1 x3.loc[x3['Protective_Device'] == 'Airbag present', 'Protective_Device'] = 2 x3.loc[x3['Protective_Device'] == 'Helmet', 'Protective_Device'] = 3 x3.loc[x3['Protective_Device'] == 'Other/unknown', 'Protective_Device'] = 4 x3.loc[x3['WorkRelated'] == 'No/unknown', 'WorkRelated'] = 0 x3.loc[x3['WorkRelated'] == 'Yes', 'WorkRelated'] = 1 x3.loc[x3['Surgical_Intervention'] == 'No', 'Surgical_Intervention'] = 0 x3.loc[x3['Surgical_Intervention'] == 'Yes', 'Surgical_Intervention'] = 1 x3.loc[x3['Alcohol_Screen'] == 'No', 'Alcohol_Screen'] = 0 x3.loc[x3['Alcohol_Screen'] == 'Yes', 'Alcohol_Screen'] = 1 x3.loc[x3['Alcohol_Screen'] == 'Unknown', 'Alcohol_Screen'] = 2 x3.loc[x3['Drug_Screen__Amphetamine'] == 'No', 'Drug_Screen__Amphetamine'] = 0 x3.loc[x3['Drug_Screen__Amphetamine'] == 'Yes', 'Drug_Screen__Amphetamine'] = 1 x3.loc[x3['Drug_Screen__Amphetamine'] == 'Not tested', 'Drug_Screen__Amphetamine'] = 2 x3.loc[x3['Drug_Screen__Barbiturate'] == 'No', 'Drug_Screen__Barbiturate'] = 0 x3.loc[x3['Drug_Screen__Barbiturate'] == 'Yes', 'Drug_Screen__Barbiturate'] = 1 x3.loc[x3['Drug_Screen__Barbiturate'] == 'Not tested', 'Drug_Screen__Barbiturate'] = 2 x3.loc[x3['Drug_Screen__Benzodiazepines'] == 'No', 'Drug_Screen__Benzodiazepines'] = 0 x3.loc[x3['Drug_Screen__Benzodiazepines'] == 'Yes', 'Drug_Screen__Benzodiazepines'] = 1 x3.loc[x3['Drug_Screen__Benzodiazepines'] == 'Not tested', 'Drug_Screen__Benzodiazepines'] = 2 x3.loc[x3['Drug_Screen__Cannabinoid'] == 'No', 'Drug_Screen__Cannabinoid'] = 0 x3.loc[x3['Drug_Screen__Cannabinoid'] == 'Yes', 'Drug_Screen__Cannabinoid'] = 1 x3.loc[x3['Drug_Screen__Cannabinoid'] == 'Not tested', 'Drug_Screen__Cannabinoid'] = 2 x3.loc[x3['Drug_Screen__Cocaine'] == 'No', 'Drug_Screen__Cocaine'] = 0 x3.loc[x3['Drug_Screen__Cocaine'] == 'Yes', 'Drug_Screen__Cocaine'] = 1 x3.loc[x3['Drug_Screen__Cocaine'] == 'Not tested', 'Drug_Screen__Cocaine'] = 2 x3.loc[x3['Drug_Screen__MDMA_or_Ecstasy'] == 'No', 'Drug_Screen__MDMA_or_Ecstasy'] = 0 x3.loc[x3['Drug_Screen__MDMA_or_Ecstasy'] == 'Yes', 'Drug_Screen__MDMA_or_Ecstasy'] = 1 x3.loc[x3['Drug_Screen__MDMA_or_Ecstasy'] == 'Not tested', 'Drug_Screen__MDMA_or_Ecstasy'] = 2 x3.loc[x3['Drug_Screen__Methadone'] == 'No', 'Drug_Screen__Methadone'] = 0 x3.loc[x3['Drug_Screen__Methadone'] == 'Yes', 'Drug_Screen__Methadone'] = 1 x3.loc[x3['Drug_Screen__Methadone'] == 'Not tested', 'Drug_Screen__Methadone'] = 2 x3.loc[x3['Drug_Screen__Methamphetamine'] == 'No', 'Drug_Screen__Methamphetamine'] = 0 x3.loc[x3['Drug_Screen__Methamphetamine'] == 'Yes', 'Drug_Screen__Methamphetamine'] = 1 x3.loc[x3['Drug_Screen__Methamphetamine'] == 'Not tested', 'Drug_Screen__Methamphetamine'] = 2 x3.loc[x3['Drug_Screen__Opioid'] == 'No', 'Drug_Screen__Opioid'] = 0 x3.loc[x3['Drug_Screen__Opioid'] == 'Yes', 'Drug_Screen__Opioid'] = 1 x3.loc[x3['Drug_Screen__Opioid'] == 'Not tested', 'Drug_Screen__Opioid'] = 2 x3.loc[x3['Drug_Screen__Oxycodone'] == 'No', 'Drug_Screen__Oxycodone'] = 0 x3.loc[x3['Drug_Screen__Oxycodone'] == 'Yes', 'Drug_Screen__Oxycodone'] = 1 x3.loc[x3['Drug_Screen__Oxycodone'] == 'Not tested', 'Drug_Screen__Oxycodone'] = 2 x3.loc[x3['Drug_Screen__Phencyclidine'] == 'No', 'Drug_Screen__Phencyclidine'] = 0 x3.loc[x3['Drug_Screen__Phencyclidine'] == 'Yes', 'Drug_Screen__Phencyclidine'] = 1 x3.loc[x3['Drug_Screen__Phencyclidine'] == 'Not tested', 'Drug_Screen__Phencyclidine'] = 2 x3.loc[x3['Drug_Screen__Tricyclic_Antidepressant'] == 'No', 'Drug_Screen__Tricyclic_Antidepressant'] = 0 x3.loc[x3['Drug_Screen__Tricyclic_Antidepressant'] == 'Yes', 'Drug_Screen__Tricyclic_Antidepressant'] = 1 x3.loc[x3['Drug_Screen__Tricyclic_Antidepressant'] == 'Not tested', 'Drug_Screen__Tricyclic_Antidepressant'] = 2 x3.loc[x3['ACS_Verification_Level'] == 'Level I Trauma Center', 'ACS_Verification_Level'] = 0 x3.loc[x3['ACS_Verification_Level'] == 'Level II Trauma Center', 'ACS_Verification_Level'] = 1 x3.loc[x3['ACS_Verification_Level'] == 'Level III Trauma Center', 'ACS_Verification_Level'] = 2 x3.loc[x3['ACS_Verification_Level'] == 'Unknown', 'ACS_Verification_Level'] = 3 x3.loc[x3['Hospital_Type'] == 'Non-profit', 'Hospital_Type'] = 0 x3.loc[x3['Hospital_Type'] == 'For profit', 'Hospital_Type'] = 1 x3.loc[x3['Hospital_Type'] == 'Government', 'Hospital_Type'] = 2 x3.loc[x3['Hospital_Type'] == 'Unknown', 'Hospital_Type'] = 3 x3.loc[x3['Facility_Bed_Size'] == 'More than 600', 'Facility_Bed_Size'] = 0 x3.loc[x3['Facility_Bed_Size'] == '401 to 600', 'Facility_Bed_Size'] = 1 x3.loc[x3['Facility_Bed_Size'] == '201 to 400', 'Facility_Bed_Size'] = 2 x3.loc[x3['Facility_Bed_Size'] == '200 or fewer', 'Facility_Bed_Size'] = 3 x3.loc[x3['Primary_Method_of_Payment'] == 'Medicare', 'Primary_Method_of_Payment'] = 0 x3.loc[x3['Primary_Method_of_Payment'] == 'Private/commercial insurance', 'Primary_Method_of_Payment'] = 1 x3.loc[x3['Primary_Method_of_Payment'] == 'Medicaid', 'Primary_Method_of_Payment'] = 2 x3.loc[x3['Primary_Method_of_Payment'] == 'Self-pay', 'Primary_Method_of_Payment'] = 3 x3.loc[x3['Primary_Method_of_Payment'] == 'Other/unknown', 'Primary_Method_of_Payment'] = 4 #Prepare validation data for the outcome 3 (LOS). y3_valid = x3_valid.pop('OUTCOME') x3_valid.loc[x3_valid['Sex'] == 'Male', 'Sex'] = 0 x3_valid.loc[x3_valid['Sex'] == 'Female', 'Sex'] = 1 x3_valid.loc[x3_valid['Sex'] == 'Non-Binary', 'Sex'] = 2 x3_valid.loc[x3_valid['Sex'] == 'Unknown', 'Sex'] = 3 x3_valid.loc[x3_valid['Race'] == 'White', 'Race'] = 0 x3_valid.loc[x3_valid['Race'] == 'Black', 'Race'] = 1 x3_valid.loc[x3_valid['Race'] == 'Asian', 'Race'] = 2 x3_valid.loc[x3_valid['Race'] == 'Other/unknown', 'Race'] = 5 x3_valid.loc[x3_valid['Ethnicity'] == 'Not Hispanic or Latino', 'Ethnicity'] = 0 x3_valid.loc[x3_valid['Ethnicity'] == 'Hispanic or Latino', 'Ethnicity'] = 1 x3_valid.loc[x3_valid['Ethnicity'] == 'Unknown', 'Ethnicity'] = 2 x3_valid.loc[x3_valid['Supplemental_Oxygen'] == 'No supplemental oxygen', 'Supplemental_Oxygen'] = 0 x3_valid.loc[x3_valid['Supplemental_Oxygen'] == 'Supplemental oxygen', 'Supplemental_Oxygen'] = 1 x3_valid.loc[x3_valid['Supplemental_Oxygen'] == 'Unknown', 'Supplemental_Oxygen'] = 2 x3_valid.loc[x3_valid['Respiratory_Assistance'] == 'Unassisted respiratory rate', 'Respiratory_Assistance'] = 0 x3_valid.loc[x3_valid['Respiratory_Assistance'] == 'Assisted respiratory rate', 'Respiratory_Assistance'] = 1 x3_valid.loc[x3_valid['Respiratory_Assistance'] == 'Unknown', 'Respiratory_Assistance'] = 2 x3_valid.loc[x3_valid['Fracture_of_C1_Vertebra'] == 'No', 'Fracture_of_C1_Vertebra'] = 0 x3_valid.loc[x3_valid['Fracture_of_C1_Vertebra'] == 'Yes', 'Fracture_of_C1_Vertebra'] = 1 x3_valid.loc[x3_valid['Fracture_of_C2_Vertebra'] == 'No', 'Fracture_of_C2_Vertebra'] = 0 x3_valid.loc[x3_valid['Fracture_of_C2_Vertebra'] == 'Yes', 'Fracture_of_C2_Vertebra'] = 1 x3_valid.loc[x3_valid['Fracture_of_C3_Vertebra'] == 'No', 'Fracture_of_C3_Vertebra'] = 0 x3_valid.loc[x3_valid['Fracture_of_C3_Vertebra'] == 'Yes', 'Fracture_of_C3_Vertebra'] = 1 x3_valid.loc[x3_valid['Fracture_of_C4_Vertebra'] == 'No', 'Fracture_of_C4_Vertebra'] = 0 x3_valid.loc[x3_valid['Fracture_of_C4_Vertebra'] == 'Yes', 'Fracture_of_C4_Vertebra'] = 1 x3_valid.loc[x3_valid['Fracture_of_C5_Vertebra'] == 'No', 'Fracture_of_C5_Vertebra'] = 0 x3_valid.loc[x3_valid['Fracture_of_C5_Vertebra'] == 'Yes', 'Fracture_of_C5_Vertebra'] = 1 x3_valid.loc[x3_valid['Fracture_of_C6_Vertebra'] == 'No', 'Fracture_of_C6_Vertebra'] = 0 x3_valid.loc[x3_valid['Fracture_of_C6_Vertebra'] == 'Yes', 'Fracture_of_C6_Vertebra'] = 1 x3_valid.loc[x3_valid['Fracture_of_C7_Vertebra'] == 'No', 'Fracture_of_C7_Vertebra'] = 0 x3_valid.loc[x3_valid['Fracture_of_C7_Vertebra'] == 'Yes', 'Fracture_of_C7_Vertebra'] = 1 x3_valid.loc[x3_valid['Rupture_of_Cervical_Intervertebral_Disc'] == 'No', 'Rupture_of_Cervical_Intervertebral_Disc'] = 0 x3_valid.loc[x3_valid['Rupture_of_Cervical_Intervertebral_Disc'] == 'Yes', 'Rupture_of_Cervical_Intervertebral_Disc'] = 1 x3_valid.loc[x3_valid['Subluxation_and_Dislocation_of_C0/C1_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C0/C1_Vertebrae'] = 0 x3_valid.loc[x3_valid['Subluxation_and_Dislocation_of_C0/C1_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C0/C1_Vertebrae'] = 1 x3_valid.loc[x3_valid['Subluxation_and_Dislocation_of_C1/C2_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C1/C2_Vertebrae'] = 0 x3_valid.loc[x3_valid['Subluxation_and_Dislocation_of_C1/C2_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C1/C2_Vertebrae'] = 1 x3_valid.loc[x3_valid['Subluxation_and_Dislocation_of_C2/C3_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C2/C3_Vertebrae'] = 0 x3_valid.loc[x3_valid['Subluxation_and_Dislocation_of_C2/C3_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C2/C3_Vertebrae'] = 1 x3_valid.loc[x3_valid['Subluxation_and_Dislocation_of_C3/C4_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C3/C4_Vertebrae'] = 0 x3_valid.loc[x3_valid['Subluxation_and_Dislocation_of_C3/C4_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C3/C4_Vertebrae'] = 1 x3_valid.loc[x3_valid['Subluxation_and_Dislocation_of_C4/C5_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C4/C5_Vertebrae'] = 0 x3_valid.loc[x3_valid['Subluxation_and_Dislocation_of_C4/C5_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C4/C5_Vertebrae'] = 1 x3_valid.loc[x3_valid['Subluxation_and_Dislocation_of_C5/C6_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C5/C6_Vertebrae'] = 0 x3_valid.loc[x3_valid['Subluxation_and_Dislocation_of_C5/C6_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C5/C6_Vertebrae'] = 1 x3_valid.loc[x3_valid['Subluxation_and_Dislocation_of_C6/C7_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C6/C7_Vertebrae'] = 0 x3_valid.loc[x3_valid['Subluxation_and_Dislocation_of_C6/C7_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C6/C7_Vertebrae'] = 1 x3_valid.loc[x3_valid['Subluxation_and_Dislocation_of_C7/T1_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C7/T1_Vertebrae'] = 0 x3_valid.loc[x3_valid['Subluxation_and_Dislocation_of_C7/T1_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C7/T1_Vertebrae'] = 1 x3_valid.loc[x3_valid['Concussion_and_Edema_of_cSC'] == 'No', 'Concussion_and_Edema_of_cSC'] = 0 x3_valid.loc[x3_valid['Concussion_and_Edema_of_cSC'] == 'Yes', 'Concussion_and_Edema_of_cSC'] = 1 x3_valid.loc[x3_valid['Complete_Lesion_of_cSC'] == 'No', 'Complete_Lesion_of_cSC'] = 0 x3_valid.loc[x3_valid['Complete_Lesion_of_cSC'] == 'Yes', 'Complete_Lesion_of_cSC'] = 1 x3_valid.loc[x3_valid['Anterior_Cord_Syndrome_of_cSC'] == 'No', 'Anterior_Cord_Syndrome_of_cSC'] = 0 x3_valid.loc[x3_valid['Anterior_Cord_Syndrome_of_cSC'] == 'Yes', 'Anterior_Cord_Syndrome_of_cSC'] = 1 x3_valid.loc[x3_valid['BrownSequard_Syndrome_of_cSC'] == 'No', 'BrownSequard_Syndrome_of_cSC'] = 0 x3_valid.loc[x3_valid['BrownSequard_Syndrome_of_cSC'] == 'Yes', 'BrownSequard_Syndrome_of_cSC'] = 1 x3_valid.loc[x3_valid['Other_Incomplete_Lesions_of_cSC'] == 'No', 'Other_Incomplete_Lesions_of_cSC'] = 0 x3_valid.loc[x3_valid['Other_Incomplete_Lesions_of_cSC'] == 'Yes', 'Other_Incomplete_Lesions_of_cSC'] = 1 x3_valid.loc[x3_valid['Current_Smoker'] == 'No', 'Current_Smoker'] = 0 x3_valid.loc[x3_valid['Current_Smoker'] == 'Yes', 'Current_Smoker'] = 1 x3_valid.loc[x3_valid['Current_Smoker'] == 'Unknown', 'Current_Smoker'] = 2 x3_valid.loc[x3_valid['Alcohol_Use_Disorder'] == 'No', 'Alcohol_Use_Disorder'] = 0 x3_valid.loc[x3_valid['Alcohol_Use_Disorder'] == 'Yes', 'Alcohol_Use_Disorder'] = 1 x3_valid.loc[x3_valid['Alcohol_Use_Disorder'] == 'Unknown', 'Alcohol_Use_Disorder'] = 2 x3_valid.loc[x3_valid['Substance_Abuse_Disorder'] == 'No', 'Substance_Abuse_Disorder'] = 0 x3_valid.loc[x3_valid['Substance_Abuse_Disorder'] == 'Yes', 'Substance_Abuse_Disorder'] = 1 x3_valid.loc[x3_valid['Substance_Abuse_Disorder'] == 'Unknown', 'Substance_Abuse_Disorder'] = 2 x3_valid.loc[x3_valid['Diabetes_Mellitus'] == 'No', 'Diabetes_Mellitus'] = 0 x3_valid.loc[x3_valid['Diabetes_Mellitus'] == 'Yes', 'Diabetes_Mellitus'] = 1 x3_valid.loc[x3_valid['Diabetes_Mellitus'] == 'Unknown', 'Diabetes_Mellitus'] = 2 x3_valid.loc[x3_valid['Hypertension'] == 'No', 'Hypertension'] = 0 x3_valid.loc[x3_valid['Hypertension'] == 'Yes', 'Hypertension'] = 1 x3_valid.loc[x3_valid['Hypertension'] == 'Unknown', 'Hypertension'] = 2 x3_valid.loc[x3_valid['Congestive_Heart_Failure'] == 'No', 'Congestive_Heart_Failure'] = 0 x3_valid.loc[x3_valid['Congestive_Heart_Failure'] == 'Yes', 'Congestive_Heart_Failure'] = 1 x3_valid.loc[x3_valid['Congestive_Heart_Failure'] == 'Unknown', 'Congestive_Heart_Failure'] = 2 x3_valid.loc[x3_valid['History_of_Myocardial_Infarction'] == 'No', 'History_of_Myocardial_Infarction'] = 0 x3_valid.loc[x3_valid['History_of_Myocardial_Infarction'] == 'Yes', 'History_of_Myocardial_Infarction'] = 1 x3_valid.loc[x3_valid['History_of_Myocardial_Infarction'] == 'Unknown', 'History_of_Myocardial_Infarction'] = 2 x3_valid.loc[x3_valid['Angina_Pectoris'] == 'No', 'Angina_Pectoris'] = 0 x3_valid.loc[x3_valid['Angina_Pectoris'] == 'Yes', 'Angina_Pectoris'] = 1 x3_valid.loc[x3_valid['Angina_Pectoris'] == 'Unknown', 'Angina_Pectoris'] = 2 x3_valid.loc[x3_valid['History_of_Cerebrovascular_Accident'] == 'No', 'History_of_Cerebrovascular_Accident'] = 0 x3_valid.loc[x3_valid['History_of_Cerebrovascular_Accident'] == 'Yes', 'History_of_Cerebrovascular_Accident'] = 1 x3_valid.loc[x3_valid['History_of_Cerebrovascular_Accident'] == 'Unknown', 'History_of_Cerebrovascular_Accident'] = 2 x3_valid.loc[x3_valid['Peripheral_Arterial_Disease'] == 'No', 'Peripheral_Arterial_Disease'] = 0 x3_valid.loc[x3_valid['Peripheral_Arterial_Disease'] == 'Yes', 'Peripheral_Arterial_Disease'] = 1 x3_valid.loc[x3_valid['Peripheral_Arterial_Disease'] == 'Unknown', 'Peripheral_Arterial_Disease'] = 2 x3_valid.loc[x3_valid['Chronic_Obstructive_Pulmonary_Disease'] == 'No', 'Chronic_Obstructive_Pulmonary_Disease'] = 0 x3_valid.loc[x3_valid['Chronic_Obstructive_Pulmonary_Disease'] == 'Yes', 'Chronic_Obstructive_Pulmonary_Disease'] = 1 x3_valid.loc[x3_valid['Chronic_Obstructive_Pulmonary_Disease'] == 'Unknown', 'Chronic_Obstructive_Pulmonary_Disease'] = 2 x3_valid.loc[x3_valid['Chronic_Renal_Failure'] == 'No', 'Chronic_Renal_Failure'] = 0 x3_valid.loc[x3_valid['Chronic_Renal_Failure'] == 'Yes', 'Chronic_Renal_Failure'] = 1 x3_valid.loc[x3_valid['Chronic_Renal_Failure'] == 'Unknown', 'Chronic_Renal_Failure'] = 2 x3_valid.loc[x3_valid['Cirrhosis'] == 'No', 'Cirrhosis'] = 0 x3_valid.loc[x3_valid['Cirrhosis'] == 'Yes', 'Cirrhosis'] = 1 x3_valid.loc[x3_valid['Cirrhosis'] == 'Unknown', 'Cirrhosis'] = 2 x3_valid.loc[x3_valid['Bleeding_Disorder'] == 'No', 'Bleeding_Disorder'] = 0 x3_valid.loc[x3_valid['Bleeding_Disorder'] == 'Yes', 'Bleeding_Disorder'] = 1 x3_valid.loc[x3_valid['Bleeding_Disorder'] == 'Unknown', 'Bleeding_Disorder'] = 2 x3_valid.loc[x3_valid['Disseminated_Cancer'] == 'No', 'Disseminated_Cancer'] = 0 x3_valid.loc[x3_valid['Disseminated_Cancer'] == 'Yes', 'Disseminated_Cancer'] = 1 x3_valid.loc[x3_valid['Disseminated_Cancer'] == 'Unknown', 'Disseminated_Cancer'] = 2 x3_valid.loc[x3_valid['Currently_Receiving_Chemotherapy_for_Cancer'] == 'No', 'Currently_Receiving_Chemotherapy_for_Cancer'] = 0 x3_valid.loc[x3_valid['Currently_Receiving_Chemotherapy_for_Cancer'] == 'Yes', 'Currently_Receiving_Chemotherapy_for_Cancer'] = 1 x3_valid.loc[x3_valid['Currently_Receiving_Chemotherapy_for_Cancer'] == 'Unknown', 'Currently_Receiving_Chemotherapy_for_Cancer'] = 2 x3_valid.loc[x3_valid['Dementia'] == 'No', 'Dementia'] = 0 x3_valid.loc[x3_valid['Dementia'] == 'Yes', 'Dementia'] = 1 x3_valid.loc[x3_valid['Dementia'] == 'Unknown', 'Dementia'] = 2 x3_valid.loc[x3_valid['Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder'] == 'No', 'Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder'] = 0 x3_valid.loc[x3_valid['Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder'] == 'Yes', 'Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder'] = 1 x3_valid.loc[x3_valid['Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder'] == 'Unknown', 'Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder'] = 2 x3_valid.loc[x3_valid['Mental_or_Personality_Disorder'] == 'No', 'Mental_or_Personality_Disorder'] = 0 x3_valid.loc[x3_valid['Mental_or_Personality_Disorder'] == 'Yes', 'Mental_or_Personality_Disorder'] = 1 x3_valid.loc[x3_valid['Mental_or_Personality_Disorder'] == 'Unknown', 'Mental_or_Personality_Disorder'] = 2 x3_valid.loc[x3_valid['Ability_to_Complete_AgeAppropriate_ADL'] == 'No', 'Ability_to_Complete_AgeAppropriate_ADL'] = 0 x3_valid.loc[x3_valid['Ability_to_Complete_AgeAppropriate_ADL'] == 'Yes', 'Ability_to_Complete_AgeAppropriate_ADL'] = 1 x3_valid.loc[x3_valid['Ability_to_Complete_AgeAppropriate_ADL'] == 'Unknown', 'Ability_to_Complete_AgeAppropriate_ADL'] = 2 x3_valid.loc[x3_valid['Pregnancy'] == 'Not applicable (male patient)', 'Pregnancy'] = 0 x3_valid.loc[x3_valid['Pregnancy'] == 'No', 'Pregnancy'] = 1 x3_valid.loc[x3_valid['Pregnancy'] == 'Yes', 'Pregnancy'] = 2 x3_valid.loc[x3_valid['Pregnancy'] == 'Unkown', 'Pregnancy'] = 3 x3_valid.loc[x3_valid['Anticoagulant_Therapy'] == 'No', 'Anticoagulant_Therapy'] = 0 x3_valid.loc[x3_valid['Anticoagulant_Therapy'] == 'Yes', 'Anticoagulant_Therapy'] = 1 x3_valid.loc[x3_valid['Anticoagulant_Therapy'] == 'Unknown', 'Anticoagulant_Therapy'] = 2 x3_valid.loc[x3_valid['Steroid_Use'] == 'No', 'Steroid_Use'] = 0 x3_valid.loc[x3_valid['Steroid_Use'] == 'Yes', 'Steroid_Use'] = 1 x3_valid.loc[x3_valid['Steroid_Use'] == 'Unknown', 'Steroid_Use'] = 2 x3_valid.loc[x3_valid['Transport_Mode'] == 'Ground ambulance', 'Transport_Mode'] = 0 x3_valid.loc[x3_valid['Transport_Mode'] == 'Private/public vehicle/walk-in', 'Transport_Mode'] = 1 x3_valid.loc[x3_valid['Transport_Mode'] == 'Air ambulance', 'Transport_Mode'] = 2 x3_valid.loc[x3_valid['Transport_Mode'] == 'Other/unknown', 'Transport_Mode'] = 3 x3_valid.loc[x3_valid['InterFacility_Transfer'] == 'No', 'InterFacility_Transfer'] = 0 x3_valid.loc[x3_valid['InterFacility_Transfer'] == 'Yes', 'InterFacility_Transfer'] = 1 x3_valid.loc[x3_valid['InterFacility_Transfer'] == 'Unknown', 'InterFacility_Transfer'] = 2 x3_valid.loc[x3_valid['Trauma_Type'] == 'Blunt', 'Trauma_Type'] = 0 x3_valid.loc[x3_valid['Trauma_Type'] == 'Penetrating', 'Trauma_Type'] = 1 x3_valid.loc[x3_valid['Trauma_Type'] == 'Other/unknown', 'Trauma_Type'] = 2 x3_valid.loc[x3_valid['Injury_Intent'] == 'Unintentional', 'Injury_Intent'] = 0 x3_valid.loc[x3_valid['Injury_Intent'] == 'Assault', 'Injury_Intent'] = 1 x3_valid.loc[x3_valid['Injury_Intent'] == 'Other/unknown', 'Injury_Intent'] = 2 x3_valid.loc[x3_valid['Mechanism_of_Injury'] == 'Fall', 'Mechanism_of_Injury'] = 0 x3_valid.loc[x3_valid['Mechanism_of_Injury'] == 'MVT occupant', 'Mechanism_of_Injury'] = 1 x3_valid.loc[x3_valid['Mechanism_of_Injury'] == 'Struck by or against', 'Mechanism_of_Injury'] = 2 x3_valid.loc[x3_valid['Mechanism_of_Injury'] == 'Other MVT', 'Mechanism_of_Injury'] = 3 x3_valid.loc[x3_valid['Mechanism_of_Injury'] == 'MVT motorcyclist', 'Mechanism_of_Injury'] = 4 x3_valid.loc[x3_valid['Mechanism_of_Injury'] == 'Other transport', 'Mechanism_of_Injury'] = 5 x3_valid.loc[x3_valid['Mechanism_of_Injury'] == 'Other pedal cyclist', 'Mechanism_of_Injury'] = 6 x3_valid.loc[x3_valid['Mechanism_of_Injury'] == 'MVT pedestrian', 'Mechanism_of_Injury'] = 7 x3_valid.loc[x3_valid['Mechanism_of_Injury'] == 'Firearm', 'Mechanism_of_Injury'] = 8 x3_valid.loc[x3_valid['Mechanism_of_Injury'] == 'Other/unknown', 'Mechanism_of_Injury'] = 9 x3_valid.loc[x3_valid['Protective_Device'] == 'None', 'Protective_Device'] = 0 x3_valid.loc[x3_valid['Protective_Device'] == 'Belt', 'Protective_Device'] = 1 x3_valid.loc[x3_valid['Protective_Device'] == 'Airbag present', 'Protective_Device'] = 2 x3_valid.loc[x3_valid['Protective_Device'] == 'Helmet', 'Protective_Device'] = 3 x3_valid.loc[x3_valid['Protective_Device'] == 'Other/unknown', 'Protective_Device'] = 4 x3_valid.loc[x3_valid['WorkRelated'] == 'No/unknown', 'WorkRelated'] = 0 x3_valid.loc[x3_valid['WorkRelated'] == 'Yes', 'WorkRelated'] = 1 x3_valid.loc[x3_valid['Surgical_Intervention'] == 'No', 'Surgical_Intervention'] = 0 x3_valid.loc[x3_valid['Surgical_Intervention'] == 'Yes', 'Surgical_Intervention'] = 1 x3_valid.loc[x3_valid['Alcohol_Screen'] == 'No', 'Alcohol_Screen'] = 0 x3_valid.loc[x3_valid['Alcohol_Screen'] == 'Yes', 'Alcohol_Screen'] = 1 x3_valid.loc[x3_valid['Alcohol_Screen'] == 'Unknown', 'Alcohol_Screen'] = 2 x3_valid.loc[x3_valid['Drug_Screen__Amphetamine'] == 'No', 'Drug_Screen__Amphetamine'] = 0 x3_valid.loc[x3_valid['Drug_Screen__Amphetamine'] == 'Yes', 'Drug_Screen__Amphetamine'] = 1 x3_valid.loc[x3_valid['Drug_Screen__Amphetamine'] == 'Not tested', 'Drug_Screen__Amphetamine'] = 2 x3_valid.loc[x3_valid['Drug_Screen__Barbiturate'] == 'No', 'Drug_Screen__Barbiturate'] = 0 x3_valid.loc[x3_valid['Drug_Screen__Barbiturate'] == 'Yes', 'Drug_Screen__Barbiturate'] = 1 x3_valid.loc[x3_valid['Drug_Screen__Barbiturate'] == 'Not tested', 'Drug_Screen__Barbiturate'] = 2 x3_valid.loc[x3_valid['Drug_Screen__Benzodiazepines'] == 'No', 'Drug_Screen__Benzodiazepines'] = 0 x3_valid.loc[x3_valid['Drug_Screen__Benzodiazepines'] == 'Yes', 'Drug_Screen__Benzodiazepines'] = 1 x3_valid.loc[x3_valid['Drug_Screen__Benzodiazepines'] == 'Not tested', 'Drug_Screen__Benzodiazepines'] = 2 x3_valid.loc[x3_valid['Drug_Screen__Cannabinoid'] == 'No', 'Drug_Screen__Cannabinoid'] = 0 x3_valid.loc[x3_valid['Drug_Screen__Cannabinoid'] == 'Yes', 'Drug_Screen__Cannabinoid'] = 1 x3_valid.loc[x3_valid['Drug_Screen__Cannabinoid'] == 'Not tested', 'Drug_Screen__Cannabinoid'] = 2 x3_valid.loc[x3_valid['Drug_Screen__Cocaine'] == 'No', 'Drug_Screen__Cocaine'] = 0 x3_valid.loc[x3_valid['Drug_Screen__Cocaine'] == 'Yes', 'Drug_Screen__Cocaine'] = 1 x3_valid.loc[x3_valid['Drug_Screen__Cocaine'] == 'Not tested', 'Drug_Screen__Cocaine'] = 2 x3_valid.loc[x3_valid['Drug_Screen__MDMA_or_Ecstasy'] == 'No', 'Drug_Screen__MDMA_or_Ecstasy'] = 0 x3_valid.loc[x3_valid['Drug_Screen__MDMA_or_Ecstasy'] == 'Yes', 'Drug_Screen__MDMA_or_Ecstasy'] = 1 x3_valid.loc[x3_valid['Drug_Screen__MDMA_or_Ecstasy'] == 'Not tested', 'Drug_Screen__MDMA_or_Ecstasy'] = 2 x3_valid.loc[x3_valid['Drug_Screen__Methadone'] == 'No', 'Drug_Screen__Methadone'] = 0 x3_valid.loc[x3_valid['Drug_Screen__Methadone'] == 'Yes', 'Drug_Screen__Methadone'] = 1 x3_valid.loc[x3_valid['Drug_Screen__Methadone'] == 'Not tested', 'Drug_Screen__Methadone'] = 2 x3_valid.loc[x3_valid['Drug_Screen__Methamphetamine'] == 'No', 'Drug_Screen__Methamphetamine'] = 0 x3_valid.loc[x3_valid['Drug_Screen__Methamphetamine'] == 'Yes', 'Drug_Screen__Methamphetamine'] = 1 x3_valid.loc[x3_valid['Drug_Screen__Methamphetamine'] == 'Not tested', 'Drug_Screen__Methamphetamine'] = 2 x3_valid.loc[x3_valid['Drug_Screen__Opioid'] == 'No', 'Drug_Screen__Opioid'] = 0 x3_valid.loc[x3_valid['Drug_Screen__Opioid'] == 'Yes', 'Drug_Screen__Opioid'] = 1 x3_valid.loc[x3_valid['Drug_Screen__Opioid'] == 'Not tested', 'Drug_Screen__Opioid'] = 2 x3_valid.loc[x3_valid['Drug_Screen__Oxycodone'] == 'No', 'Drug_Screen__Oxycodone'] = 0 x3_valid.loc[x3_valid['Drug_Screen__Oxycodone'] == 'Yes', 'Drug_Screen__Oxycodone'] = 1 x3_valid.loc[x3_valid['Drug_Screen__Oxycodone'] == 'Not tested', 'Drug_Screen__Oxycodone'] = 2 x3_valid.loc[x3_valid['Drug_Screen__Phencyclidine'] == 'No', 'Drug_Screen__Phencyclidine'] = 0 x3_valid.loc[x3_valid['Drug_Screen__Phencyclidine'] == 'Yes', 'Drug_Screen__Phencyclidine'] = 1 x3_valid.loc[x3_valid['Drug_Screen__Phencyclidine'] == 'Not tested', 'Drug_Screen__Phencyclidine'] = 2 x3_valid.loc[x3_valid['Drug_Screen__Tricyclic_Antidepressant'] == 'No', 'Drug_Screen__Tricyclic_Antidepressant'] = 0 x3_valid.loc[x3_valid['Drug_Screen__Tricyclic_Antidepressant'] == 'Yes', 'Drug_Screen__Tricyclic_Antidepressant'] = 1 x3_valid.loc[x3_valid['Drug_Screen__Tricyclic_Antidepressant'] == 'Not tested', 'Drug_Screen__Tricyclic_Antidepressant'] = 2 x3_valid.loc[x3_valid['ACS_Verification_Level'] == 'Level I Trauma Center', 'ACS_Verification_Level'] = 0 x3_valid.loc[x3_valid['ACS_Verification_Level'] == 'Level II Trauma Center', 'ACS_Verification_Level'] = 1 x3_valid.loc[x3_valid['ACS_Verification_Level'] == 'Level III Trauma Center', 'ACS_Verification_Level'] = 2 x3_valid.loc[x3_valid['ACS_Verification_Level'] == 'Unknown', 'ACS_Verification_Level'] = 3 x3_valid.loc[x3_valid['Hospital_Type'] == 'Non-profit', 'Hospital_Type'] = 0 x3_valid.loc[x3_valid['Hospital_Type'] == 'For profit', 'Hospital_Type'] = 1 x3_valid.loc[x3_valid['Hospital_Type'] == 'Government', 'Hospital_Type'] = 2 x3_valid.loc[x3_valid['Hospital_Type'] == 'Unknown', 'Hospital_Type'] = 3 x3_valid.loc[x3_valid['Facility_Bed_Size'] == 'More than 600', 'Facility_Bed_Size'] = 0 x3_valid.loc[x3_valid['Facility_Bed_Size'] == '401 to 600', 'Facility_Bed_Size'] = 1 x3_valid.loc[x3_valid['Facility_Bed_Size'] == '201 to 400', 'Facility_Bed_Size'] = 2 x3_valid.loc[x3_valid['Facility_Bed_Size'] == '200 or fewer', 'Facility_Bed_Size'] = 3 x3_valid.loc[x3_valid['Primary_Method_of_Payment'] == 'Medicare', 'Primary_Method_of_Payment'] = 0 x3_valid.loc[x3_valid['Primary_Method_of_Payment'] == 'Private/commercial insurance', 'Primary_Method_of_Payment'] = 1 x3_valid.loc[x3_valid['Primary_Method_of_Payment'] == 'Medicaid', 'Primary_Method_of_Payment'] = 2 x3_valid.loc[x3_valid['Primary_Method_of_Payment'] == 'Self-pay', 'Primary_Method_of_Payment'] = 3 x3_valid.loc[x3_valid['Primary_Method_of_Payment'] == 'Other/unknown', 'Primary_Method_of_Payment'] = 4 #Prepare training data for the outcome 4 (ICU-LOS). y4 = x4.pop('OUTCOME') x4.loc[x4['Sex'] == 'Male', 'Sex'] = 0 x4.loc[x4['Sex'] == 'Female', 'Sex'] = 1 x4.loc[x4['Sex'] == 'Non-Binary', 'Sex'] = 2 x4.loc[x4['Sex'] == 'Unknown', 'Sex'] = 3 x4.loc[x4['Race'] == 'White', 'Race'] = 0 x4.loc[x4['Race'] == 'Black', 'Race'] = 1 x4.loc[x4['Race'] == 'Asian', 'Race'] = 2 x4.loc[x4['Race'] == 'Other/unknown', 'Race'] = 5 x4.loc[x4['Ethnicity'] == 'Not Hispanic or Latino', 'Ethnicity'] = 0 x4.loc[x4['Ethnicity'] == 'Hispanic or Latino', 'Ethnicity'] = 1 x4.loc[x4['Ethnicity'] == 'Unknown', 'Ethnicity'] = 2 x4.loc[x4['Supplemental_Oxygen'] == 'No supplemental oxygen', 'Supplemental_Oxygen'] = 0 x4.loc[x4['Supplemental_Oxygen'] == 'Supplemental oxygen', 'Supplemental_Oxygen'] = 1 x4.loc[x4['Supplemental_Oxygen'] == 'Unknown', 'Supplemental_Oxygen'] = 2 x4.loc[x4['Respiratory_Assistance'] == 'Unassisted respiratory rate', 'Respiratory_Assistance'] = 0 x4.loc[x4['Respiratory_Assistance'] == 'Assisted respiratory rate', 'Respiratory_Assistance'] = 1 x4.loc[x4['Respiratory_Assistance'] == 'Unknown', 'Respiratory_Assistance'] = 2 x4.loc[x4['Fracture_of_C1_Vertebra'] == 'No', 'Fracture_of_C1_Vertebra'] = 0 x4.loc[x4['Fracture_of_C1_Vertebra'] == 'Yes', 'Fracture_of_C1_Vertebra'] = 1 x4.loc[x4['Fracture_of_C2_Vertebra'] == 'No', 'Fracture_of_C2_Vertebra'] = 0 x4.loc[x4['Fracture_of_C2_Vertebra'] == 'Yes', 'Fracture_of_C2_Vertebra'] = 1 x4.loc[x4['Fracture_of_C3_Vertebra'] == 'No', 'Fracture_of_C3_Vertebra'] = 0 x4.loc[x4['Fracture_of_C3_Vertebra'] == 'Yes', 'Fracture_of_C3_Vertebra'] = 1 x4.loc[x4['Fracture_of_C4_Vertebra'] == 'No', 'Fracture_of_C4_Vertebra'] = 0 x4.loc[x4['Fracture_of_C4_Vertebra'] == 'Yes', 'Fracture_of_C4_Vertebra'] = 1 x4.loc[x4['Fracture_of_C5_Vertebra'] == 'No', 'Fracture_of_C5_Vertebra'] = 0 x4.loc[x4['Fracture_of_C5_Vertebra'] == 'Yes', 'Fracture_of_C5_Vertebra'] = 1 x4.loc[x4['Fracture_of_C6_Vertebra'] == 'No', 'Fracture_of_C6_Vertebra'] = 0 x4.loc[x4['Fracture_of_C6_Vertebra'] == 'Yes', 'Fracture_of_C6_Vertebra'] = 1 x4.loc[x4['Fracture_of_C7_Vertebra'] == 'No', 'Fracture_of_C7_Vertebra'] = 0 x4.loc[x4['Fracture_of_C7_Vertebra'] == 'Yes', 'Fracture_of_C7_Vertebra'] = 1 x4.loc[x4['Rupture_of_Cervical_Intervertebral_Disc'] == 'No', 'Rupture_of_Cervical_Intervertebral_Disc'] = 0 x4.loc[x4['Rupture_of_Cervical_Intervertebral_Disc'] == 'Yes', 'Rupture_of_Cervical_Intervertebral_Disc'] = 1 x4.loc[x4['Subluxation_and_Dislocation_of_C0/C1_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C0/C1_Vertebrae'] = 0 x4.loc[x4['Subluxation_and_Dislocation_of_C0/C1_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C0/C1_Vertebrae'] = 1 x4.loc[x4['Subluxation_and_Dislocation_of_C1/C2_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C1/C2_Vertebrae'] = 0 x4.loc[x4['Subluxation_and_Dislocation_of_C1/C2_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C1/C2_Vertebrae'] = 1 x4.loc[x4['Subluxation_and_Dislocation_of_C2/C3_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C2/C3_Vertebrae'] = 0 x4.loc[x4['Subluxation_and_Dislocation_of_C2/C3_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C2/C3_Vertebrae'] = 1 x4.loc[x4['Subluxation_and_Dislocation_of_C3/C4_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C3/C4_Vertebrae'] = 0 x4.loc[x4['Subluxation_and_Dislocation_of_C3/C4_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C3/C4_Vertebrae'] = 1 x4.loc[x4['Subluxation_and_Dislocation_of_C4/C5_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C4/C5_Vertebrae'] = 0 x4.loc[x4['Subluxation_and_Dislocation_of_C4/C5_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C4/C5_Vertebrae'] = 1 x4.loc[x4['Subluxation_and_Dislocation_of_C5/C6_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C5/C6_Vertebrae'] = 0 x4.loc[x4['Subluxation_and_Dislocation_of_C5/C6_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C5/C6_Vertebrae'] = 1 x4.loc[x4['Subluxation_and_Dislocation_of_C6/C7_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C6/C7_Vertebrae'] = 0 x4.loc[x4['Subluxation_and_Dislocation_of_C6/C7_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C6/C7_Vertebrae'] = 1 x4.loc[x4['Subluxation_and_Dislocation_of_C7/T1_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C7/T1_Vertebrae'] = 0 x4.loc[x4['Subluxation_and_Dislocation_of_C7/T1_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C7/T1_Vertebrae'] = 1 x4.loc[x4['Concussion_and_Edema_of_cSC'] == 'No', 'Concussion_and_Edema_of_cSC'] = 0 x4.loc[x4['Concussion_and_Edema_of_cSC'] == 'Yes', 'Concussion_and_Edema_of_cSC'] = 1 x4.loc[x4['Complete_Lesion_of_cSC'] == 'No', 'Complete_Lesion_of_cSC'] = 0 x4.loc[x4['Complete_Lesion_of_cSC'] == 'Yes', 'Complete_Lesion_of_cSC'] = 1 x4.loc[x4['Anterior_Cord_Syndrome_of_cSC'] == 'No', 'Anterior_Cord_Syndrome_of_cSC'] = 0 x4.loc[x4['Anterior_Cord_Syndrome_of_cSC'] == 'Yes', 'Anterior_Cord_Syndrome_of_cSC'] = 1 x4.loc[x4['BrownSequard_Syndrome_of_cSC'] == 'No', 'BrownSequard_Syndrome_of_cSC'] = 0 x4.loc[x4['BrownSequard_Syndrome_of_cSC'] == 'Yes', 'BrownSequard_Syndrome_of_cSC'] = 1 x4.loc[x4['Other_Incomplete_Lesions_of_cSC'] == 'No', 'Other_Incomplete_Lesions_of_cSC'] = 0 x4.loc[x4['Other_Incomplete_Lesions_of_cSC'] == 'Yes', 'Other_Incomplete_Lesions_of_cSC'] = 1 x4.loc[x4['Current_Smoker'] == 'No', 'Current_Smoker'] = 0 x4.loc[x4['Current_Smoker'] == 'Yes', 'Current_Smoker'] = 1 x4.loc[x4['Current_Smoker'] == 'Unknown', 'Current_Smoker'] = 2 x4.loc[x4['Alcohol_Use_Disorder'] == 'No', 'Alcohol_Use_Disorder'] = 0 x4.loc[x4['Alcohol_Use_Disorder'] == 'Yes', 'Alcohol_Use_Disorder'] = 1 x4.loc[x4['Alcohol_Use_Disorder'] == 'Unknown', 'Alcohol_Use_Disorder'] = 2 x4.loc[x4['Substance_Abuse_Disorder'] == 'No', 'Substance_Abuse_Disorder'] = 0 x4.loc[x4['Substance_Abuse_Disorder'] == 'Yes', 'Substance_Abuse_Disorder'] = 1 x4.loc[x4['Substance_Abuse_Disorder'] == 'Unknown', 'Substance_Abuse_Disorder'] = 2 x4.loc[x4['Diabetes_Mellitus'] == 'No', 'Diabetes_Mellitus'] = 0 x4.loc[x4['Diabetes_Mellitus'] == 'Yes', 'Diabetes_Mellitus'] = 1 x4.loc[x4['Diabetes_Mellitus'] == 'Unknown', 'Diabetes_Mellitus'] = 2 x4.loc[x4['Hypertension'] == 'No', 'Hypertension'] = 0 x4.loc[x4['Hypertension'] == 'Yes', 'Hypertension'] = 1 x4.loc[x4['Hypertension'] == 'Unknown', 'Hypertension'] = 2 x4.loc[x4['Congestive_Heart_Failure'] == 'No', 'Congestive_Heart_Failure'] = 0 x4.loc[x4['Congestive_Heart_Failure'] == 'Yes', 'Congestive_Heart_Failure'] = 1 x4.loc[x4['Congestive_Heart_Failure'] == 'Unknown', 'Congestive_Heart_Failure'] = 2 x4.loc[x4['History_of_Myocardial_Infarction'] == 'No', 'History_of_Myocardial_Infarction'] = 0 x4.loc[x4['History_of_Myocardial_Infarction'] == 'Yes', 'History_of_Myocardial_Infarction'] = 1 x4.loc[x4['History_of_Myocardial_Infarction'] == 'Unknown', 'History_of_Myocardial_Infarction'] = 2 x4.loc[x4['Angina_Pectoris'] == 'No', 'Angina_Pectoris'] = 0 x4.loc[x4['Angina_Pectoris'] == 'Yes', 'Angina_Pectoris'] = 1 x4.loc[x4['Angina_Pectoris'] == 'Unknown', 'Angina_Pectoris'] = 2 x4.loc[x4['History_of_Cerebrovascular_Accident'] == 'No', 'History_of_Cerebrovascular_Accident'] = 0 x4.loc[x4['History_of_Cerebrovascular_Accident'] == 'Yes', 'History_of_Cerebrovascular_Accident'] = 1 x4.loc[x4['History_of_Cerebrovascular_Accident'] == 'Unknown', 'History_of_Cerebrovascular_Accident'] = 2 x4.loc[x4['Peripheral_Arterial_Disease'] == 'No', 'Peripheral_Arterial_Disease'] = 0 x4.loc[x4['Peripheral_Arterial_Disease'] == 'Yes', 'Peripheral_Arterial_Disease'] = 1 x4.loc[x4['Peripheral_Arterial_Disease'] == 'Unknown', 'Peripheral_Arterial_Disease'] = 2 x4.loc[x4['Chronic_Obstructive_Pulmonary_Disease'] == 'No', 'Chronic_Obstructive_Pulmonary_Disease'] = 0 x4.loc[x4['Chronic_Obstructive_Pulmonary_Disease'] == 'Yes', 'Chronic_Obstructive_Pulmonary_Disease'] = 1 x4.loc[x4['Chronic_Obstructive_Pulmonary_Disease'] == 'Unknown', 'Chronic_Obstructive_Pulmonary_Disease'] = 2 x4.loc[x4['Chronic_Renal_Failure'] == 'No', 'Chronic_Renal_Failure'] = 0 x4.loc[x4['Chronic_Renal_Failure'] == 'Yes', 'Chronic_Renal_Failure'] = 1 x4.loc[x4['Chronic_Renal_Failure'] == 'Unknown', 'Chronic_Renal_Failure'] = 2 x4.loc[x4['Cirrhosis'] == 'No', 'Cirrhosis'] = 0 x4.loc[x4['Cirrhosis'] == 'Yes', 'Cirrhosis'] = 1 x4.loc[x4['Cirrhosis'] == 'Unknown', 'Cirrhosis'] = 2 x4.loc[x4['Bleeding_Disorder'] == 'No', 'Bleeding_Disorder'] = 0 x4.loc[x4['Bleeding_Disorder'] == 'Yes', 'Bleeding_Disorder'] = 1 x4.loc[x4['Bleeding_Disorder'] == 'Unknown', 'Bleeding_Disorder'] = 2 x4.loc[x4['Disseminated_Cancer'] == 'No', 'Disseminated_Cancer'] = 0 x4.loc[x4['Disseminated_Cancer'] == 'Yes', 'Disseminated_Cancer'] = 1 x4.loc[x4['Disseminated_Cancer'] == 'Unknown', 'Disseminated_Cancer'] = 2 x4.loc[x4['Currently_Receiving_Chemotherapy_for_Cancer'] == 'No', 'Currently_Receiving_Chemotherapy_for_Cancer'] = 0 x4.loc[x4['Currently_Receiving_Chemotherapy_for_Cancer'] == 'Yes', 'Currently_Receiving_Chemotherapy_for_Cancer'] = 1 x4.loc[x4['Currently_Receiving_Chemotherapy_for_Cancer'] == 'Unknown', 'Currently_Receiving_Chemotherapy_for_Cancer'] = 2 x4.loc[x4['Dementia'] == 'No', 'Dementia'] = 0 x4.loc[x4['Dementia'] == 'Yes', 'Dementia'] = 1 x4.loc[x4['Dementia'] == 'Unknown', 'Dementia'] = 2 x4.loc[x4['Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder'] == 'No', 'Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder'] = 0 x4.loc[x4['Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder'] == 'Yes', 'Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder'] = 1 x4.loc[x4['Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder'] == 'Unknown', 'Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder'] = 2 x4.loc[x4['Mental_or_Personality_Disorder'] == 'No', 'Mental_or_Personality_Disorder'] = 0 x4.loc[x4['Mental_or_Personality_Disorder'] == 'Yes', 'Mental_or_Personality_Disorder'] = 1 x4.loc[x4['Mental_or_Personality_Disorder'] == 'Unknown', 'Mental_or_Personality_Disorder'] = 2 x4.loc[x4['Ability_to_Complete_AgeAppropriate_ADL'] == 'No', 'Ability_to_Complete_AgeAppropriate_ADL'] = 0 x4.loc[x4['Ability_to_Complete_AgeAppropriate_ADL'] == 'Yes', 'Ability_to_Complete_AgeAppropriate_ADL'] = 1 x4.loc[x4['Ability_to_Complete_AgeAppropriate_ADL'] == 'Unknown', 'Ability_to_Complete_AgeAppropriate_ADL'] = 2 x4.loc[x4['Pregnancy'] == 'Not applicable (male patient)', 'Pregnancy'] = 0 x4.loc[x4['Pregnancy'] == 'No', 'Pregnancy'] = 1 x4.loc[x4['Pregnancy'] == 'Yes', 'Pregnancy'] = 2 x4.loc[x4['Pregnancy'] == 'Unkown', 'Pregnancy'] = 3 x4.loc[x4['Anticoagulant_Therapy'] == 'No', 'Anticoagulant_Therapy'] = 0 x4.loc[x4['Anticoagulant_Therapy'] == 'Yes', 'Anticoagulant_Therapy'] = 1 x4.loc[x4['Anticoagulant_Therapy'] == 'Unknown', 'Anticoagulant_Therapy'] = 2 x4.loc[x4['Steroid_Use'] == 'No', 'Steroid_Use'] = 0 x4.loc[x4['Steroid_Use'] == 'Yes', 'Steroid_Use'] = 1 x4.loc[x4['Steroid_Use'] == 'Unknown', 'Steroid_Use'] = 2 x4.loc[x4['Transport_Mode'] == 'Ground ambulance', 'Transport_Mode'] = 0 x4.loc[x4['Transport_Mode'] == 'Private/public vehicle/walk-in', 'Transport_Mode'] = 1 x4.loc[x4['Transport_Mode'] == 'Air ambulance', 'Transport_Mode'] = 2 x4.loc[x4['Transport_Mode'] == 'Other/unknown', 'Transport_Mode'] = 3 x4.loc[x4['InterFacility_Transfer'] == 'No', 'InterFacility_Transfer'] = 0 x4.loc[x4['InterFacility_Transfer'] == 'Yes', 'InterFacility_Transfer'] = 1 x4.loc[x4['InterFacility_Transfer'] == 'Unknown', 'InterFacility_Transfer'] = 2 x4.loc[x4['Trauma_Type'] == 'Blunt', 'Trauma_Type'] = 0 x4.loc[x4['Trauma_Type'] == 'Penetrating', 'Trauma_Type'] = 1 x4.loc[x4['Trauma_Type'] == 'Other/unknown', 'Trauma_Type'] = 2 x4.loc[x4['Injury_Intent'] == 'Unintentional', 'Injury_Intent'] = 0 x4.loc[x4['Injury_Intent'] == 'Assault', 'Injury_Intent'] = 1 x4.loc[x4['Injury_Intent'] == 'Other/unknown', 'Injury_Intent'] = 2 x4.loc[x4['Mechanism_of_Injury'] == 'Fall', 'Mechanism_of_Injury'] = 0 x4.loc[x4['Mechanism_of_Injury'] == 'MVT occupant', 'Mechanism_of_Injury'] = 1 x4.loc[x4['Mechanism_of_Injury'] == 'Struck by or against', 'Mechanism_of_Injury'] = 2 x4.loc[x4['Mechanism_of_Injury'] == 'Other MVT', 'Mechanism_of_Injury'] = 3 x4.loc[x4['Mechanism_of_Injury'] == 'MVT motorcyclist', 'Mechanism_of_Injury'] = 4 x4.loc[x4['Mechanism_of_Injury'] == 'Other transport', 'Mechanism_of_Injury'] = 5 x4.loc[x4['Mechanism_of_Injury'] == 'Other pedal cyclist', 'Mechanism_of_Injury'] = 6 x4.loc[x4['Mechanism_of_Injury'] == 'MVT pedestrian', 'Mechanism_of_Injury'] = 7 x4.loc[x4['Mechanism_of_Injury'] == 'Firearm', 'Mechanism_of_Injury'] = 8 x4.loc[x4['Mechanism_of_Injury'] == 'Other/unknown', 'Mechanism_of_Injury'] = 9 x4.loc[x4['Protective_Device'] == 'None', 'Protective_Device'] = 0 x4.loc[x4['Protective_Device'] == 'Belt', 'Protective_Device'] = 1 x4.loc[x4['Protective_Device'] == 'Airbag present', 'Protective_Device'] = 2 x4.loc[x4['Protective_Device'] == 'Helmet', 'Protective_Device'] = 3 x4.loc[x4['Protective_Device'] == 'Other/unknown', 'Protective_Device'] = 4 x4.loc[x4['WorkRelated'] == 'No/unknown', 'WorkRelated'] = 0 x4.loc[x4['WorkRelated'] == 'Yes', 'WorkRelated'] = 1 x4.loc[x4['Surgical_Intervention'] == 'No', 'Surgical_Intervention'] = 0 x4.loc[x4['Surgical_Intervention'] == 'Yes', 'Surgical_Intervention'] = 1 x4.loc[x4['Alcohol_Screen'] == 'No', 'Alcohol_Screen'] = 0 x4.loc[x4['Alcohol_Screen'] == 'Yes', 'Alcohol_Screen'] = 1 x4.loc[x4['Alcohol_Screen'] == 'Unknown', 'Alcohol_Screen'] = 2 x4.loc[x4['Drug_Screen__Amphetamine'] == 'No', 'Drug_Screen__Amphetamine'] = 0 x4.loc[x4['Drug_Screen__Amphetamine'] == 'Yes', 'Drug_Screen__Amphetamine'] = 1 x4.loc[x4['Drug_Screen__Amphetamine'] == 'Not tested', 'Drug_Screen__Amphetamine'] = 2 x4.loc[x4['Drug_Screen__Barbiturate'] == 'No', 'Drug_Screen__Barbiturate'] = 0 x4.loc[x4['Drug_Screen__Barbiturate'] == 'Yes', 'Drug_Screen__Barbiturate'] = 1 x4.loc[x4['Drug_Screen__Barbiturate'] == 'Not tested', 'Drug_Screen__Barbiturate'] = 2 x4.loc[x4['Drug_Screen__Benzodiazepines'] == 'No', 'Drug_Screen__Benzodiazepines'] = 0 x4.loc[x4['Drug_Screen__Benzodiazepines'] == 'Yes', 'Drug_Screen__Benzodiazepines'] = 1 x4.loc[x4['Drug_Screen__Benzodiazepines'] == 'Not tested', 'Drug_Screen__Benzodiazepines'] = 2 x4.loc[x4['Drug_Screen__Cannabinoid'] == 'No', 'Drug_Screen__Cannabinoid'] = 0 x4.loc[x4['Drug_Screen__Cannabinoid'] == 'Yes', 'Drug_Screen__Cannabinoid'] = 1 x4.loc[x4['Drug_Screen__Cannabinoid'] == 'Not tested', 'Drug_Screen__Cannabinoid'] = 2 x4.loc[x4['Drug_Screen__Cocaine'] == 'No', 'Drug_Screen__Cocaine'] = 0 x4.loc[x4['Drug_Screen__Cocaine'] == 'Yes', 'Drug_Screen__Cocaine'] = 1 x4.loc[x4['Drug_Screen__Cocaine'] == 'Not tested', 'Drug_Screen__Cocaine'] = 2 x4.loc[x4['Drug_Screen__MDMA_or_Ecstasy'] == 'No', 'Drug_Screen__MDMA_or_Ecstasy'] = 0 x4.loc[x4['Drug_Screen__MDMA_or_Ecstasy'] == 'Yes', 'Drug_Screen__MDMA_or_Ecstasy'] = 1 x4.loc[x4['Drug_Screen__MDMA_or_Ecstasy'] == 'Not tested', 'Drug_Screen__MDMA_or_Ecstasy'] = 2 x4.loc[x4['Drug_Screen__Methadone'] == 'No', 'Drug_Screen__Methadone'] = 0 x4.loc[x4['Drug_Screen__Methadone'] == 'Yes', 'Drug_Screen__Methadone'] = 1 x4.loc[x4['Drug_Screen__Methadone'] == 'Not tested', 'Drug_Screen__Methadone'] = 2 x4.loc[x4['Drug_Screen__Methamphetamine'] == 'No', 'Drug_Screen__Methamphetamine'] = 0 x4.loc[x4['Drug_Screen__Methamphetamine'] == 'Yes', 'Drug_Screen__Methamphetamine'] = 1 x4.loc[x4['Drug_Screen__Methamphetamine'] == 'Not tested', 'Drug_Screen__Methamphetamine'] = 2 x4.loc[x4['Drug_Screen__Opioid'] == 'No', 'Drug_Screen__Opioid'] = 0 x4.loc[x4['Drug_Screen__Opioid'] == 'Yes', 'Drug_Screen__Opioid'] = 1 x4.loc[x4['Drug_Screen__Opioid'] == 'Not tested', 'Drug_Screen__Opioid'] = 2 x4.loc[x4['Drug_Screen__Oxycodone'] == 'No', 'Drug_Screen__Oxycodone'] = 0 x4.loc[x4['Drug_Screen__Oxycodone'] == 'Yes', 'Drug_Screen__Oxycodone'] = 1 x4.loc[x4['Drug_Screen__Oxycodone'] == 'Not tested', 'Drug_Screen__Oxycodone'] = 2 x4.loc[x4['Drug_Screen__Phencyclidine'] == 'No', 'Drug_Screen__Phencyclidine'] = 0 x4.loc[x4['Drug_Screen__Phencyclidine'] == 'Yes', 'Drug_Screen__Phencyclidine'] = 1 x4.loc[x4['Drug_Screen__Phencyclidine'] == 'Not tested', 'Drug_Screen__Phencyclidine'] = 2 x4.loc[x4['Drug_Screen__Tricyclic_Antidepressant'] == 'No', 'Drug_Screen__Tricyclic_Antidepressant'] = 0 x4.loc[x4['Drug_Screen__Tricyclic_Antidepressant'] == 'Yes', 'Drug_Screen__Tricyclic_Antidepressant'] = 1 x4.loc[x4['Drug_Screen__Tricyclic_Antidepressant'] == 'Not tested', 'Drug_Screen__Tricyclic_Antidepressant'] = 2 x4.loc[x4['ACS_Verification_Level'] == 'Level I Trauma Center', 'ACS_Verification_Level'] = 0 x4.loc[x4['ACS_Verification_Level'] == 'Level II Trauma Center', 'ACS_Verification_Level'] = 1 x4.loc[x4['ACS_Verification_Level'] == 'Level III Trauma Center', 'ACS_Verification_Level'] = 2 x4.loc[x4['ACS_Verification_Level'] == 'Unknown', 'ACS_Verification_Level'] = 3 x4.loc[x4['Hospital_Type'] == 'Non-profit', 'Hospital_Type'] = 0 x4.loc[x4['Hospital_Type'] == 'For profit', 'Hospital_Type'] = 1 x4.loc[x4['Hospital_Type'] == 'Government', 'Hospital_Type'] = 2 x4.loc[x4['Hospital_Type'] == 'Unknown', 'Hospital_Type'] = 3 x4.loc[x4['Facility_Bed_Size'] == 'More than 600', 'Facility_Bed_Size'] = 0 x4.loc[x4['Facility_Bed_Size'] == '401 to 600', 'Facility_Bed_Size'] = 1 x4.loc[x4['Facility_Bed_Size'] == '201 to 400', 'Facility_Bed_Size'] = 2 x4.loc[x4['Facility_Bed_Size'] == '200 or fewer', 'Facility_Bed_Size'] = 3 x4.loc[x4['Primary_Method_of_Payment'] == 'Medicare', 'Primary_Method_of_Payment'] = 0 x4.loc[x4['Primary_Method_of_Payment'] == 'Private/commercial insurance', 'Primary_Method_of_Payment'] = 1 x4.loc[x4['Primary_Method_of_Payment'] == 'Medicaid', 'Primary_Method_of_Payment'] = 2 x4.loc[x4['Primary_Method_of_Payment'] == 'Self-pay', 'Primary_Method_of_Payment'] = 3 x4.loc[x4['Primary_Method_of_Payment'] == 'Other/unknown', 'Primary_Method_of_Payment'] = 4 #Prepare validation data for the outcome 4 (ICU-LOS). y4_valid = x4_valid.pop('OUTCOME') x4_valid.loc[x4_valid['Sex'] == 'Male', 'Sex'] = 0 x4_valid.loc[x4_valid['Sex'] == 'Female', 'Sex'] = 1 x4_valid.loc[x4_valid['Sex'] == 'Non-Binary', 'Sex'] = 2 x4_valid.loc[x4_valid['Sex'] == 'Unknown', 'Sex'] = 3 x4_valid.loc[x4_valid['Race'] == 'White', 'Race'] = 0 x4_valid.loc[x4_valid['Race'] == 'Black', 'Race'] = 1 x4_valid.loc[x4_valid['Race'] == 'Asian', 'Race'] = 2 x4_valid.loc[x4_valid['Race'] == 'Other/unknown', 'Race'] = 5 x4_valid.loc[x4_valid['Ethnicity'] == 'Not Hispanic or Latino', 'Ethnicity'] = 0 x4_valid.loc[x4_valid['Ethnicity'] == 'Hispanic or Latino', 'Ethnicity'] = 1 x4_valid.loc[x4_valid['Ethnicity'] == 'Unknown', 'Ethnicity'] = 2 x4_valid.loc[x4_valid['Supplemental_Oxygen'] == 'No supplemental oxygen', 'Supplemental_Oxygen'] = 0 x4_valid.loc[x4_valid['Supplemental_Oxygen'] == 'Supplemental oxygen', 'Supplemental_Oxygen'] = 1 x4_valid.loc[x4_valid['Supplemental_Oxygen'] == 'Unknown', 'Supplemental_Oxygen'] = 2 x4_valid.loc[x4_valid['Respiratory_Assistance'] == 'Unassisted respiratory rate', 'Respiratory_Assistance'] = 0 x4_valid.loc[x4_valid['Respiratory_Assistance'] == 'Assisted respiratory rate', 'Respiratory_Assistance'] = 1 x4_valid.loc[x4_valid['Respiratory_Assistance'] == 'Unknown', 'Respiratory_Assistance'] = 2 x4_valid.loc[x4_valid['Fracture_of_C1_Vertebra'] == 'No', 'Fracture_of_C1_Vertebra'] = 0 x4_valid.loc[x4_valid['Fracture_of_C1_Vertebra'] == 'Yes', 'Fracture_of_C1_Vertebra'] = 1 x4_valid.loc[x4_valid['Fracture_of_C2_Vertebra'] == 'No', 'Fracture_of_C2_Vertebra'] = 0 x4_valid.loc[x4_valid['Fracture_of_C2_Vertebra'] == 'Yes', 'Fracture_of_C2_Vertebra'] = 1 x4_valid.loc[x4_valid['Fracture_of_C3_Vertebra'] == 'No', 'Fracture_of_C3_Vertebra'] = 0 x4_valid.loc[x4_valid['Fracture_of_C3_Vertebra'] == 'Yes', 'Fracture_of_C3_Vertebra'] = 1 x4_valid.loc[x4_valid['Fracture_of_C4_Vertebra'] == 'No', 'Fracture_of_C4_Vertebra'] = 0 x4_valid.loc[x4_valid['Fracture_of_C4_Vertebra'] == 'Yes', 'Fracture_of_C4_Vertebra'] = 1 x4_valid.loc[x4_valid['Fracture_of_C5_Vertebra'] == 'No', 'Fracture_of_C5_Vertebra'] = 0 x4_valid.loc[x4_valid['Fracture_of_C5_Vertebra'] == 'Yes', 'Fracture_of_C5_Vertebra'] = 1 x4_valid.loc[x4_valid['Fracture_of_C6_Vertebra'] == 'No', 'Fracture_of_C6_Vertebra'] = 0 x4_valid.loc[x4_valid['Fracture_of_C6_Vertebra'] == 'Yes', 'Fracture_of_C6_Vertebra'] = 1 x4_valid.loc[x4_valid['Fracture_of_C7_Vertebra'] == 'No', 'Fracture_of_C7_Vertebra'] = 0 x4_valid.loc[x4_valid['Fracture_of_C7_Vertebra'] == 'Yes', 'Fracture_of_C7_Vertebra'] = 1 x4_valid.loc[x4_valid['Rupture_of_Cervical_Intervertebral_Disc'] == 'No', 'Rupture_of_Cervical_Intervertebral_Disc'] = 0 x4_valid.loc[x4_valid['Rupture_of_Cervical_Intervertebral_Disc'] == 'Yes', 'Rupture_of_Cervical_Intervertebral_Disc'] = 1 x4_valid.loc[x4_valid['Subluxation_and_Dislocation_of_C0/C1_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C0/C1_Vertebrae'] = 0 x4_valid.loc[x4_valid['Subluxation_and_Dislocation_of_C0/C1_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C0/C1_Vertebrae'] = 1 x4_valid.loc[x4_valid['Subluxation_and_Dislocation_of_C1/C2_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C1/C2_Vertebrae'] = 0 x4_valid.loc[x4_valid['Subluxation_and_Dislocation_of_C1/C2_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C1/C2_Vertebrae'] = 1 x4_valid.loc[x4_valid['Subluxation_and_Dislocation_of_C2/C3_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C2/C3_Vertebrae'] = 0 x4_valid.loc[x4_valid['Subluxation_and_Dislocation_of_C2/C3_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C2/C3_Vertebrae'] = 1 x4_valid.loc[x4_valid['Subluxation_and_Dislocation_of_C3/C4_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C3/C4_Vertebrae'] = 0 x4_valid.loc[x4_valid['Subluxation_and_Dislocation_of_C3/C4_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C3/C4_Vertebrae'] = 1 x4_valid.loc[x4_valid['Subluxation_and_Dislocation_of_C4/C5_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C4/C5_Vertebrae'] = 0 x4_valid.loc[x4_valid['Subluxation_and_Dislocation_of_C4/C5_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C4/C5_Vertebrae'] = 1 x4_valid.loc[x4_valid['Subluxation_and_Dislocation_of_C5/C6_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C5/C6_Vertebrae'] = 0 x4_valid.loc[x4_valid['Subluxation_and_Dislocation_of_C5/C6_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C5/C6_Vertebrae'] = 1 x4_valid.loc[x4_valid['Subluxation_and_Dislocation_of_C6/C7_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C6/C7_Vertebrae'] = 0 x4_valid.loc[x4_valid['Subluxation_and_Dislocation_of_C6/C7_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C6/C7_Vertebrae'] = 1 x4_valid.loc[x4_valid['Subluxation_and_Dislocation_of_C7/T1_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C7/T1_Vertebrae'] = 0 x4_valid.loc[x4_valid['Subluxation_and_Dislocation_of_C7/T1_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C7/T1_Vertebrae'] = 1 x4_valid.loc[x4_valid['Concussion_and_Edema_of_cSC'] == 'No', 'Concussion_and_Edema_of_cSC'] = 0 x4_valid.loc[x4_valid['Concussion_and_Edema_of_cSC'] == 'Yes', 'Concussion_and_Edema_of_cSC'] = 1 x4_valid.loc[x4_valid['Complete_Lesion_of_cSC'] == 'No', 'Complete_Lesion_of_cSC'] = 0 x4_valid.loc[x4_valid['Complete_Lesion_of_cSC'] == 'Yes', 'Complete_Lesion_of_cSC'] = 1 x4_valid.loc[x4_valid['Anterior_Cord_Syndrome_of_cSC'] == 'No', 'Anterior_Cord_Syndrome_of_cSC'] = 0 x4_valid.loc[x4_valid['Anterior_Cord_Syndrome_of_cSC'] == 'Yes', 'Anterior_Cord_Syndrome_of_cSC'] = 1 x4_valid.loc[x4_valid['BrownSequard_Syndrome_of_cSC'] == 'No', 'BrownSequard_Syndrome_of_cSC'] = 0 x4_valid.loc[x4_valid['BrownSequard_Syndrome_of_cSC'] == 'Yes', 'BrownSequard_Syndrome_of_cSC'] = 1 x4_valid.loc[x4_valid['Other_Incomplete_Lesions_of_cSC'] == 'No', 'Other_Incomplete_Lesions_of_cSC'] = 0 x4_valid.loc[x4_valid['Other_Incomplete_Lesions_of_cSC'] == 'Yes', 'Other_Incomplete_Lesions_of_cSC'] = 1 x4_valid.loc[x4_valid['Current_Smoker'] == 'No', 'Current_Smoker'] = 0 x4_valid.loc[x4_valid['Current_Smoker'] == 'Yes', 'Current_Smoker'] = 1 x4_valid.loc[x4_valid['Current_Smoker'] == 'Unknown', 'Current_Smoker'] = 2 x4_valid.loc[x4_valid['Alcohol_Use_Disorder'] == 'No', 'Alcohol_Use_Disorder'] = 0 x4_valid.loc[x4_valid['Alcohol_Use_Disorder'] == 'Yes', 'Alcohol_Use_Disorder'] = 1 x4_valid.loc[x4_valid['Alcohol_Use_Disorder'] == 'Unknown', 'Alcohol_Use_Disorder'] = 2 x4_valid.loc[x4_valid['Substance_Abuse_Disorder'] == 'No', 'Substance_Abuse_Disorder'] = 0 x4_valid.loc[x4_valid['Substance_Abuse_Disorder'] == 'Yes', 'Substance_Abuse_Disorder'] = 1 x4_valid.loc[x4_valid['Substance_Abuse_Disorder'] == 'Unknown', 'Substance_Abuse_Disorder'] = 2 x4_valid.loc[x4_valid['Diabetes_Mellitus'] == 'No', 'Diabetes_Mellitus'] = 0 x4_valid.loc[x4_valid['Diabetes_Mellitus'] == 'Yes', 'Diabetes_Mellitus'] = 1 x4_valid.loc[x4_valid['Diabetes_Mellitus'] == 'Unknown', 'Diabetes_Mellitus'] = 2 x4_valid.loc[x4_valid['Hypertension'] == 'No', 'Hypertension'] = 0 x4_valid.loc[x4_valid['Hypertension'] == 'Yes', 'Hypertension'] = 1 x4_valid.loc[x4_valid['Hypertension'] == 'Unknown', 'Hypertension'] = 2 x4_valid.loc[x4_valid['Congestive_Heart_Failure'] == 'No', 'Congestive_Heart_Failure'] = 0 x4_valid.loc[x4_valid['Congestive_Heart_Failure'] == 'Yes', 'Congestive_Heart_Failure'] = 1 x4_valid.loc[x4_valid['Congestive_Heart_Failure'] == 'Unknown', 'Congestive_Heart_Failure'] = 2 x4_valid.loc[x4_valid['History_of_Myocardial_Infarction'] == 'No', 'History_of_Myocardial_Infarction'] = 0 x4_valid.loc[x4_valid['History_of_Myocardial_Infarction'] == 'Yes', 'History_of_Myocardial_Infarction'] = 1 x4_valid.loc[x4_valid['History_of_Myocardial_Infarction'] == 'Unknown', 'History_of_Myocardial_Infarction'] = 2 x4_valid.loc[x4_valid['Angina_Pectoris'] == 'No', 'Angina_Pectoris'] = 0 x4_valid.loc[x4_valid['Angina_Pectoris'] == 'Yes', 'Angina_Pectoris'] = 1 x4_valid.loc[x4_valid['Angina_Pectoris'] == 'Unknown', 'Angina_Pectoris'] = 2 x4_valid.loc[x4_valid['History_of_Cerebrovascular_Accident'] == 'No', 'History_of_Cerebrovascular_Accident'] = 0 x4_valid.loc[x4_valid['History_of_Cerebrovascular_Accident'] == 'Yes', 'History_of_Cerebrovascular_Accident'] = 1 x4_valid.loc[x4_valid['History_of_Cerebrovascular_Accident'] == 'Unknown', 'History_of_Cerebrovascular_Accident'] = 2 x4_valid.loc[x4_valid['Peripheral_Arterial_Disease'] == 'No', 'Peripheral_Arterial_Disease'] = 0 x4_valid.loc[x4_valid['Peripheral_Arterial_Disease'] == 'Yes', 'Peripheral_Arterial_Disease'] = 1 x4_valid.loc[x4_valid['Peripheral_Arterial_Disease'] == 'Unknown', 'Peripheral_Arterial_Disease'] = 2 x4_valid.loc[x4_valid['Chronic_Obstructive_Pulmonary_Disease'] == 'No', 'Chronic_Obstructive_Pulmonary_Disease'] = 0 x4_valid.loc[x4_valid['Chronic_Obstructive_Pulmonary_Disease'] == 'Yes', 'Chronic_Obstructive_Pulmonary_Disease'] = 1 x4_valid.loc[x4_valid['Chronic_Obstructive_Pulmonary_Disease'] == 'Unknown', 'Chronic_Obstructive_Pulmonary_Disease'] = 2 x4_valid.loc[x4_valid['Chronic_Renal_Failure'] == 'No', 'Chronic_Renal_Failure'] = 0 x4_valid.loc[x4_valid['Chronic_Renal_Failure'] == 'Yes', 'Chronic_Renal_Failure'] = 1 x4_valid.loc[x4_valid['Chronic_Renal_Failure'] == 'Unknown', 'Chronic_Renal_Failure'] = 2 x4_valid.loc[x4_valid['Cirrhosis'] == 'No', 'Cirrhosis'] = 0 x4_valid.loc[x4_valid['Cirrhosis'] == 'Yes', 'Cirrhosis'] = 1 x4_valid.loc[x4_valid['Cirrhosis'] == 'Unknown', 'Cirrhosis'] = 2 x4_valid.loc[x4_valid['Bleeding_Disorder'] == 'No', 'Bleeding_Disorder'] = 0 x4_valid.loc[x4_valid['Bleeding_Disorder'] == 'Yes', 'Bleeding_Disorder'] = 1 x4_valid.loc[x4_valid['Bleeding_Disorder'] == 'Unknown', 'Bleeding_Disorder'] = 2 x4_valid.loc[x4_valid['Disseminated_Cancer'] == 'No', 'Disseminated_Cancer'] = 0 x4_valid.loc[x4_valid['Disseminated_Cancer'] == 'Yes', 'Disseminated_Cancer'] = 1 x4_valid.loc[x4_valid['Disseminated_Cancer'] == 'Unknown', 'Disseminated_Cancer'] = 2 x4_valid.loc[x4_valid['Currently_Receiving_Chemotherapy_for_Cancer'] == 'No', 'Currently_Receiving_Chemotherapy_for_Cancer'] = 0 x4_valid.loc[x4_valid['Currently_Receiving_Chemotherapy_for_Cancer'] == 'Yes', 'Currently_Receiving_Chemotherapy_for_Cancer'] = 1 x4_valid.loc[x4_valid['Currently_Receiving_Chemotherapy_for_Cancer'] == 'Unknown', 'Currently_Receiving_Chemotherapy_for_Cancer'] = 2 x4_valid.loc[x4_valid['Dementia'] == 'No', 'Dementia'] = 0 x4_valid.loc[x4_valid['Dementia'] == 'Yes', 'Dementia'] = 1 x4_valid.loc[x4_valid['Dementia'] == 'Unknown', 'Dementia'] = 2 x4_valid.loc[x4_valid['Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder'] == 'No', 'Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder'] = 0 x4_valid.loc[x4_valid['Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder'] == 'Yes', 'Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder'] = 1 x4_valid.loc[x4_valid['Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder'] == 'Unknown', 'Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder'] = 2 x4_valid.loc[x4_valid['Mental_or_Personality_Disorder'] == 'No', 'Mental_or_Personality_Disorder'] = 0 x4_valid.loc[x4_valid['Mental_or_Personality_Disorder'] == 'Yes', 'Mental_or_Personality_Disorder'] = 1 x4_valid.loc[x4_valid['Mental_or_Personality_Disorder'] == 'Unknown', 'Mental_or_Personality_Disorder'] = 2 x4_valid.loc[x4_valid['Ability_to_Complete_AgeAppropriate_ADL'] == 'No', 'Ability_to_Complete_AgeAppropriate_ADL'] = 0 x4_valid.loc[x4_valid['Ability_to_Complete_AgeAppropriate_ADL'] == 'Yes', 'Ability_to_Complete_AgeAppropriate_ADL'] = 1 x4_valid.loc[x4_valid['Ability_to_Complete_AgeAppropriate_ADL'] == 'Unknown', 'Ability_to_Complete_AgeAppropriate_ADL'] = 2 x4_valid.loc[x4_valid['Pregnancy'] == 'Not applicable (male patient)', 'Pregnancy'] = 0 x4_valid.loc[x4_valid['Pregnancy'] == 'No', 'Pregnancy'] = 1 x4_valid.loc[x4_valid['Pregnancy'] == 'Yes', 'Pregnancy'] = 2 x4_valid.loc[x4_valid['Pregnancy'] == 'Unkown', 'Pregnancy'] = 3 x4_valid.loc[x4_valid['Anticoagulant_Therapy'] == 'No', 'Anticoagulant_Therapy'] = 0 x4_valid.loc[x4_valid['Anticoagulant_Therapy'] == 'Yes', 'Anticoagulant_Therapy'] = 1 x4_valid.loc[x4_valid['Anticoagulant_Therapy'] == 'Unknown', 'Anticoagulant_Therapy'] = 2 x4_valid.loc[x4_valid['Steroid_Use'] == 'No', 'Steroid_Use'] = 0 x4_valid.loc[x4_valid['Steroid_Use'] == 'Yes', 'Steroid_Use'] = 1 x4_valid.loc[x4_valid['Steroid_Use'] == 'Unknown', 'Steroid_Use'] = 2 x4_valid.loc[x4_valid['Transport_Mode'] == 'Ground ambulance', 'Transport_Mode'] = 0 x4_valid.loc[x4_valid['Transport_Mode'] == 'Private/public vehicle/walk-in', 'Transport_Mode'] = 1 x4_valid.loc[x4_valid['Transport_Mode'] == 'Air ambulance', 'Transport_Mode'] = 2 x4_valid.loc[x4_valid['Transport_Mode'] == 'Other/unknown', 'Transport_Mode'] = 3 x4_valid.loc[x4_valid['InterFacility_Transfer'] == 'No', 'InterFacility_Transfer'] = 0 x4_valid.loc[x4_valid['InterFacility_Transfer'] == 'Yes', 'InterFacility_Transfer'] = 1 x4_valid.loc[x4_valid['InterFacility_Transfer'] == 'Unknown', 'InterFacility_Transfer'] = 2 x4_valid.loc[x4_valid['Trauma_Type'] == 'Blunt', 'Trauma_Type'] = 0 x4_valid.loc[x4_valid['Trauma_Type'] == 'Penetrating', 'Trauma_Type'] = 1 x4_valid.loc[x4_valid['Trauma_Type'] == 'Other/unknown', 'Trauma_Type'] = 2 x4_valid.loc[x4_valid['Injury_Intent'] == 'Unintentional', 'Injury_Intent'] = 0 x4_valid.loc[x4_valid['Injury_Intent'] == 'Assault', 'Injury_Intent'] = 1 x4_valid.loc[x4_valid['Injury_Intent'] == 'Other/unknown', 'Injury_Intent'] = 2 x4_valid.loc[x4_valid['Mechanism_of_Injury'] == 'Fall', 'Mechanism_of_Injury'] = 0 x4_valid.loc[x4_valid['Mechanism_of_Injury'] == 'MVT occupant', 'Mechanism_of_Injury'] = 1 x4_valid.loc[x4_valid['Mechanism_of_Injury'] == 'Struck by or against', 'Mechanism_of_Injury'] = 2 x4_valid.loc[x4_valid['Mechanism_of_Injury'] == 'Other MVT', 'Mechanism_of_Injury'] = 3 x4_valid.loc[x4_valid['Mechanism_of_Injury'] == 'MVT motorcyclist', 'Mechanism_of_Injury'] = 4 x4_valid.loc[x4_valid['Mechanism_of_Injury'] == 'Other transport', 'Mechanism_of_Injury'] = 5 x4_valid.loc[x4_valid['Mechanism_of_Injury'] == 'Other pedal cyclist', 'Mechanism_of_Injury'] = 6 x4_valid.loc[x4_valid['Mechanism_of_Injury'] == 'MVT pedestrian', 'Mechanism_of_Injury'] = 7 x4_valid.loc[x4_valid['Mechanism_of_Injury'] == 'Firearm', 'Mechanism_of_Injury'] = 8 x4_valid.loc[x4_valid['Mechanism_of_Injury'] == 'Other/unknown', 'Mechanism_of_Injury'] = 9 x4_valid.loc[x4_valid['Protective_Device'] == 'None', 'Protective_Device'] = 0 x4_valid.loc[x4_valid['Protective_Device'] == 'Belt', 'Protective_Device'] = 1 x4_valid.loc[x4_valid['Protective_Device'] == 'Airbag present', 'Protective_Device'] = 2 x4_valid.loc[x4_valid['Protective_Device'] == 'Helmet', 'Protective_Device'] = 3 x4_valid.loc[x4_valid['Protective_Device'] == 'Other/unknown', 'Protective_Device'] = 4 x4_valid.loc[x4_valid['WorkRelated'] == 'No/unknown', 'WorkRelated'] = 0 x4_valid.loc[x4_valid['WorkRelated'] == 'Yes', 'WorkRelated'] = 1 x4_valid.loc[x4_valid['Surgical_Intervention'] == 'No', 'Surgical_Intervention'] = 0 x4_valid.loc[x4_valid['Surgical_Intervention'] == 'Yes', 'Surgical_Intervention'] = 1 x4_valid.loc[x4_valid['Alcohol_Screen'] == 'No', 'Alcohol_Screen'] = 0 x4_valid.loc[x4_valid['Alcohol_Screen'] == 'Yes', 'Alcohol_Screen'] = 1 x4_valid.loc[x4_valid['Alcohol_Screen'] == 'Unknown', 'Alcohol_Screen'] = 2 x4_valid.loc[x4_valid['Drug_Screen__Amphetamine'] == 'No', 'Drug_Screen__Amphetamine'] = 0 x4_valid.loc[x4_valid['Drug_Screen__Amphetamine'] == 'Yes', 'Drug_Screen__Amphetamine'] = 1 x4_valid.loc[x4_valid['Drug_Screen__Amphetamine'] == 'Not tested', 'Drug_Screen__Amphetamine'] = 2 x4_valid.loc[x4_valid['Drug_Screen__Barbiturate'] == 'No', 'Drug_Screen__Barbiturate'] = 0 x4_valid.loc[x4_valid['Drug_Screen__Barbiturate'] == 'Yes', 'Drug_Screen__Barbiturate'] = 1 x4_valid.loc[x4_valid['Drug_Screen__Barbiturate'] == 'Not tested', 'Drug_Screen__Barbiturate'] = 2 x4_valid.loc[x4_valid['Drug_Screen__Benzodiazepines'] == 'No', 'Drug_Screen__Benzodiazepines'] = 0 x4_valid.loc[x4_valid['Drug_Screen__Benzodiazepines'] == 'Yes', 'Drug_Screen__Benzodiazepines'] = 1 x4_valid.loc[x4_valid['Drug_Screen__Benzodiazepines'] == 'Not tested', 'Drug_Screen__Benzodiazepines'] = 2 x4_valid.loc[x4_valid['Drug_Screen__Cannabinoid'] == 'No', 'Drug_Screen__Cannabinoid'] = 0 x4_valid.loc[x4_valid['Drug_Screen__Cannabinoid'] == 'Yes', 'Drug_Screen__Cannabinoid'] = 1 x4_valid.loc[x4_valid['Drug_Screen__Cannabinoid'] == 'Not tested', 'Drug_Screen__Cannabinoid'] = 2 x4_valid.loc[x4_valid['Drug_Screen__Cocaine'] == 'No', 'Drug_Screen__Cocaine'] = 0 x4_valid.loc[x4_valid['Drug_Screen__Cocaine'] == 'Yes', 'Drug_Screen__Cocaine'] = 1 x4_valid.loc[x4_valid['Drug_Screen__Cocaine'] == 'Not tested', 'Drug_Screen__Cocaine'] = 2 x4_valid.loc[x4_valid['Drug_Screen__MDMA_or_Ecstasy'] == 'No', 'Drug_Screen__MDMA_or_Ecstasy'] = 0 x4_valid.loc[x4_valid['Drug_Screen__MDMA_or_Ecstasy'] == 'Yes', 'Drug_Screen__MDMA_or_Ecstasy'] = 1 x4_valid.loc[x4_valid['Drug_Screen__MDMA_or_Ecstasy'] == 'Not tested', 'Drug_Screen__MDMA_or_Ecstasy'] = 2 x4_valid.loc[x4_valid['Drug_Screen__Methadone'] == 'No', 'Drug_Screen__Methadone'] = 0 x4_valid.loc[x4_valid['Drug_Screen__Methadone'] == 'Yes', 'Drug_Screen__Methadone'] = 1 x4_valid.loc[x4_valid['Drug_Screen__Methadone'] == 'Not tested', 'Drug_Screen__Methadone'] = 2 x4_valid.loc[x4_valid['Drug_Screen__Methamphetamine'] == 'No', 'Drug_Screen__Methamphetamine'] = 0 x4_valid.loc[x4_valid['Drug_Screen__Methamphetamine'] == 'Yes', 'Drug_Screen__Methamphetamine'] = 1 x4_valid.loc[x4_valid['Drug_Screen__Methamphetamine'] == 'Not tested', 'Drug_Screen__Methamphetamine'] = 2 x4_valid.loc[x4_valid['Drug_Screen__Opioid'] == 'No', 'Drug_Screen__Opioid'] = 0 x4_valid.loc[x4_valid['Drug_Screen__Opioid'] == 'Yes', 'Drug_Screen__Opioid'] = 1 x4_valid.loc[x4_valid['Drug_Screen__Opioid'] == 'Not tested', 'Drug_Screen__Opioid'] = 2 x4_valid.loc[x4_valid['Drug_Screen__Oxycodone'] == 'No', 'Drug_Screen__Oxycodone'] = 0 x4_valid.loc[x4_valid['Drug_Screen__Oxycodone'] == 'Yes', 'Drug_Screen__Oxycodone'] = 1 x4_valid.loc[x4_valid['Drug_Screen__Oxycodone'] == 'Not tested', 'Drug_Screen__Oxycodone'] = 2 x4_valid.loc[x4_valid['Drug_Screen__Phencyclidine'] == 'No', 'Drug_Screen__Phencyclidine'] = 0 x4_valid.loc[x4_valid['Drug_Screen__Phencyclidine'] == 'Yes', 'Drug_Screen__Phencyclidine'] = 1 x4_valid.loc[x4_valid['Drug_Screen__Phencyclidine'] == 'Not tested', 'Drug_Screen__Phencyclidine'] = 2 x4_valid.loc[x4_valid['Drug_Screen__Tricyclic_Antidepressant'] == 'No', 'Drug_Screen__Tricyclic_Antidepressant'] = 0 x4_valid.loc[x4_valid['Drug_Screen__Tricyclic_Antidepressant'] == 'Yes', 'Drug_Screen__Tricyclic_Antidepressant'] = 1 x4_valid.loc[x4_valid['Drug_Screen__Tricyclic_Antidepressant'] == 'Not tested', 'Drug_Screen__Tricyclic_Antidepressant'] = 2 x4_valid.loc[x4_valid['ACS_Verification_Level'] == 'Level I Trauma Center', 'ACS_Verification_Level'] = 0 x4_valid.loc[x4_valid['ACS_Verification_Level'] == 'Level II Trauma Center', 'ACS_Verification_Level'] = 1 x4_valid.loc[x4_valid['ACS_Verification_Level'] == 'Level III Trauma Center', 'ACS_Verification_Level'] = 2 x4_valid.loc[x4_valid['ACS_Verification_Level'] == 'Unknown', 'ACS_Verification_Level'] = 3 x4_valid.loc[x4_valid['Hospital_Type'] == 'Non-profit', 'Hospital_Type'] = 0 x4_valid.loc[x4_valid['Hospital_Type'] == 'For profit', 'Hospital_Type'] = 1 x4_valid.loc[x4_valid['Hospital_Type'] == 'Government', 'Hospital_Type'] = 2 x4_valid.loc[x4_valid['Hospital_Type'] == 'Unknown', 'Hospital_Type'] = 3 x4_valid.loc[x4_valid['Facility_Bed_Size'] == 'More than 600', 'Facility_Bed_Size'] = 0 x4_valid.loc[x4_valid['Facility_Bed_Size'] == '401 to 600', 'Facility_Bed_Size'] = 1 x4_valid.loc[x4_valid['Facility_Bed_Size'] == '201 to 400', 'Facility_Bed_Size'] = 2 x4_valid.loc[x4_valid['Facility_Bed_Size'] == '200 or fewer', 'Facility_Bed_Size'] = 3 x4_valid.loc[x4_valid['Primary_Method_of_Payment'] == 'Medicare', 'Primary_Method_of_Payment'] = 0 x4_valid.loc[x4_valid['Primary_Method_of_Payment'] == 'Private/commercial insurance', 'Primary_Method_of_Payment'] = 1 x4_valid.loc[x4_valid['Primary_Method_of_Payment'] == 'Medicaid', 'Primary_Method_of_Payment'] = 2 x4_valid.loc[x4_valid['Primary_Method_of_Payment'] == 'Self-pay', 'Primary_Method_of_Payment'] = 3 x4_valid.loc[x4_valid['Primary_Method_of_Payment'] == 'Other/unknown', 'Primary_Method_of_Payment'] = 4 #Prepare data for the outcome 5 (complications). y5 = x5.pop('OUTCOME') x5.loc[x5['Sex'] == 'Male', 'Sex'] = 0 x5.loc[x5['Sex'] == 'Female', 'Sex'] = 1 x5.loc[x5['Sex'] == 'Non-Binary', 'Sex'] = 2 x5.loc[x5['Sex'] == 'Unknown', 'Sex'] = 3 x5.loc[x5['Race'] == 'White', 'Race'] = 0 x5.loc[x5['Race'] == 'Black', 'Race'] = 1 x5.loc[x5['Race'] == 'Asian', 'Race'] = 2 x5.loc[x5['Race'] == 'Other/unknown', 'Race'] = 5 x5.loc[x5['Ethnicity'] == 'Not Hispanic or Latino', 'Ethnicity'] = 0 x5.loc[x5['Ethnicity'] == 'Hispanic or Latino', 'Ethnicity'] = 1 x5.loc[x5['Ethnicity'] == 'Unknown', 'Ethnicity'] = 2 x5.loc[x5['Supplemental_Oxygen'] == 'No supplemental oxygen', 'Supplemental_Oxygen'] = 0 x5.loc[x5['Supplemental_Oxygen'] == 'Supplemental oxygen', 'Supplemental_Oxygen'] = 1 x5.loc[x5['Supplemental_Oxygen'] == 'Unknown', 'Supplemental_Oxygen'] = 2 x5.loc[x5['Respiratory_Assistance'] == 'Unassisted respiratory rate', 'Respiratory_Assistance'] = 0 x5.loc[x5['Respiratory_Assistance'] == 'Assisted respiratory rate', 'Respiratory_Assistance'] = 1 x5.loc[x5['Respiratory_Assistance'] == 'Unknown', 'Respiratory_Assistance'] = 2 x5.loc[x5['Fracture_of_C1_Vertebra'] == 'No', 'Fracture_of_C1_Vertebra'] = 0 x5.loc[x5['Fracture_of_C1_Vertebra'] == 'Yes', 'Fracture_of_C1_Vertebra'] = 1 x5.loc[x5['Fracture_of_C2_Vertebra'] == 'No', 'Fracture_of_C2_Vertebra'] = 0 x5.loc[x5['Fracture_of_C2_Vertebra'] == 'Yes', 'Fracture_of_C2_Vertebra'] = 1 x5.loc[x5['Fracture_of_C3_Vertebra'] == 'No', 'Fracture_of_C3_Vertebra'] = 0 x5.loc[x5['Fracture_of_C3_Vertebra'] == 'Yes', 'Fracture_of_C3_Vertebra'] = 1 x5.loc[x5['Fracture_of_C4_Vertebra'] == 'No', 'Fracture_of_C4_Vertebra'] = 0 x5.loc[x5['Fracture_of_C4_Vertebra'] == 'Yes', 'Fracture_of_C4_Vertebra'] = 1 x5.loc[x5['Fracture_of_C5_Vertebra'] == 'No', 'Fracture_of_C5_Vertebra'] = 0 x5.loc[x5['Fracture_of_C5_Vertebra'] == 'Yes', 'Fracture_of_C5_Vertebra'] = 1 x5.loc[x5['Fracture_of_C6_Vertebra'] == 'No', 'Fracture_of_C6_Vertebra'] = 0 x5.loc[x5['Fracture_of_C6_Vertebra'] == 'Yes', 'Fracture_of_C6_Vertebra'] = 1 x5.loc[x5['Fracture_of_C7_Vertebra'] == 'No', 'Fracture_of_C7_Vertebra'] = 0 x5.loc[x5['Fracture_of_C7_Vertebra'] == 'Yes', 'Fracture_of_C7_Vertebra'] = 1 x5.loc[x5['Rupture_of_Cervical_Intervertebral_Disc'] == 'No', 'Rupture_of_Cervical_Intervertebral_Disc'] = 0 x5.loc[x5['Rupture_of_Cervical_Intervertebral_Disc'] == 'Yes', 'Rupture_of_Cervical_Intervertebral_Disc'] = 1 x5.loc[x5['Subluxation_and_Dislocation_of_C0/C1_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C0/C1_Vertebrae'] = 0 x5.loc[x5['Subluxation_and_Dislocation_of_C0/C1_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C0/C1_Vertebrae'] = 1 x5.loc[x5['Subluxation_and_Dislocation_of_C1/C2_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C1/C2_Vertebrae'] = 0 x5.loc[x5['Subluxation_and_Dislocation_of_C1/C2_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C1/C2_Vertebrae'] = 1 x5.loc[x5['Subluxation_and_Dislocation_of_C2/C3_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C2/C3_Vertebrae'] = 0 x5.loc[x5['Subluxation_and_Dislocation_of_C2/C3_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C2/C3_Vertebrae'] = 1 x5.loc[x5['Subluxation_and_Dislocation_of_C3/C4_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C3/C4_Vertebrae'] = 0 x5.loc[x5['Subluxation_and_Dislocation_of_C3/C4_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C3/C4_Vertebrae'] = 1 x5.loc[x5['Subluxation_and_Dislocation_of_C4/C5_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C4/C5_Vertebrae'] = 0 x5.loc[x5['Subluxation_and_Dislocation_of_C4/C5_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C4/C5_Vertebrae'] = 1 x5.loc[x5['Subluxation_and_Dislocation_of_C5/C6_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C5/C6_Vertebrae'] = 0 x5.loc[x5['Subluxation_and_Dislocation_of_C5/C6_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C5/C6_Vertebrae'] = 1 x5.loc[x5['Subluxation_and_Dislocation_of_C6/C7_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C6/C7_Vertebrae'] = 0 x5.loc[x5['Subluxation_and_Dislocation_of_C6/C7_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C6/C7_Vertebrae'] = 1 x5.loc[x5['Subluxation_and_Dislocation_of_C7/T1_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C7/T1_Vertebrae'] = 0 x5.loc[x5['Subluxation_and_Dislocation_of_C7/T1_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C7/T1_Vertebrae'] = 1 x5.loc[x5['Concussion_and_Edema_of_cSC'] == 'No', 'Concussion_and_Edema_of_cSC'] = 0 x5.loc[x5['Concussion_and_Edema_of_cSC'] == 'Yes', 'Concussion_and_Edema_of_cSC'] = 1 x5.loc[x5['Complete_Lesion_of_cSC'] == 'No', 'Complete_Lesion_of_cSC'] = 0 x5.loc[x5['Complete_Lesion_of_cSC'] == 'Yes', 'Complete_Lesion_of_cSC'] = 1 x5.loc[x5['Anterior_Cord_Syndrome_of_cSC'] == 'No', 'Anterior_Cord_Syndrome_of_cSC'] = 0 x5.loc[x5['Anterior_Cord_Syndrome_of_cSC'] == 'Yes', 'Anterior_Cord_Syndrome_of_cSC'] = 1 x5.loc[x5['BrownSequard_Syndrome_of_cSC'] == 'No', 'BrownSequard_Syndrome_of_cSC'] = 0 x5.loc[x5['BrownSequard_Syndrome_of_cSC'] == 'Yes', 'BrownSequard_Syndrome_of_cSC'] = 1 x5.loc[x5['Other_Incomplete_Lesions_of_cSC'] == 'No', 'Other_Incomplete_Lesions_of_cSC'] = 0 x5.loc[x5['Other_Incomplete_Lesions_of_cSC'] == 'Yes', 'Other_Incomplete_Lesions_of_cSC'] = 1 x5.loc[x5['Current_Smoker'] == 'No', 'Current_Smoker'] = 0 x5.loc[x5['Current_Smoker'] == 'Yes', 'Current_Smoker'] = 1 x5.loc[x5['Current_Smoker'] == 'Unknown', 'Current_Smoker'] = 2 x5.loc[x5['Alcohol_Use_Disorder'] == 'No', 'Alcohol_Use_Disorder'] = 0 x5.loc[x5['Alcohol_Use_Disorder'] == 'Yes', 'Alcohol_Use_Disorder'] = 1 x5.loc[x5['Alcohol_Use_Disorder'] == 'Unknown', 'Alcohol_Use_Disorder'] = 2 x5.loc[x5['Substance_Abuse_Disorder'] == 'No', 'Substance_Abuse_Disorder'] = 0 x5.loc[x5['Substance_Abuse_Disorder'] == 'Yes', 'Substance_Abuse_Disorder'] = 1 x5.loc[x5['Substance_Abuse_Disorder'] == 'Unknown', 'Substance_Abuse_Disorder'] = 2 x5.loc[x5['Diabetes_Mellitus'] == 'No', 'Diabetes_Mellitus'] = 0 x5.loc[x5['Diabetes_Mellitus'] == 'Yes', 'Diabetes_Mellitus'] = 1 x5.loc[x5['Diabetes_Mellitus'] == 'Unknown', 'Diabetes_Mellitus'] = 2 x5.loc[x5['Hypertension'] == 'No', 'Hypertension'] = 0 x5.loc[x5['Hypertension'] == 'Yes', 'Hypertension'] = 1 x5.loc[x5['Hypertension'] == 'Unknown', 'Hypertension'] = 2 x5.loc[x5['Congestive_Heart_Failure'] == 'No', 'Congestive_Heart_Failure'] = 0 x5.loc[x5['Congestive_Heart_Failure'] == 'Yes', 'Congestive_Heart_Failure'] = 1 x5.loc[x5['Congestive_Heart_Failure'] == 'Unknown', 'Congestive_Heart_Failure'] = 2 x5.loc[x5['History_of_Myocardial_Infarction'] == 'No', 'History_of_Myocardial_Infarction'] = 0 x5.loc[x5['History_of_Myocardial_Infarction'] == 'Yes', 'History_of_Myocardial_Infarction'] = 1 x5.loc[x5['History_of_Myocardial_Infarction'] == 'Unknown', 'History_of_Myocardial_Infarction'] = 2 x5.loc[x5['Angina_Pectoris'] == 'No', 'Angina_Pectoris'] = 0 x5.loc[x5['Angina_Pectoris'] == 'Yes', 'Angina_Pectoris'] = 1 x5.loc[x5['Angina_Pectoris'] == 'Unknown', 'Angina_Pectoris'] = 2 x5.loc[x5['History_of_Cerebrovascular_Accident'] == 'No', 'History_of_Cerebrovascular_Accident'] = 0 x5.loc[x5['History_of_Cerebrovascular_Accident'] == 'Yes', 'History_of_Cerebrovascular_Accident'] = 1 x5.loc[x5['History_of_Cerebrovascular_Accident'] == 'Unknown', 'History_of_Cerebrovascular_Accident'] = 2 x5.loc[x5['Peripheral_Arterial_Disease'] == 'No', 'Peripheral_Arterial_Disease'] = 0 x5.loc[x5['Peripheral_Arterial_Disease'] == 'Yes', 'Peripheral_Arterial_Disease'] = 1 x5.loc[x5['Peripheral_Arterial_Disease'] == 'Unknown', 'Peripheral_Arterial_Disease'] = 2 x5.loc[x5['Chronic_Obstructive_Pulmonary_Disease'] == 'No', 'Chronic_Obstructive_Pulmonary_Disease'] = 0 x5.loc[x5['Chronic_Obstructive_Pulmonary_Disease'] == 'Yes', 'Chronic_Obstructive_Pulmonary_Disease'] = 1 x5.loc[x5['Chronic_Obstructive_Pulmonary_Disease'] == 'Unknown', 'Chronic_Obstructive_Pulmonary_Disease'] = 2 x5.loc[x5['Chronic_Renal_Failure'] == 'No', 'Chronic_Renal_Failure'] = 0 x5.loc[x5['Chronic_Renal_Failure'] == 'Yes', 'Chronic_Renal_Failure'] = 1 x5.loc[x5['Chronic_Renal_Failure'] == 'Unknown', 'Chronic_Renal_Failure'] = 2 x5.loc[x5['Cirrhosis'] == 'No', 'Cirrhosis'] = 0 x5.loc[x5['Cirrhosis'] == 'Yes', 'Cirrhosis'] = 1 x5.loc[x5['Cirrhosis'] == 'Unknown', 'Cirrhosis'] = 2 x5.loc[x5['Bleeding_Disorder'] == 'No', 'Bleeding_Disorder'] = 0 x5.loc[x5['Bleeding_Disorder'] == 'Yes', 'Bleeding_Disorder'] = 1 x5.loc[x5['Bleeding_Disorder'] == 'Unknown', 'Bleeding_Disorder'] = 2 x5.loc[x5['Disseminated_Cancer'] == 'No', 'Disseminated_Cancer'] = 0 x5.loc[x5['Disseminated_Cancer'] == 'Yes', 'Disseminated_Cancer'] = 1 x5.loc[x5['Disseminated_Cancer'] == 'Unknown', 'Disseminated_Cancer'] = 2 x5.loc[x5['Currently_Receiving_Chemotherapy_for_Cancer'] == 'No', 'Currently_Receiving_Chemotherapy_for_Cancer'] = 0 x5.loc[x5['Currently_Receiving_Chemotherapy_for_Cancer'] == 'Yes', 'Currently_Receiving_Chemotherapy_for_Cancer'] = 1 x5.loc[x5['Currently_Receiving_Chemotherapy_for_Cancer'] == 'Unknown', 'Currently_Receiving_Chemotherapy_for_Cancer'] = 2 x5.loc[x5['Dementia'] == 'No', 'Dementia'] = 0 x5.loc[x5['Dementia'] == 'Yes', 'Dementia'] = 1 x5.loc[x5['Dementia'] == 'Unknown', 'Dementia'] = 2 x5.loc[x5['Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder'] == 'No', 'Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder'] = 0 x5.loc[x5['Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder'] == 'Yes', 'Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder'] = 1 x5.loc[x5['Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder'] == 'Unknown', 'Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder'] = 2 x5.loc[x5['Mental_or_Personality_Disorder'] == 'No', 'Mental_or_Personality_Disorder'] = 0 x5.loc[x5['Mental_or_Personality_Disorder'] == 'Yes', 'Mental_or_Personality_Disorder'] = 1 x5.loc[x5['Mental_or_Personality_Disorder'] == 'Unknown', 'Mental_or_Personality_Disorder'] = 2 x5.loc[x5['Ability_to_Complete_AgeAppropriate_ADL'] == 'No', 'Ability_to_Complete_AgeAppropriate_ADL'] = 0 x5.loc[x5['Ability_to_Complete_AgeAppropriate_ADL'] == 'Yes', 'Ability_to_Complete_AgeAppropriate_ADL'] = 1 x5.loc[x5['Ability_to_Complete_AgeAppropriate_ADL'] == 'Unknown', 'Ability_to_Complete_AgeAppropriate_ADL'] = 2 x5.loc[x5['Pregnancy'] == 'Not applicable (male patient)', 'Pregnancy'] = 0 x5.loc[x5['Pregnancy'] == 'No', 'Pregnancy'] = 1 x5.loc[x5['Pregnancy'] == 'Yes', 'Pregnancy'] = 2 x5.loc[x5['Pregnancy'] == 'Unkown', 'Pregnancy'] = 3 x5.loc[x5['Anticoagulant_Therapy'] == 'No', 'Anticoagulant_Therapy'] = 0 x5.loc[x5['Anticoagulant_Therapy'] == 'Yes', 'Anticoagulant_Therapy'] = 1 x5.loc[x5['Anticoagulant_Therapy'] == 'Unknown', 'Anticoagulant_Therapy'] = 2 x5.loc[x5['Steroid_Use'] == 'No', 'Steroid_Use'] = 0 x5.loc[x5['Steroid_Use'] == 'Yes', 'Steroid_Use'] = 1 x5.loc[x5['Steroid_Use'] == 'Unknown', 'Steroid_Use'] = 2 x5.loc[x5['Transport_Mode'] == 'Ground ambulance', 'Transport_Mode'] = 0 x5.loc[x5['Transport_Mode'] == 'Private/public vehicle/walk-in', 'Transport_Mode'] = 1 x5.loc[x5['Transport_Mode'] == 'Air ambulance', 'Transport_Mode'] = 2 x5.loc[x5['Transport_Mode'] == 'Other/unknown', 'Transport_Mode'] = 3 x5.loc[x5['InterFacility_Transfer'] == 'No', 'InterFacility_Transfer'] = 0 x5.loc[x5['InterFacility_Transfer'] == 'Yes', 'InterFacility_Transfer'] = 1 x5.loc[x5['InterFacility_Transfer'] == 'Unknown', 'InterFacility_Transfer'] = 2 x5.loc[x5['Trauma_Type'] == 'Blunt', 'Trauma_Type'] = 0 x5.loc[x5['Trauma_Type'] == 'Penetrating', 'Trauma_Type'] = 1 x5.loc[x5['Trauma_Type'] == 'Other/unknown', 'Trauma_Type'] = 2 x5.loc[x5['Injury_Intent'] == 'Unintentional', 'Injury_Intent'] = 0 x5.loc[x5['Injury_Intent'] == 'Assault', 'Injury_Intent'] = 1 x5.loc[x5['Injury_Intent'] == 'Other/unknown', 'Injury_Intent'] = 2 x5.loc[x5['Mechanism_of_Injury'] == 'Fall', 'Mechanism_of_Injury'] = 0 x5.loc[x5['Mechanism_of_Injury'] == 'MVT occupant', 'Mechanism_of_Injury'] = 1 x5.loc[x5['Mechanism_of_Injury'] == 'Struck by or against', 'Mechanism_of_Injury'] = 2 x5.loc[x5['Mechanism_of_Injury'] == 'Other MVT', 'Mechanism_of_Injury'] = 3 x5.loc[x5['Mechanism_of_Injury'] == 'MVT motorcyclist', 'Mechanism_of_Injury'] = 4 x5.loc[x5['Mechanism_of_Injury'] == 'Other transport', 'Mechanism_of_Injury'] = 5 x5.loc[x5['Mechanism_of_Injury'] == 'Other pedal cyclist', 'Mechanism_of_Injury'] = 6 x5.loc[x5['Mechanism_of_Injury'] == 'MVT pedestrian', 'Mechanism_of_Injury'] = 7 x5.loc[x5['Mechanism_of_Injury'] == 'Firearm', 'Mechanism_of_Injury'] = 8 x5.loc[x5['Mechanism_of_Injury'] == 'Other/unknown', 'Mechanism_of_Injury'] = 9 x5.loc[x5['Protective_Device'] == 'None', 'Protective_Device'] = 0 x5.loc[x5['Protective_Device'] == 'Belt', 'Protective_Device'] = 1 x5.loc[x5['Protective_Device'] == 'Airbag present', 'Protective_Device'] = 2 x5.loc[x5['Protective_Device'] == 'Helmet', 'Protective_Device'] = 3 x5.loc[x5['Protective_Device'] == 'Other/unknown', 'Protective_Device'] = 4 x5.loc[x5['WorkRelated'] == 'No/unknown', 'WorkRelated'] = 0 x5.loc[x5['WorkRelated'] == 'Yes', 'WorkRelated'] = 1 x5.loc[x5['Surgical_Intervention'] == 'No', 'Surgical_Intervention'] = 0 x5.loc[x5['Surgical_Intervention'] == 'Yes', 'Surgical_Intervention'] = 1 x5.loc[x5['Alcohol_Screen'] == 'No', 'Alcohol_Screen'] = 0 x5.loc[x5['Alcohol_Screen'] == 'Yes', 'Alcohol_Screen'] = 1 x5.loc[x5['Alcohol_Screen'] == 'Unknown', 'Alcohol_Screen'] = 2 x5.loc[x5['Drug_Screen__Amphetamine'] == 'No', 'Drug_Screen__Amphetamine'] = 0 x5.loc[x5['Drug_Screen__Amphetamine'] == 'Yes', 'Drug_Screen__Amphetamine'] = 1 x5.loc[x5['Drug_Screen__Amphetamine'] == 'Not tested', 'Drug_Screen__Amphetamine'] = 2 x5.loc[x5['Drug_Screen__Barbiturate'] == 'No', 'Drug_Screen__Barbiturate'] = 0 x5.loc[x5['Drug_Screen__Barbiturate'] == 'Yes', 'Drug_Screen__Barbiturate'] = 1 x5.loc[x5['Drug_Screen__Barbiturate'] == 'Not tested', 'Drug_Screen__Barbiturate'] = 2 x5.loc[x5['Drug_Screen__Benzodiazepines'] == 'No', 'Drug_Screen__Benzodiazepines'] = 0 x5.loc[x5['Drug_Screen__Benzodiazepines'] == 'Yes', 'Drug_Screen__Benzodiazepines'] = 1 x5.loc[x5['Drug_Screen__Benzodiazepines'] == 'Not tested', 'Drug_Screen__Benzodiazepines'] = 2 x5.loc[x5['Drug_Screen__Cannabinoid'] == 'No', 'Drug_Screen__Cannabinoid'] = 0 x5.loc[x5['Drug_Screen__Cannabinoid'] == 'Yes', 'Drug_Screen__Cannabinoid'] = 1 x5.loc[x5['Drug_Screen__Cannabinoid'] == 'Not tested', 'Drug_Screen__Cannabinoid'] = 2 x5.loc[x5['Drug_Screen__Cocaine'] == 'No', 'Drug_Screen__Cocaine'] = 0 x5.loc[x5['Drug_Screen__Cocaine'] == 'Yes', 'Drug_Screen__Cocaine'] = 1 x5.loc[x5['Drug_Screen__Cocaine'] == 'Not tested', 'Drug_Screen__Cocaine'] = 2 x5.loc[x5['Drug_Screen__MDMA_or_Ecstasy'] == 'No', 'Drug_Screen__MDMA_or_Ecstasy'] = 0 x5.loc[x5['Drug_Screen__MDMA_or_Ecstasy'] == 'Yes', 'Drug_Screen__MDMA_or_Ecstasy'] = 1 x5.loc[x5['Drug_Screen__MDMA_or_Ecstasy'] == 'Not tested', 'Drug_Screen__MDMA_or_Ecstasy'] = 2 x5.loc[x5['Drug_Screen__Methadone'] == 'No', 'Drug_Screen__Methadone'] = 0 x5.loc[x5['Drug_Screen__Methadone'] == 'Yes', 'Drug_Screen__Methadone'] = 1 x5.loc[x5['Drug_Screen__Methadone'] == 'Not tested', 'Drug_Screen__Methadone'] = 2 x5.loc[x5['Drug_Screen__Methamphetamine'] == 'No', 'Drug_Screen__Methamphetamine'] = 0 x5.loc[x5['Drug_Screen__Methamphetamine'] == 'Yes', 'Drug_Screen__Methamphetamine'] = 1 x5.loc[x5['Drug_Screen__Methamphetamine'] == 'Not tested', 'Drug_Screen__Methamphetamine'] = 2 x5.loc[x5['Drug_Screen__Opioid'] == 'No', 'Drug_Screen__Opioid'] = 0 x5.loc[x5['Drug_Screen__Opioid'] == 'Yes', 'Drug_Screen__Opioid'] = 1 x5.loc[x5['Drug_Screen__Opioid'] == 'Not tested', 'Drug_Screen__Opioid'] = 2 x5.loc[x5['Drug_Screen__Oxycodone'] == 'No', 'Drug_Screen__Oxycodone'] = 0 x5.loc[x5['Drug_Screen__Oxycodone'] == 'Yes', 'Drug_Screen__Oxycodone'] = 1 x5.loc[x5['Drug_Screen__Oxycodone'] == 'Not tested', 'Drug_Screen__Oxycodone'] = 2 x5.loc[x5['Drug_Screen__Phencyclidine'] == 'No', 'Drug_Screen__Phencyclidine'] = 0 x5.loc[x5['Drug_Screen__Phencyclidine'] == 'Yes', 'Drug_Screen__Phencyclidine'] = 1 x5.loc[x5['Drug_Screen__Phencyclidine'] == 'Not tested', 'Drug_Screen__Phencyclidine'] = 2 x5.loc[x5['Drug_Screen__Tricyclic_Antidepressant'] == 'No', 'Drug_Screen__Tricyclic_Antidepressant'] = 0 x5.loc[x5['Drug_Screen__Tricyclic_Antidepressant'] == 'Yes', 'Drug_Screen__Tricyclic_Antidepressant'] = 1 x5.loc[x5['Drug_Screen__Tricyclic_Antidepressant'] == 'Not tested', 'Drug_Screen__Tricyclic_Antidepressant'] = 2 x5.loc[x5['ACS_Verification_Level'] == 'Level I Trauma Center', 'ACS_Verification_Level'] = 0 x5.loc[x5['ACS_Verification_Level'] == 'Level II Trauma Center', 'ACS_Verification_Level'] = 1 x5.loc[x5['ACS_Verification_Level'] == 'Level III Trauma Center', 'ACS_Verification_Level'] = 2 x5.loc[x5['ACS_Verification_Level'] == 'Unknown', 'ACS_Verification_Level'] = 3 x5.loc[x5['Hospital_Type'] == 'Non-profit', 'Hospital_Type'] = 0 x5.loc[x5['Hospital_Type'] == 'For profit', 'Hospital_Type'] = 1 x5.loc[x5['Hospital_Type'] == 'Government', 'Hospital_Type'] = 2 x5.loc[x5['Hospital_Type'] == 'Unknown', 'Hospital_Type'] = 3 x5.loc[x5['Facility_Bed_Size'] == 'More than 600', 'Facility_Bed_Size'] = 0 x5.loc[x5['Facility_Bed_Size'] == '401 to 600', 'Facility_Bed_Size'] = 1 x5.loc[x5['Facility_Bed_Size'] == '201 to 400', 'Facility_Bed_Size'] = 2 x5.loc[x5['Facility_Bed_Size'] == '200 or fewer', 'Facility_Bed_Size'] = 3 x5.loc[x5['Primary_Method_of_Payment'] == 'Medicare', 'Primary_Method_of_Payment'] = 0 x5.loc[x5['Primary_Method_of_Payment'] == 'Private/commercial insurance', 'Primary_Method_of_Payment'] = 1 x5.loc[x5['Primary_Method_of_Payment'] == 'Medicaid', 'Primary_Method_of_Payment'] = 2 x5.loc[x5['Primary_Method_of_Payment'] == 'Self-pay', 'Primary_Method_of_Payment'] = 3 x5.loc[x5['Primary_Method_of_Payment'] == 'Other/unknown', 'Primary_Method_of_Payment'] = 4 #Prepare validation data for the outcome 5 (complications). y5_valid = x5_valid.pop('OUTCOME') x5_valid.loc[x5_valid['Sex'] == 'Male', 'Sex'] = 0 x5_valid.loc[x5_valid['Sex'] == 'Female', 'Sex'] = 1 x5_valid.loc[x5_valid['Sex'] == 'Non-Binary', 'Sex'] = 2 x5_valid.loc[x5_valid['Sex'] == 'Unknown', 'Sex'] = 3 x5_valid.loc[x5_valid['Race'] == 'White', 'Race'] = 0 x5_valid.loc[x5_valid['Race'] == 'Black', 'Race'] = 1 x5_valid.loc[x5_valid['Race'] == 'Asian', 'Race'] = 2 x5_valid.loc[x5_valid['Race'] == 'Other/unknown', 'Race'] = 5 x5_valid.loc[x5_valid['Ethnicity'] == 'Not Hispanic or Latino', 'Ethnicity'] = 0 x5_valid.loc[x5_valid['Ethnicity'] == 'Hispanic or Latino', 'Ethnicity'] = 1 x5_valid.loc[x5_valid['Ethnicity'] == 'Unknown', 'Ethnicity'] = 2 x5_valid.loc[x5_valid['Supplemental_Oxygen'] == 'No supplemental oxygen', 'Supplemental_Oxygen'] = 0 x5_valid.loc[x5_valid['Supplemental_Oxygen'] == 'Supplemental oxygen', 'Supplemental_Oxygen'] = 1 x5_valid.loc[x5_valid['Supplemental_Oxygen'] == 'Unknown', 'Supplemental_Oxygen'] = 2 x5_valid.loc[x5_valid['Respiratory_Assistance'] == 'Unassisted respiratory rate', 'Respiratory_Assistance'] = 0 x5_valid.loc[x5_valid['Respiratory_Assistance'] == 'Assisted respiratory rate', 'Respiratory_Assistance'] = 1 x5_valid.loc[x5_valid['Respiratory_Assistance'] == 'Unknown', 'Respiratory_Assistance'] = 2 x5_valid.loc[x5_valid['Fracture_of_C1_Vertebra'] == 'No', 'Fracture_of_C1_Vertebra'] = 0 x5_valid.loc[x5_valid['Fracture_of_C1_Vertebra'] == 'Yes', 'Fracture_of_C1_Vertebra'] = 1 x5_valid.loc[x5_valid['Fracture_of_C2_Vertebra'] == 'No', 'Fracture_of_C2_Vertebra'] = 0 x5_valid.loc[x5_valid['Fracture_of_C2_Vertebra'] == 'Yes', 'Fracture_of_C2_Vertebra'] = 1 x5_valid.loc[x5_valid['Fracture_of_C3_Vertebra'] == 'No', 'Fracture_of_C3_Vertebra'] = 0 x5_valid.loc[x5_valid['Fracture_of_C3_Vertebra'] == 'Yes', 'Fracture_of_C3_Vertebra'] = 1 x5_valid.loc[x5_valid['Fracture_of_C4_Vertebra'] == 'No', 'Fracture_of_C4_Vertebra'] = 0 x5_valid.loc[x5_valid['Fracture_of_C4_Vertebra'] == 'Yes', 'Fracture_of_C4_Vertebra'] = 1 x5_valid.loc[x5_valid['Fracture_of_C5_Vertebra'] == 'No', 'Fracture_of_C5_Vertebra'] = 0 x5_valid.loc[x5_valid['Fracture_of_C5_Vertebra'] == 'Yes', 'Fracture_of_C5_Vertebra'] = 1 x5_valid.loc[x5_valid['Fracture_of_C6_Vertebra'] == 'No', 'Fracture_of_C6_Vertebra'] = 0 x5_valid.loc[x5_valid['Fracture_of_C6_Vertebra'] == 'Yes', 'Fracture_of_C6_Vertebra'] = 1 x5_valid.loc[x5_valid['Fracture_of_C7_Vertebra'] == 'No', 'Fracture_of_C7_Vertebra'] = 0 x5_valid.loc[x5_valid['Fracture_of_C7_Vertebra'] == 'Yes', 'Fracture_of_C7_Vertebra'] = 1 x5_valid.loc[x5_valid['Rupture_of_Cervical_Intervertebral_Disc'] == 'No', 'Rupture_of_Cervical_Intervertebral_Disc'] = 0 x5_valid.loc[x5_valid['Rupture_of_Cervical_Intervertebral_Disc'] == 'Yes', 'Rupture_of_Cervical_Intervertebral_Disc'] = 1 x5_valid.loc[x5_valid['Subluxation_and_Dislocation_of_C0/C1_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C0/C1_Vertebrae'] = 0 x5_valid.loc[x5_valid['Subluxation_and_Dislocation_of_C0/C1_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C0/C1_Vertebrae'] = 1 x5_valid.loc[x5_valid['Subluxation_and_Dislocation_of_C1/C2_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C1/C2_Vertebrae'] = 0 x5_valid.loc[x5_valid['Subluxation_and_Dislocation_of_C1/C2_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C1/C2_Vertebrae'] = 1 x5_valid.loc[x5_valid['Subluxation_and_Dislocation_of_C2/C3_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C2/C3_Vertebrae'] = 0 x5_valid.loc[x5_valid['Subluxation_and_Dislocation_of_C2/C3_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C2/C3_Vertebrae'] = 1 x5_valid.loc[x5_valid['Subluxation_and_Dislocation_of_C3/C4_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C3/C4_Vertebrae'] = 0 x5_valid.loc[x5_valid['Subluxation_and_Dislocation_of_C3/C4_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C3/C4_Vertebrae'] = 1 x5_valid.loc[x5_valid['Subluxation_and_Dislocation_of_C4/C5_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C4/C5_Vertebrae'] = 0 x5_valid.loc[x5_valid['Subluxation_and_Dislocation_of_C4/C5_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C4/C5_Vertebrae'] = 1 x5_valid.loc[x5_valid['Subluxation_and_Dislocation_of_C5/C6_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C5/C6_Vertebrae'] = 0 x5_valid.loc[x5_valid['Subluxation_and_Dislocation_of_C5/C6_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C5/C6_Vertebrae'] = 1 x5_valid.loc[x5_valid['Subluxation_and_Dislocation_of_C6/C7_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C6/C7_Vertebrae'] = 0 x5_valid.loc[x5_valid['Subluxation_and_Dislocation_of_C6/C7_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C6/C7_Vertebrae'] = 1 x5_valid.loc[x5_valid['Subluxation_and_Dislocation_of_C7/T1_Vertebrae'] == 'No', 'Subluxation_and_Dislocation_of_C7/T1_Vertebrae'] = 0 x5_valid.loc[x5_valid['Subluxation_and_Dislocation_of_C7/T1_Vertebrae'] == 'Yes', 'Subluxation_and_Dislocation_of_C7/T1_Vertebrae'] = 1 x5_valid.loc[x5_valid['Concussion_and_Edema_of_cSC'] == 'No', 'Concussion_and_Edema_of_cSC'] = 0 x5_valid.loc[x5_valid['Concussion_and_Edema_of_cSC'] == 'Yes', 'Concussion_and_Edema_of_cSC'] = 1 x5_valid.loc[x5_valid['Complete_Lesion_of_cSC'] == 'No', 'Complete_Lesion_of_cSC'] = 0 x5_valid.loc[x5_valid['Complete_Lesion_of_cSC'] == 'Yes', 'Complete_Lesion_of_cSC'] = 1 x5_valid.loc[x5_valid['Anterior_Cord_Syndrome_of_cSC'] == 'No', 'Anterior_Cord_Syndrome_of_cSC'] = 0 x5_valid.loc[x5_valid['Anterior_Cord_Syndrome_of_cSC'] == 'Yes', 'Anterior_Cord_Syndrome_of_cSC'] = 1 x5_valid.loc[x5_valid['BrownSequard_Syndrome_of_cSC'] == 'No', 'BrownSequard_Syndrome_of_cSC'] = 0 x5_valid.loc[x5_valid['BrownSequard_Syndrome_of_cSC'] == 'Yes', 'BrownSequard_Syndrome_of_cSC'] = 1 x5_valid.loc[x5_valid['Other_Incomplete_Lesions_of_cSC'] == 'No', 'Other_Incomplete_Lesions_of_cSC'] = 0 x5_valid.loc[x5_valid['Other_Incomplete_Lesions_of_cSC'] == 'Yes', 'Other_Incomplete_Lesions_of_cSC'] = 1 x5_valid.loc[x5_valid['Current_Smoker'] == 'No', 'Current_Smoker'] = 0 x5_valid.loc[x5_valid['Current_Smoker'] == 'Yes', 'Current_Smoker'] = 1 x5_valid.loc[x5_valid['Current_Smoker'] == 'Unknown', 'Current_Smoker'] = 2 x5_valid.loc[x5_valid['Alcohol_Use_Disorder'] == 'No', 'Alcohol_Use_Disorder'] = 0 x5_valid.loc[x5_valid['Alcohol_Use_Disorder'] == 'Yes', 'Alcohol_Use_Disorder'] = 1 x5_valid.loc[x5_valid['Alcohol_Use_Disorder'] == 'Unknown', 'Alcohol_Use_Disorder'] = 2 x5_valid.loc[x5_valid['Substance_Abuse_Disorder'] == 'No', 'Substance_Abuse_Disorder'] = 0 x5_valid.loc[x5_valid['Substance_Abuse_Disorder'] == 'Yes', 'Substance_Abuse_Disorder'] = 1 x5_valid.loc[x5_valid['Substance_Abuse_Disorder'] == 'Unknown', 'Substance_Abuse_Disorder'] = 2 x5_valid.loc[x5_valid['Diabetes_Mellitus'] == 'No', 'Diabetes_Mellitus'] = 0 x5_valid.loc[x5_valid['Diabetes_Mellitus'] == 'Yes', 'Diabetes_Mellitus'] = 1 x5_valid.loc[x5_valid['Diabetes_Mellitus'] == 'Unknown', 'Diabetes_Mellitus'] = 2 x5_valid.loc[x5_valid['Hypertension'] == 'No', 'Hypertension'] = 0 x5_valid.loc[x5_valid['Hypertension'] == 'Yes', 'Hypertension'] = 1 x5_valid.loc[x5_valid['Hypertension'] == 'Unknown', 'Hypertension'] = 2 x5_valid.loc[x5_valid['Congestive_Heart_Failure'] == 'No', 'Congestive_Heart_Failure'] = 0 x5_valid.loc[x5_valid['Congestive_Heart_Failure'] == 'Yes', 'Congestive_Heart_Failure'] = 1 x5_valid.loc[x5_valid['Congestive_Heart_Failure'] == 'Unknown', 'Congestive_Heart_Failure'] = 2 x5_valid.loc[x5_valid['History_of_Myocardial_Infarction'] == 'No', 'History_of_Myocardial_Infarction'] = 0 x5_valid.loc[x5_valid['History_of_Myocardial_Infarction'] == 'Yes', 'History_of_Myocardial_Infarction'] = 1 x5_valid.loc[x5_valid['History_of_Myocardial_Infarction'] == 'Unknown', 'History_of_Myocardial_Infarction'] = 2 x5_valid.loc[x5_valid['Angina_Pectoris'] == 'No', 'Angina_Pectoris'] = 0 x5_valid.loc[x5_valid['Angina_Pectoris'] == 'Yes', 'Angina_Pectoris'] = 1 x5_valid.loc[x5_valid['Angina_Pectoris'] == 'Unknown', 'Angina_Pectoris'] = 2 x5_valid.loc[x5_valid['History_of_Cerebrovascular_Accident'] == 'No', 'History_of_Cerebrovascular_Accident'] = 0 x5_valid.loc[x5_valid['History_of_Cerebrovascular_Accident'] == 'Yes', 'History_of_Cerebrovascular_Accident'] = 1 x5_valid.loc[x5_valid['History_of_Cerebrovascular_Accident'] == 'Unknown', 'History_of_Cerebrovascular_Accident'] = 2 x5_valid.loc[x5_valid['Peripheral_Arterial_Disease'] == 'No', 'Peripheral_Arterial_Disease'] = 0 x5_valid.loc[x5_valid['Peripheral_Arterial_Disease'] == 'Yes', 'Peripheral_Arterial_Disease'] = 1 x5_valid.loc[x5_valid['Peripheral_Arterial_Disease'] == 'Unknown', 'Peripheral_Arterial_Disease'] = 2 x5_valid.loc[x5_valid['Chronic_Obstructive_Pulmonary_Disease'] == 'No', 'Chronic_Obstructive_Pulmonary_Disease'] = 0 x5_valid.loc[x5_valid['Chronic_Obstructive_Pulmonary_Disease'] == 'Yes', 'Chronic_Obstructive_Pulmonary_Disease'] = 1 x5_valid.loc[x5_valid['Chronic_Obstructive_Pulmonary_Disease'] == 'Unknown', 'Chronic_Obstructive_Pulmonary_Disease'] = 2 x5_valid.loc[x5_valid['Chronic_Renal_Failure'] == 'No', 'Chronic_Renal_Failure'] = 0 x5_valid.loc[x5_valid['Chronic_Renal_Failure'] == 'Yes', 'Chronic_Renal_Failure'] = 1 x5_valid.loc[x5_valid['Chronic_Renal_Failure'] == 'Unknown', 'Chronic_Renal_Failure'] = 2 x5_valid.loc[x5_valid['Cirrhosis'] == 'No', 'Cirrhosis'] = 0 x5_valid.loc[x5_valid['Cirrhosis'] == 'Yes', 'Cirrhosis'] = 1 x5_valid.loc[x5_valid['Cirrhosis'] == 'Unknown', 'Cirrhosis'] = 2 x5_valid.loc[x5_valid['Bleeding_Disorder'] == 'No', 'Bleeding_Disorder'] = 0 x5_valid.loc[x5_valid['Bleeding_Disorder'] == 'Yes', 'Bleeding_Disorder'] = 1 x5_valid.loc[x5_valid['Bleeding_Disorder'] == 'Unknown', 'Bleeding_Disorder'] = 2 x5_valid.loc[x5_valid['Disseminated_Cancer'] == 'No', 'Disseminated_Cancer'] = 0 x5_valid.loc[x5_valid['Disseminated_Cancer'] == 'Yes', 'Disseminated_Cancer'] = 1 x5_valid.loc[x5_valid['Disseminated_Cancer'] == 'Unknown', 'Disseminated_Cancer'] = 2 x5_valid.loc[x5_valid['Currently_Receiving_Chemotherapy_for_Cancer'] == 'No', 'Currently_Receiving_Chemotherapy_for_Cancer'] = 0 x5_valid.loc[x5_valid['Currently_Receiving_Chemotherapy_for_Cancer'] == 'Yes', 'Currently_Receiving_Chemotherapy_for_Cancer'] = 1 x5_valid.loc[x5_valid['Currently_Receiving_Chemotherapy_for_Cancer'] == 'Unknown', 'Currently_Receiving_Chemotherapy_for_Cancer'] = 2 x5_valid.loc[x5_valid['Dementia'] == 'No', 'Dementia'] = 0 x5_valid.loc[x5_valid['Dementia'] == 'Yes', 'Dementia'] = 1 x5_valid.loc[x5_valid['Dementia'] == 'Unknown', 'Dementia'] = 2 x5_valid.loc[x5_valid['Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder'] == 'No', 'Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder'] = 0 x5_valid.loc[x5_valid['Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder'] == 'Yes', 'Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder'] = 1 x5_valid.loc[x5_valid['Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder'] == 'Unknown', 'Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder'] = 2 x5_valid.loc[x5_valid['Mental_or_Personality_Disorder'] == 'No', 'Mental_or_Personality_Disorder'] = 0 x5_valid.loc[x5_valid['Mental_or_Personality_Disorder'] == 'Yes', 'Mental_or_Personality_Disorder'] = 1 x5_valid.loc[x5_valid['Mental_or_Personality_Disorder'] == 'Unknown', 'Mental_or_Personality_Disorder'] = 2 x5_valid.loc[x5_valid['Ability_to_Complete_AgeAppropriate_ADL'] == 'No', 'Ability_to_Complete_AgeAppropriate_ADL'] = 0 x5_valid.loc[x5_valid['Ability_to_Complete_AgeAppropriate_ADL'] == 'Yes', 'Ability_to_Complete_AgeAppropriate_ADL'] = 1 x5_valid.loc[x5_valid['Ability_to_Complete_AgeAppropriate_ADL'] == 'Unknown', 'Ability_to_Complete_AgeAppropriate_ADL'] = 2 x5_valid.loc[x5_valid['Pregnancy'] == 'Not applicable (male patient)', 'Pregnancy'] = 0 x5_valid.loc[x5_valid['Pregnancy'] == 'No', 'Pregnancy'] = 1 x5_valid.loc[x5_valid['Pregnancy'] == 'Yes', 'Pregnancy'] = 2 x5_valid.loc[x5_valid['Pregnancy'] == 'Unkown', 'Pregnancy'] = 3 x5_valid.loc[x5_valid['Anticoagulant_Therapy'] == 'No', 'Anticoagulant_Therapy'] = 0 x5_valid.loc[x5_valid['Anticoagulant_Therapy'] == 'Yes', 'Anticoagulant_Therapy'] = 1 x5_valid.loc[x5_valid['Anticoagulant_Therapy'] == 'Unknown', 'Anticoagulant_Therapy'] = 2 x5_valid.loc[x5_valid['Steroid_Use'] == 'No', 'Steroid_Use'] = 0 x5_valid.loc[x5_valid['Steroid_Use'] == 'Yes', 'Steroid_Use'] = 1 x5_valid.loc[x5_valid['Steroid_Use'] == 'Unknown', 'Steroid_Use'] = 2 x5_valid.loc[x5_valid['Transport_Mode'] == 'Ground ambulance', 'Transport_Mode'] = 0 x5_valid.loc[x5_valid['Transport_Mode'] == 'Private/public vehicle/walk-in', 'Transport_Mode'] = 1 x5_valid.loc[x5_valid['Transport_Mode'] == 'Air ambulance', 'Transport_Mode'] = 2 x5_valid.loc[x5_valid['Transport_Mode'] == 'Other/unknown', 'Transport_Mode'] = 3 x5_valid.loc[x5_valid['InterFacility_Transfer'] == 'No', 'InterFacility_Transfer'] = 0 x5_valid.loc[x5_valid['InterFacility_Transfer'] == 'Yes', 'InterFacility_Transfer'] = 1 x5_valid.loc[x5_valid['InterFacility_Transfer'] == 'Unknown', 'InterFacility_Transfer'] = 2 x5_valid.loc[x5_valid['Trauma_Type'] == 'Blunt', 'Trauma_Type'] = 0 x5_valid.loc[x5_valid['Trauma_Type'] == 'Penetrating', 'Trauma_Type'] = 1 x5_valid.loc[x5_valid['Trauma_Type'] == 'Other/unknown', 'Trauma_Type'] = 2 x5_valid.loc[x5_valid['Injury_Intent'] == 'Unintentional', 'Injury_Intent'] = 0 x5_valid.loc[x5_valid['Injury_Intent'] == 'Assault', 'Injury_Intent'] = 1 x5_valid.loc[x5_valid['Injury_Intent'] == 'Other/unknown', 'Injury_Intent'] = 2 x5_valid.loc[x5_valid['Mechanism_of_Injury'] == 'Fall', 'Mechanism_of_Injury'] = 0 x5_valid.loc[x5_valid['Mechanism_of_Injury'] == 'MVT occupant', 'Mechanism_of_Injury'] = 1 x5_valid.loc[x5_valid['Mechanism_of_Injury'] == 'Struck by or against', 'Mechanism_of_Injury'] = 2 x5_valid.loc[x5_valid['Mechanism_of_Injury'] == 'Other MVT', 'Mechanism_of_Injury'] = 3 x5_valid.loc[x5_valid['Mechanism_of_Injury'] == 'MVT motorcyclist', 'Mechanism_of_Injury'] = 4 x5_valid.loc[x5_valid['Mechanism_of_Injury'] == 'Other transport', 'Mechanism_of_Injury'] = 5 x5_valid.loc[x5_valid['Mechanism_of_Injury'] == 'Other pedal cyclist', 'Mechanism_of_Injury'] = 6 x5_valid.loc[x5_valid['Mechanism_of_Injury'] == 'MVT pedestrian', 'Mechanism_of_Injury'] = 7 x5_valid.loc[x5_valid['Mechanism_of_Injury'] == 'Firearm', 'Mechanism_of_Injury'] = 8 x5_valid.loc[x5_valid['Mechanism_of_Injury'] == 'Other/unknown', 'Mechanism_of_Injury'] = 9 x5_valid.loc[x5_valid['Protective_Device'] == 'None', 'Protective_Device'] = 0 x5_valid.loc[x5_valid['Protective_Device'] == 'Belt', 'Protective_Device'] = 1 x5_valid.loc[x5_valid['Protective_Device'] == 'Airbag present', 'Protective_Device'] = 2 x5_valid.loc[x5_valid['Protective_Device'] == 'Helmet', 'Protective_Device'] = 3 x5_valid.loc[x5_valid['Protective_Device'] == 'Other/unknown', 'Protective_Device'] = 4 x5_valid.loc[x5_valid['WorkRelated'] == 'No/unknown', 'WorkRelated'] = 0 x5_valid.loc[x5_valid['WorkRelated'] == 'Yes', 'WorkRelated'] = 1 x5_valid.loc[x5_valid['Surgical_Intervention'] == 'No', 'Surgical_Intervention'] = 0 x5_valid.loc[x5_valid['Surgical_Intervention'] == 'Yes', 'Surgical_Intervention'] = 1 x5_valid.loc[x5_valid['Alcohol_Screen'] == 'No', 'Alcohol_Screen'] = 0 x5_valid.loc[x5_valid['Alcohol_Screen'] == 'Yes', 'Alcohol_Screen'] = 1 x5_valid.loc[x5_valid['Alcohol_Screen'] == 'Unknown', 'Alcohol_Screen'] = 2 x5_valid.loc[x5_valid['Drug_Screen__Amphetamine'] == 'No', 'Drug_Screen__Amphetamine'] = 0 x5_valid.loc[x5_valid['Drug_Screen__Amphetamine'] == 'Yes', 'Drug_Screen__Amphetamine'] = 1 x5_valid.loc[x5_valid['Drug_Screen__Amphetamine'] == 'Not tested', 'Drug_Screen__Amphetamine'] = 2 x5_valid.loc[x5_valid['Drug_Screen__Barbiturate'] == 'No', 'Drug_Screen__Barbiturate'] = 0 x5_valid.loc[x5_valid['Drug_Screen__Barbiturate'] == 'Yes', 'Drug_Screen__Barbiturate'] = 1 x5_valid.loc[x5_valid['Drug_Screen__Barbiturate'] == 'Not tested', 'Drug_Screen__Barbiturate'] = 2 x5_valid.loc[x5_valid['Drug_Screen__Benzodiazepines'] == 'No', 'Drug_Screen__Benzodiazepines'] = 0 x5_valid.loc[x5_valid['Drug_Screen__Benzodiazepines'] == 'Yes', 'Drug_Screen__Benzodiazepines'] = 1 x5_valid.loc[x5_valid['Drug_Screen__Benzodiazepines'] == 'Not tested', 'Drug_Screen__Benzodiazepines'] = 2 x5_valid.loc[x5_valid['Drug_Screen__Cannabinoid'] == 'No', 'Drug_Screen__Cannabinoid'] = 0 x5_valid.loc[x5_valid['Drug_Screen__Cannabinoid'] == 'Yes', 'Drug_Screen__Cannabinoid'] = 1 x5_valid.loc[x5_valid['Drug_Screen__Cannabinoid'] == 'Not tested', 'Drug_Screen__Cannabinoid'] = 2 x5_valid.loc[x5_valid['Drug_Screen__Cocaine'] == 'No', 'Drug_Screen__Cocaine'] = 0 x5_valid.loc[x5_valid['Drug_Screen__Cocaine'] == 'Yes', 'Drug_Screen__Cocaine'] = 1 x5_valid.loc[x5_valid['Drug_Screen__Cocaine'] == 'Not tested', 'Drug_Screen__Cocaine'] = 2 x5_valid.loc[x5_valid['Drug_Screen__MDMA_or_Ecstasy'] == 'No', 'Drug_Screen__MDMA_or_Ecstasy'] = 0 x5_valid.loc[x5_valid['Drug_Screen__MDMA_or_Ecstasy'] == 'Yes', 'Drug_Screen__MDMA_or_Ecstasy'] = 1 x5_valid.loc[x5_valid['Drug_Screen__MDMA_or_Ecstasy'] == 'Not tested', 'Drug_Screen__MDMA_or_Ecstasy'] = 2 x5_valid.loc[x5_valid['Drug_Screen__Methadone'] == 'No', 'Drug_Screen__Methadone'] = 0 x5_valid.loc[x5_valid['Drug_Screen__Methadone'] == 'Yes', 'Drug_Screen__Methadone'] = 1 x5_valid.loc[x5_valid['Drug_Screen__Methadone'] == 'Not tested', 'Drug_Screen__Methadone'] = 2 x5_valid.loc[x5_valid['Drug_Screen__Methamphetamine'] == 'No', 'Drug_Screen__Methamphetamine'] = 0 x5_valid.loc[x5_valid['Drug_Screen__Methamphetamine'] == 'Yes', 'Drug_Screen__Methamphetamine'] = 1 x5_valid.loc[x5_valid['Drug_Screen__Methamphetamine'] == 'Not tested', 'Drug_Screen__Methamphetamine'] = 2 x5_valid.loc[x5_valid['Drug_Screen__Opioid'] == 'No', 'Drug_Screen__Opioid'] = 0 x5_valid.loc[x5_valid['Drug_Screen__Opioid'] == 'Yes', 'Drug_Screen__Opioid'] = 1 x5_valid.loc[x5_valid['Drug_Screen__Opioid'] == 'Not tested', 'Drug_Screen__Opioid'] = 2 x5_valid.loc[x5_valid['Drug_Screen__Oxycodone'] == 'No', 'Drug_Screen__Oxycodone'] = 0 x5_valid.loc[x5_valid['Drug_Screen__Oxycodone'] == 'Yes', 'Drug_Screen__Oxycodone'] = 1 x5_valid.loc[x5_valid['Drug_Screen__Oxycodone'] == 'Not tested', 'Drug_Screen__Oxycodone'] = 2 x5_valid.loc[x5_valid['Drug_Screen__Phencyclidine'] == 'No', 'Drug_Screen__Phencyclidine'] = 0 x5_valid.loc[x5_valid['Drug_Screen__Phencyclidine'] == 'Yes', 'Drug_Screen__Phencyclidine'] = 1 x5_valid.loc[x5_valid['Drug_Screen__Phencyclidine'] == 'Not tested', 'Drug_Screen__Phencyclidine'] = 2 x5_valid.loc[x5_valid['Drug_Screen__Tricyclic_Antidepressant'] == 'No', 'Drug_Screen__Tricyclic_Antidepressant'] = 0 x5_valid.loc[x5_valid['Drug_Screen__Tricyclic_Antidepressant'] == 'Yes', 'Drug_Screen__Tricyclic_Antidepressant'] = 1 x5_valid.loc[x5_valid['Drug_Screen__Tricyclic_Antidepressant'] == 'Not tested', 'Drug_Screen__Tricyclic_Antidepressant'] = 2 x5_valid.loc[x5_valid['ACS_Verification_Level'] == 'Level I Trauma Center', 'ACS_Verification_Level'] = 0 x5_valid.loc[x5_valid['ACS_Verification_Level'] == 'Level II Trauma Center', 'ACS_Verification_Level'] = 1 x5_valid.loc[x5_valid['ACS_Verification_Level'] == 'Level III Trauma Center', 'ACS_Verification_Level'] = 2 x5_valid.loc[x5_valid['ACS_Verification_Level'] == 'Unknown', 'ACS_Verification_Level'] = 3 x5_valid.loc[x5_valid['Hospital_Type'] == 'Non-profit', 'Hospital_Type'] = 0 x5_valid.loc[x5_valid['Hospital_Type'] == 'For profit', 'Hospital_Type'] = 1 x5_valid.loc[x5_valid['Hospital_Type'] == 'Government', 'Hospital_Type'] = 2 x5_valid.loc[x5_valid['Hospital_Type'] == 'Unknown', 'Hospital_Type'] = 3 x5_valid.loc[x5_valid['Facility_Bed_Size'] == 'More than 600', 'Facility_Bed_Size'] = 0 x5_valid.loc[x5_valid['Facility_Bed_Size'] == '401 to 600', 'Facility_Bed_Size'] = 1 x5_valid.loc[x5_valid['Facility_Bed_Size'] == '201 to 400', 'Facility_Bed_Size'] = 2 x5_valid.loc[x5_valid['Facility_Bed_Size'] == '200 or fewer', 'Facility_Bed_Size'] = 3 x5_valid.loc[x5_valid['Primary_Method_of_Payment'] == 'Medicare', 'Primary_Method_of_Payment'] = 0 x5_valid.loc[x5_valid['Primary_Method_of_Payment'] == 'Private/commercial insurance', 'Primary_Method_of_Payment'] = 1 x5_valid.loc[x5_valid['Primary_Method_of_Payment'] == 'Medicaid', 'Primary_Method_of_Payment'] = 2 x5_valid.loc[x5_valid['Primary_Method_of_Payment'] == 'Self-pay', 'Primary_Method_of_Payment'] = 3 x5_valid.loc[x5_valid['Primary_Method_of_Payment'] == 'Other/unknown', 'Primary_Method_of_Payment'] = 4 #Define categorical variables categorical_columns = ['Sex', 'Ethnicity', 'Supplemental_Oxygen', 'Respiratory_Assistance', 'Fracture_of_C1_Vertebra', 'Fracture_of_C2_Vertebra', 'Fracture_of_C3_Vertebra', 'Fracture_of_C4_Vertebra', 'Fracture_of_C5_Vertebra', 'Fracture_of_C6_Vertebra', 'Fracture_of_C7_Vertebra', 'Rupture_of_Cervical_Intervertebral_Disc', 'Subluxation_and_Dislocation_of_C0/C1_Vertebrae', 'Subluxation_and_Dislocation_of_C1/C2_Vertebrae', 'Subluxation_and_Dislocation_of_C2/C3_Vertebrae', 'Subluxation_and_Dislocation_of_C3/C4_Vertebrae', 'Subluxation_and_Dislocation_of_C4/C5_Vertebrae', 'Subluxation_and_Dislocation_of_C5/C6_Vertebrae', 'Subluxation_and_Dislocation_of_C6/C7_Vertebrae', 'Subluxation_and_Dislocation_of_C7/T1_Vertebrae', 'Concussion_and_Edema_of_cSC', 'Complete_Lesion_of_cSC', 'Anterior_Cord_Syndrome_of_cSC', 'BrownSequard_Syndrome_of_cSC', 'Other_Incomplete_Lesions_of_cSC', 'Current_Smoker', 'Alcohol_Use_Disorder', 'Substance_Abuse_Disorder', 'Diabetes_Mellitus', 'Hypertension', 'Congestive_Heart_Failure', 'History_of_Myocardial_Infarction', 'Angina_Pectoris', 'History_of_Cerebrovascular_Accident', 'Peripheral_Arterial_Disease', 'Chronic_Obstructive_Pulmonary_Disease', 'Chronic_Renal_Failure', 'Cirrhosis', 'Bleeding_Disorder', 'Disseminated_Cancer', 'Currently_Receiving_Chemotherapy_for_Cancer', 'Dementia', 'Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder', 'Mental_or_Personality_Disorder', 'Ability_to_Complete_AgeAppropriate_ADL', 'Pregnancy', 'Anticoagulant_Therapy', 'Steroid_Use', 'Transport_Mode', 'InterFacility_Transfer', 'Trauma_Type', 'Injury_Intent', 'Mechanism_of_Injury', 'WorkRelated', 'Alcohol_Screen', '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', 'Protective_Device', 'Surgical_Intervention'] #Assign hyperparameters. y1_params = {'criterion': 'entropy', 'max_depth': 59, 'n_estimators': 1100, 'min_samples_leaf': 3, 'min_samples_split': 10, 'random_state': 31} y2_params = {'objective': 'Logloss', 'colsample_bylevel': 0.02893626365611705, 'depth': 9, 'boosting_type': 'Plain', 'bootstrap_type': 'Bayesian', 'bagging_temperature': 0.8396785798333539, 'used_ram_limit': '3gb', 'eval_metric': 'AUC', 'random_state': 31} y3_params = {'criterion': 'entropy', 'max_depth': 44, 'n_estimators': 1000, 'min_samples_leaf': 2, 'min_samples_split': 7, 'random_state': 31} y4_params = {'objective': 'CrossEntropy', 'colsample_bylevel': 0.058926810135424286, 'depth': 12, 'boosting_type': 'Ordered', 'bootstrap_type': 'Bayesian', 'bagging_temperature': 5.435346894873128, 'used_ram_limit': '3gb', 'eval_metric': 'AUC', 'random_state': 31} y5_params = {'objective': 'binary:logistic', 'booster': 'gbtree', 'lambda': 0.04557510948087113, 'alpha': 0.0005750751437574057, 'max_depth': 7, 'eta': 0.18615547823824322, 'gamma': 5.022508868242294e-05, 'grow_policy': 'lossguide', 'eval_metric': 'auc', 'verbosity': 0, 'seed': 31} #Training models. from sklearn.ensemble import RandomForestClassifier rf = RandomForestClassifier(**y1_params) y1_model_rf = rf.fit(x1, y1) y1_explainer_rf = shap.TreeExplainer(y1_model_rf) y1_calib_probs = y1_model_rf.predict_proba(x1_valid) y1_calib_model = LogisticRegression() y1_calib_model = y1_calib_model.fit(y1_calib_probs, y1_valid) from catboost import CatBoostClassifier cb = CatBoostClassifier(**y2_params) y2_model_cb = cb.fit(x2, y2) y2_explainer_cb = shap.TreeExplainer(y2_model_cb) y2_calib_probs = y2_model_cb.predict_proba(x2_valid) y2_calib_model = LogisticRegression() y2_calib_model = y2_calib_model.fit(y2_calib_probs, y2_valid) from sklearn.ensemble import RandomForestClassifier rf = RandomForestClassifier(**y3_params) y3_model_rf = rf.fit(x3, y3) y3_explainer_rf = shap.TreeExplainer(y3_model_rf) y3_calib_probs = y3_model_rf.predict_proba(x3_valid) y3_calib_model = LogisticRegression() y3_calib_model = y3_calib_model.fit(y3_calib_probs, y3_valid) from catboost import CatBoostClassifier cb = CatBoostClassifier(**y4_params) y4_model_cb = cb.fit(x4, y4) y4_explainer_cb = shap.TreeExplainer(y4_model_cb) y4_calib_probs = y4_model_cb.predict_proba(x4_valid) y4_calib_model = LogisticRegression() y4_calib_model = y4_calib_model.fit(y4_calib_probs, y4_valid) from xgboost import XGBClassifier xgb = XGBClassifier(**y5_params) y5_model_xgb = xgb.fit(x5, y5) y5_explainer_xgb = shap.TreeExplainer(y5_model_xgb) y5_calib_probs = y5_model_xgb.predict_proba(x5_valid) y5_calib_model = LogisticRegression() y5_calib_model = y5_calib_model.fit(y5_calib_probs, y5_valid) output_y1 = ( """
The predicted risk of in-hospital mortality:

{:.2f}%

""" ) output_y2 = ( """
The predicted risk of non-home discharge:

{:.2f}%

""" ) output_y3 = ( """
The predicted risk of prolonged length of stay:

{:.2f}%

""" ) output_y4 = ( """
The predicted risk of prolonged length of ICU stay:

{:.2f}%

""" ) output_y5 = ( """
The predicted risk of major complications:

{:.2f}%

""" ) #Define predict for y1. def y1_predict_xgb(*args): df1 = pd.DataFrame([args], columns=x1.columns) pos_pred = y1_model_xgb.predict_proba(df1) pos_pred = y1_calib_model.predict_proba(pos_pred) prob = pos_pred[0][1] output = output_y1.format(prob * 100) return output def y1_predict_lgb(*args): df1 = pd.DataFrame([args], columns=x1.columns) pos_pred = y1_model_lgb.predict_proba(df1) pos_pred = y1_calib_model.predict_proba(pos_pred) prob = pos_pred[0][1] output = output_y1.format(prob * 100) return output def y1_predict_cb(*args): df1 = pd.DataFrame([args], columns=x1.columns) pos_pred = y1_model_cb.predict_proba(df1) pos_pred = y1_calib_model.predict_proba(pos_pred) prob = pos_pred[0][1] output = output_y1.format(prob * 100) return output def y1_predict_rf(*args): df1 = pd.DataFrame([args], columns=x1.columns) pos_pred = y1_model_rf.predict_proba(df1) pos_pred = y1_calib_model.predict_proba(pos_pred) prob = pos_pred[0][1] output = output_y1.format(prob * 100) return output #Define predict for y2. def y2_predict_xgb(*args): df2 = pd.DataFrame([args], columns=x2.columns) pos_pred = y2_model_xgb.predict_proba(df2) pos_pred = y2_calib_model.predict_proba(pos_pred) prob = pos_pred[0][1] output = output_y2.format(prob * 100) return output def y2_predict_lgb(*args): df2 = pd.DataFrame([args], columns=x2.columns) pos_pred = y2_model_lgb.predict_proba(df2) pos_pred = y2_calib_model.predict_proba(pos_pred) prob = pos_pred[0][1] output = output_y2.format(prob * 100) return output def y2_predict_cb(*args): df2 = pd.DataFrame([args], columns=x2.columns) pos_pred = y2_model_cb.predict_proba(df2) pos_pred = y2_calib_model.predict_proba(pos_pred) prob = pos_pred[0][1] output = output_y2.format(prob * 100) return output def y2_predict_rf(*args): df2 = pd.DataFrame([args], columns=x2.columns) pos_pred = y2_model_rf.predict_proba(df2) pos_pred = y2_calib_model.predict_proba(pos_pred) prob = pos_pred[0][1] output = output_y2.format(prob * 100) return output #Define predict for y3. def y3_predict_xgb(*args): df3 = pd.DataFrame([args], columns=x3.columns) pos_pred = y3_model_xgb.predict_proba(df3) pos_pred = y3_calib_model.predict_proba(pos_pred) prob = pos_pred[0][1] output = output_y3.format(prob * 100) return output def y3_predict_lgb(*args): df3 = pd.DataFrame([args], columns=x3.columns) pos_pred = y3_model_lgb.predict_proba(df3) pos_pred = y3_calib_model.predict_proba(pos_pred) prob = pos_pred[0][1] output = output_y3.format(prob * 100) return output def y3_predict_cb(*args): df3 = pd.DataFrame([args], columns=x3.columns) pos_pred = y3_model_cb.predict_proba(df3) pos_pred = y3_calib_model.predict_proba(pos_pred) prob = pos_pred[0][1] output = output_y3.format(prob * 100) return output def y3_predict_rf(*args): df3 = pd.DataFrame([args], columns=x3.columns) pos_pred = y3_model_rf.predict_proba(df3) pos_pred = y3_calib_model.predict_proba(pos_pred) prob = pos_pred[0][1] output = output_y3.format(prob * 100) return output #Define predict for y4. def y4_predict_xgb(*args): df4 = pd.DataFrame([args], columns=x4.columns) pos_pred = y4_model_xgb.predict_proba(df4) pos_pred = y4_calib_model.predict_proba(pos_pred) prob = pos_pred[0][1] output = output_y4.format(prob * 100) return output def y4_predict_lgb(*args): df4 = pd.DataFrame([args], columns=x4.columns) pos_pred = y4_model_lgb.predict_proba(df4) pos_pred = y4_calib_model.predict_proba(pos_pred) prob = pos_pred[0][1] output = output_y4.format(prob * 100) return output def y4_predict_cb(*args): df4 = pd.DataFrame([args], columns=x4.columns) pos_pred = y4_model_cb.predict_proba(df4) pos_pred = y4_calib_model.predict_proba(pos_pred) prob = pos_pred[0][1] output = output_y4.format(prob * 100) return output def y4_predict_rf(*args): df4 = pd.DataFrame([args], columns=x4.columns) pos_pred = y4_model_rf.predict_proba(df4) pos_pred = y4_calib_model.predict_proba(pos_pred) prob = pos_pred[0][1] output = output_y4.format(prob * 100) return output #Define predict for y5. def y5_predict_xgb(*args): df5 = pd.DataFrame([args], columns=x5.columns) pos_pred = y5_model_xgb.predict_proba(df5) pos_pred = y5_calib_model.predict_proba(pos_pred) prob = pos_pred[0][1] output = output_y5.format(prob * 100) return output def y5_predict_lgb(*args): df5 = pd.DataFrame([args], columns=x5.columns) pos_pred = y5_model_lgb.predict_proba(df5) pos_pred = y5_calib_model.predict_proba(pos_pred) prob = pos_pred[0][1] output = output_y5.format(prob * 100) return output def y5_predict_cb(*args): df5 = pd.DataFrame([args], columns=x5.columns) pos_pred = y5_model_cb.predict_proba(df5) pos_pred = y5_calib_model.predict_proba(pos_pred) prob = pos_pred[0][1] output = output_y5.format(prob * 100) return output def y5_predict_rf(*args): df5 = pd.DataFrame([args], columns=x5.columns) pos_pred = y5_model_rf.predict_proba(df5) pos_pred = y5_calib_model.predict_proba(pos_pred) prob = pos_pred[0][1] output = output_y5.format(prob * 100) return output #Define function for wrapping feature labels. def wrap_labels(ax, width, break_long_words=False): labels = [] for label in ax.get_yticklabels(): text = label.get_text() labels.append(textwrap.fill(text, width=width, break_long_words=break_long_words)) ax.set_yticklabels(labels, rotation=0) #Define interpret for y1 (mortality). def y1_interpret_xgb(*args): df1 = pd.DataFrame([args], columns=x1.columns) shap_values1 = y1_explainer_xgb.shap_values(xgb.DMatrix(df1)) shap_values1 = np.abs(shap_values1) shap.bar_plot(shap_values1[0], max_display = 10, show = False, feature_names = f1_names) fig = plt.gcf() ax = plt.gca() wrap_labels(ax, 20) ax.figure plt.tight_layout() fig.set_figheight(7) fig.set_figwidth(9) plt.xlabel("SHAP value (impact on model output)", fontsize =12, fontweight = 'heavy', labelpad = 8) plt.tick_params(axis="y",direction="out", labelsize = 12) plt.tick_params(axis="x",direction="out", labelsize = 12) return fig def y1_interpret_lgb(*args): df1 = pd.DataFrame([args], columns=x1.columns) shap_values1 = y1_explainer_lgb.shap_values(df1) shap_values1 = np.abs(shap_values1) shap.bar_plot(shap_values1[0][0], max_display = 10, show = False, feature_names = f1_names) fig = plt.gcf() ax = plt.gca() wrap_labels(ax, 20) ax.figure plt.tight_layout() fig.set_figheight(7) fig.set_figwidth(9) plt.xlabel("SHAP value (impact on model output)", fontsize =12, fontweight = 'heavy', labelpad = 8) plt.tick_params(axis="y",direction="out", labelsize = 12) plt.tick_params(axis="x",direction="out", labelsize = 12) return fig def y1_interpret_cb(*args): df1 = pd.DataFrame([args], columns=x2.columns) shap_values1 = y2_explainer_cb.shap_values(Pool(df1)) shap_values1 = np.abs(shap_values1) shap.bar_plot(shap_values1[0], max_display = 10, show = False, feature_names = f1_names) fig = plt.gcf() ax = plt.gca() wrap_labels(ax, 20) ax.figure plt.tight_layout() fig.set_figheight(7) fig.set_figwidth(9) plt.xlabel("SHAP value (impact on model output)", fontsize =12, fontweight = 'heavy', labelpad = 8) plt.tick_params(axis="y",direction="out", labelsize = 12) plt.tick_params(axis="x",direction="out", labelsize = 12) return fig def y1_interpret_rf(*args): df1 = pd.DataFrame([args], columns=x1.columns) shap_values1 = y1_explainer_rf.shap_values(df1) shap_values1 = np.abs(shap_values1) shap.bar_plot(shap_values1[0][0], max_display = 10, show = False, feature_names = f1_names) fig = plt.gcf() ax = plt.gca() wrap_labels(ax, 20) ax.figure plt.tight_layout() fig.set_figheight(7) fig.set_figwidth(9) plt.xlabel("SHAP value (impact on model output)", fontsize =12, fontweight = 'heavy', labelpad = 8) plt.tick_params(axis="y",direction="out", labelsize = 12) plt.tick_params(axis="x",direction="out", labelsize = 12) return fig #Define interpret for y2 (discharge). def y2_interpret_xgb(*args): df2 = pd.DataFrame([args], columns=x2.columns) shap_values2 = y2_explainer_xgb.shap_values(xgb.DMatrix(df2)) shap_values2 = np.abs(shap_values2) shap.bar_plot(shap_values2[0], max_display = 10, show = False, feature_names = f2_names) fig = plt.gcf() ax = plt.gca() wrap_labels(ax, 20) ax.figure plt.tight_layout() fig.set_figheight(7) fig.set_figwidth(9) plt.xlabel("SHAP value (impact on model output)", fontsize =12, fontweight = 'heavy', labelpad = 8) plt.tick_params(axis="y",direction="out", labelsize = 12) plt.tick_params(axis="x",direction="out", labelsize = 12) return fig def y2_interpret_lgb(*args): df2 = pd.DataFrame([args], columns=x2.columns) shap_values2 = y2_explainer_lgb.shap_values(df2) shap_values2 = np.abs(shap_values2) shap.bar_plot(shap_values2[0][0], max_display = 10, show = False, feature_names = f2_names) fig = plt.gcf() ax = plt.gca() wrap_labels(ax, 20) ax.figure plt.tight_layout() fig.set_figheight(7) fig.set_figwidth(9) plt.xlabel("SHAP value (impact on model output)", fontsize =12, fontweight = 'heavy', labelpad = 8) plt.tick_params(axis="y",direction="out", labelsize = 12) plt.tick_params(axis="x",direction="out", labelsize = 12) return fig def y2_interpret_cb(*args): df2 = pd.DataFrame([args], columns=x2.columns) shap_values2 = y2_explainer_cb.shap_values(Pool(df2)) shap_values2 = np.abs(shap_values2) shap.bar_plot(shap_values2[0], max_display = 10, show = False, feature_names = f2_names) fig = plt.gcf() ax = plt.gca() wrap_labels(ax, 20) ax.figure plt.tight_layout() fig.set_figheight(7) fig.set_figwidth(9) plt.xlabel("SHAP value (impact on model output)", fontsize =12, fontweight = 'heavy', labelpad = 8) plt.tick_params(axis="y",direction="out", labelsize = 12) plt.tick_params(axis="x",direction="out", labelsize = 12) return fig def y2_interpret_rf(*args): df2 = pd.DataFrame([args], columns=x2.columns) df2 = df2.astype({col: "category" for col in categorical_columns}) shap_values2 = y2_explainer_rf.shap_values(df2) shap_values2 = np.abs(shap_values2) shap.bar_plot(shap_values2[0][0], max_display = 10, show = False, feature_names = f2_names) fig = plt.gcf() ax = plt.gca() wrap_labels(ax, 20) ax.figure plt.tight_layout() fig.set_figheight(7) fig.set_figwidth(9) plt.xlabel("SHAP value (impact on model output)", fontsize =12, fontweight = 'heavy', labelpad = 8) plt.tick_params(axis="y",direction="out", labelsize = 12) plt.tick_params(axis="x",direction="out", labelsize = 12) return fig #Define interpret for y3 (LOS). def y3_interpret_xgb(*args): df3 = pd.DataFrame([args], columns=x3.columns) shap_values3 = y3_explainer_xgb.shap_values(xgb.DMatrix(df3)) shap_values3 = np.abs(shap_values3) shap.bar_plot(shap_values3[0], max_display = 10, show = False, feature_names = f3_names) fig = plt.gcf() ax = plt.gca() wrap_labels(ax, 20) ax.figure plt.tight_layout() fig.set_figheight(7) fig.set_figwidth(9) plt.xlabel("SHAP value (impact on model output)", fontsize =12, fontweight = 'heavy', labelpad = 8) plt.tick_params(axis="y",direction="out", labelsize = 12) plt.tick_params(axis="x",direction="out", labelsize = 12) return fig def y3_interpret_lgb(*args): df3 = pd.DataFrame([args], columns=x3.columns) shap_values3 = y3_explainer_lgb.shap_values(df3) shap_values3 = np.abs(shap_values3) shap.bar_plot(shap_values3[0][0], max_display = 10, show = False, feature_names = f3_names) fig = plt.gcf() ax = plt.gca() wrap_labels(ax, 20) ax.figure plt.tight_layout() fig.set_figheight(7) fig.set_figwidth(9) plt.xlabel("SHAP value (impact on model output)", fontsize =12, fontweight = 'heavy', labelpad = 8) plt.tick_params(axis="y",direction="out", labelsize = 12) plt.tick_params(axis="x",direction="out", labelsize = 12) return fig def y3_interpret_cb(*args): df3 = pd.DataFrame([args], columns=x3.columns) shap_values3 = y3_explainer_cb.shap_values(Pool(df3)) shap_values3 = np.abs(shap_values3) shap.bar_plot(shap_values3[0], max_display = 10, show = False, feature_names = f3_names) fig = plt.gcf() ax = plt.gca() wrap_labels(ax, 20) ax.figure plt.tight_layout() fig.set_figheight(7) fig.set_figwidth(9) plt.xlabel("SHAP value (impact on model output)", fontsize =12, fontweight = 'heavy', labelpad = 8) plt.tick_params(axis="y",direction="out", labelsize = 12) plt.tick_params(axis="x",direction="out", labelsize = 12) return fig def y3_interpret_rf(*args): df3 = pd.DataFrame([args], columns=x3.columns) shap_values3 = y3_explainer_rf.shap_values(df3) shap_values3 = np.abs(shap_values3) shap.bar_plot(shap_values3[0][0], max_display = 10, show = False, feature_names = f3_names) fig = plt.gcf() ax = plt.gca() wrap_labels(ax, 20) ax.figure plt.tight_layout() fig.set_figheight(7) fig.set_figwidth(9) plt.xlabel("SHAP value (impact on model output)", fontsize =12, fontweight = 'heavy', labelpad = 8) plt.tick_params(axis="y",direction="out", labelsize = 12) plt.tick_params(axis="x",direction="out", labelsize = 12) return fig #Define interpret for y4 (ICU LOS). def y4_interpret_xgb(*args): df4 = pd.DataFrame([args], columns=x4.columns) shap_values4 = y4_explainer_xgb.shap_values(xgb.DMatrix(df4)) shap_values4 = np.abs(shap_values4) shap.bar_plot(shap_values4[0], max_display = 10, show = False, feature_names = f4_names) fig = plt.gcf() ax = plt.gca() wrap_labels(ax, 20) ax.figure plt.tight_layout() fig.set_figheight(7) fig.set_figwidth(9) plt.xlabel("SHAP value (impact on model output)", fontsize =12, fontweight = 'heavy', labelpad = 8) plt.tick_params(axis="y",direction="out", labelsize = 12) plt.tick_params(axis="x",direction="out", labelsize = 12) return fig def y4_interpret_lgb(*args): df4 = pd.DataFrame([args], columns=x4.columns) shap_values4 = y4_explainer_lgb.shap_values(df4) shap_values4 = np.abs(shap_values4) shap.bar_plot(shap_values4[0][0], max_display = 10, show = False, feature_names = f4_names) fig = plt.gcf() ax = plt.gca() wrap_labels(ax, 20) ax.figure plt.tight_layout() fig.set_figheight(7) fig.set_figwidth(9) plt.xlabel("SHAP value (impact on model output)", fontsize =12, fontweight = 'heavy', labelpad = 8) plt.tick_params(axis="y",direction="out", labelsize = 12) plt.tick_params(axis="x",direction="out", labelsize = 12) return fig def y4_interpret_cb(*args): df4 = pd.DataFrame([args], columns=x4.columns) shap_values4 = y4_explainer_cb.shap_values(Pool(df4)) shap_values4 = np.abs(shap_values4) shap.bar_plot(shap_values4[0], max_display = 10, show = False, feature_names = f4_names) fig = plt.gcf() ax = plt.gca() wrap_labels(ax, 20) ax.figure plt.tight_layout() fig.set_figheight(7) fig.set_figwidth(9) plt.xlabel("SHAP value (impact on model output)", fontsize =12, fontweight = 'heavy', labelpad = 8) plt.tick_params(axis="y",direction="out", labelsize = 12) plt.tick_params(axis="x",direction="out", labelsize = 12) return fig def y4_interpret_rf(*args): df4 = pd.DataFrame([args], columns=x4.columns) shap_values4 = y4_explainer.shap_values(df4) shap_values4 = np.abs(shap_values4) shap.bar_plot(shap_values4[0][0], max_display = 10, show = False, feature_names = f4_names) fig = plt.gcf() ax = plt.gca() wrap_labels(ax, 20) ax.figure plt.tight_layout() fig.set_figheight(7) fig.set_figwidth(9) plt.xlabel("SHAP value (impact on model output)", fontsize =12, fontweight = 'heavy', labelpad = 8) plt.tick_params(axis="y",direction="out", labelsize = 12) plt.tick_params(axis="x",direction="out", labelsize = 12) return fig #Define interpret for y5 (complications). def y5_interpret_xgb(*args): df5 = pd.DataFrame([args], columns=x5.columns) shap_values5 = y5_explainer_xgb.shap_values(df5) shap_values5 = np.abs(shap_values5) shap.bar_plot(shap_values5[0], max_display = 10, show = False, feature_names = f5_names) fig = plt.gcf() ax = plt.gca() wrap_labels(ax, 20) ax.figure plt.tight_layout() fig.set_figheight(7) fig.set_figwidth(9) plt.xlabel("SHAP value (impact on model output)", fontsize =12, fontweight = 'heavy', labelpad = 8) plt.tick_params(axis="y",direction="out", labelsize = 12) plt.tick_params(axis="x",direction="out", labelsize = 12) return fig def y5_interpret_lgb(*args): df5 = pd.DataFrame([args], columns=x5.columns) shap_values5 = y5_explainer_lgb.shap_values(df5) shap_values5 = np.abs(shap_values5) shap.bar_plot(shap_values5[0][0], max_display = 10, show = False, feature_names = f5_names) fig = plt.gcf() ax = plt.gca() wrap_labels(ax, 20) ax.figure plt.tight_layout() fig.set_figheight(7) fig.set_figwidth(9) plt.xlabel("SHAP value (impact on model output)", fontsize =12, fontweight = 'heavy', labelpad = 8) plt.tick_params(axis="y",direction="out", labelsize = 12) plt.tick_params(axis="x",direction="out", labelsize = 12) return fig def y5_interpret_cb(*args): df5 = pd.DataFrame([args], columns=x5.columns) shap_values5 = y5_explainer_cb.shap_values(Pool(df5)) shap_values5 = np.abs(shap_values5) shap.bar_plot(shap_values5[0], max_display = 10, show = False, feature_names = f5_names) fig = plt.gcf() ax = plt.gca() wrap_labels(ax, 20) ax.figure plt.tight_layout() fig.set_figheight(7) fig.set_figwidth(9) plt.xlabel("SHAP value (impact on model output)", fontsize =12, fontweight = 'heavy', labelpad = 8) plt.tick_params(axis="y",direction="out", labelsize = 12) plt.tick_params(axis="x",direction="out", labelsize = 12) return fig def y5_interpret_rf(*args): df5 = pd.DataFrame([args], columns=x5.columns) shap_values5 = y5_explainer_rf.shap_values(df5) shap_values5 = np.abs(sshap_values5) shap.bar_plot(shap_values5[0][0], max_display = 10, show = False, feature_names = f5_names) fig = plt.gcf() ax = plt.gca() wrap_labels(ax, 20) ax.figure plt.tight_layout() fig.set_figheight(7) fig.set_figwidth(9) plt.xlabel("SHAP value (impact on model output)", fontsize =12, fontweight = 'heavy', labelpad = 8) plt.tick_params(axis="y",direction="out", labelsize = 12) plt.tick_params(axis="x",direction="out", labelsize = 12) return fig with gr.Blocks(title = "TQP-cSCI") as demo: gr.Markdown( """

NOT FOR CLINICAL USE


Cervical SCI Outcomes

Prediction Tool


This web application should not be used to guide any clinical decisions.


The publication describing the details of this prediction tool can be reached from https://doi.org/10.1016/j.spinee.2023.08.009.
""" ) gr.Markdown( """

Model Performances

Outcome Algorithm Weighted Precision Weighted Recall Weighted AUPRC Balanced Accuracy AUROC Brier Score
Mortality Random Forest 0.951 (0.947 - 0.955) 0.961 (0.958 - 0.964) 0.145 (0.139 - 0.151) 0.564 (0.556 - 0.572) 0.839 (0.816 - 0.848) 0.028 (0.025 - 0.031)
Non-home Discharges CatBoost 0.739 (0.732 - 0.746) 0.725 (0.716 - 0.734) 0.641 (0.633 - 0.649) 0.737 (0.730 - 0.744) 0.815 (0.803 - 0.818) 0.177 (0.171 - 0.183)
Prolonged LOS Random Forest 0.786 (0.780 - 0.792) 0.816 (0.810 - 0.822) 0.372 (0.364 - 0.380) 0.596 (0.588 - 0.604) 0.742 (0.721 - 0.742) 0.128 (0.123 - 0.133)
Prolonged ICU-LOS CatBoost 0.775 (0.764 - 0.786) 0.765 (0.754 - 0.776) 0.219 (0.208 - 0.230) 0.599 (0.586 - 0.612) 0.682 (0.657 - 0.696) 0.130 (0.121 - 0.139)
Major Complications XGBoost 0.909 (0.904 - 0.914) 0.943 (0.939 - 0.947) 0.121 (0.116 - 0.126) 0.510 (0.502 - 0.518) 0.704 (0.683 - 0.720) 0.050 (0.046 - 0.054)
""" ) 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=220, step=1, value = 75) Supplemental_Oxygen = gr.Radio(label = "Supplemental Oxygen", choices = unique_SUPPLEMENTALOXYGEN, type = 'index', value = 'No supplemental oxygen') Pulse_Oximetry = gr.Slider(label = "Pulse Oximetry", minimum = 70, 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 = 4, maximum = 45, step = 1, value = 18) Temperature = gr.Slider(label = "Temperature", minimum = 36, maximum = 44, step = 0.1, value = 36.5) 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) Fracture_of_C1_Vertebra = gr.Radio(label = "Fracture of C1 Vertebra", choices = unique_C1FRACTURE, type = 'index', value = 'No') Fracture_of_C2_Vertebra = gr.Radio(label = "Fracture of C2 Vertebra", choices = unique_C2FRACTURE, type = 'index', value = 'No') Fracture_of_C3_Vertebra = gr.Radio(label = "Fracture of C3 Vertebra", choices = unique_C3FRACTURE, type = 'index', value = 'No') Fracture_of_C4_Vertebra = gr.Radio(label = "Fracture of C4 Vertebra", choices = unique_C4FRACTURE, type = 'index', value = 'No') Fracture_of_C5_Vertebra = gr.Radio(label = "Fracture of C5 Vertebra", choices = unique_C5FRACTURE, type = 'index', value = 'No') Fracture_of_C6_Vertebra = gr.Radio(label = "Fracture of C6 Vertebra", choices = unique_C6FRACTURE, type = 'index', value = 'No') Fracture_of_C7_Vertebra = gr.Radio(label = "Fracture of C7 Vertebra", choices = unique_C7FRACTURE, type = 'index', value = 'No') Rupture_of_Cervical_Intervertebral_Disc = gr.Radio(label = "Rupture of Cervical Intervertebral Disc", choices = unique_IVDRUPTURE, type = 'index', value = 'No') Subluxation_and_Dislocation_of_C0C1_Vertebrae = gr.Radio(label = "Subluxation and Dislocation of C0/C1 Vertebrae", choices = unique_C01SUBDIS, type = 'index', value = 'No') Subluxation_and_Dislocation_of_C1C2_Vertebrae = gr.Radio(label = "Subluxation and Dislocation of C1/C2 Vertebrae", choices = unique_C12SUBDIS, type = 'index', value = 'No') Subluxation_and_Dislocation_of_C2C3_Vertebrae = gr.Radio(label = "Subluxation and Dislocation of C2/C3 Vertebrae", choices = unique_C23SUBDIS, type = 'index', value = 'No') Subluxation_and_Dislocation_of_C3C4_Vertebrae = gr.Radio(label = "Subluxation and Dislocation of C3/C4 Vertebrae", choices = unique_C34SUBDIS, type = 'index', value = 'No') Subluxation_and_Dislocation_of_C4C5_Vertebrae = gr.Radio(label = "Subluxation and Dislocation of C4/C5 Vertebrae", choices = unique_C45SUBDIS, type = 'index', value = 'No') Subluxation_and_Dislocation_of_C5C6_Vertebrae = gr.Radio(label = "Subluxation and Dislocation of C5/C6 Vertebrae", choices = unique_C56SUBDIS, type = 'index', value = 'No') Subluxation_and_Dislocation_of_C6C7_Vertebrae = gr.Radio(label = "Subluxation and Dislocation of C6/C7 Vertebrae", choices = unique_C67SUBDIS, type = 'index', value = 'No') Subluxation_and_Dislocation_of_C7T1_Vertebrae = gr.Radio(label = "Subluxation and Dislocation of C7/T1 Vertebrae", choices = unique_C71SUBDIS, type = 'index', value = 'No') Concussion_and_Edema_of_cSC = gr.Radio(label = "Concussion and Edema of cSC", choices = unique_SCEDEMA, type = 'index', value = 'No') Complete_Lesion_of_cSC = gr.Radio(label = "Complete Lesion of cSC", choices = unique_SCANTCORD, type = 'index', value = 'No') Anterior_Cord_Syndrome_of_cSC = gr.Radio(label = "Anterior Cord Syndrome of cSC", choices = unique_SCBROWNSEQ, type = 'index', value = 'No') BrownSequard_Syndrome_of_cSC = gr.Radio(label = "Brown-Sequard Syndrome of cSC", choices = unique_C1FRACTURE, type = 'index', value = 'No') Other_Incomplete_Lesions_of_cSC = gr.Radio(label = "Other Incomplete Lesions of cSC", choices = unique_SCINCOMPLETE, type = 'index', value = 'No') Current_Smoker = gr.Radio(label = "Current Smoker", choices = unique_CC_SMOKING, type = 'index', value = 'No') Alcohol_Use_Disorder = gr.Radio(label = "Comorbid Condition - Alcohol Use Disorder", choices = unique_CC_ALCOHOLISM, type = 'index', value = 'No') Substance_Abuse_Disorder = gr.Radio(label = "Comorbid Condition - Substance Abuse Disorder", choices = unique_CC_SUBSTANCEABUSE, type = 'index', value = 'No') Diabetes_Mellitus = gr.Radio(label = "Comorbid Condition - Diabetes Mellitus", choices = unique_CC_DIABETES, type = 'index', value = 'No') Hypertension = gr.Radio(label = "Comorbid Condition - Hypertension", choices = unique_CC_HYPERTENSION, type = 'index', value = 'No') 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') 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') Peripheral_Arterial_Disease = gr.Radio(label = "Comorbid Condition - Peripheral Arterial Disease", choices = unique_CC_PAD, type = 'index', value = 'No') Chronic_Obstructive_Pulmonary_Disease = gr.Radio(label = "Comorbid Condition - Chronic Obstructive Pulmonary Disease", choices = unique_CC_COPD, type = 'index', value = 'No') Chronic_Renal_Failure = gr.Radio(label = "Comorbid Condition - Chronic Renal Failure", choices = unique_CC_RENAL, type = 'index', value = 'No') Cirrhosis = gr.Radio(label = "Comorbid Condition - Cirrhosis", choices = unique_CC_CIRRHOSIS, type = 'index', value = 'No') Bleeding_Disorder = gr.Radio(label = "Comorbid Condition - Bleeding Disorder", choices = unique_CC_BLEEDING, type = 'index', value = 'No') Disseminated_Cancer = gr.Radio(label = "Comorbid Condition - Disseminated Cancer", choices = unique_CC_DISCANCER, type = 'index', value = 'No') Currently_Receiving_Chemotherapy_for_Cancer = gr.Radio(label = "Comorbid Condition - Currently Receiving Chemotherapy for Cancer", choices = unique_CC_CHEMO, type = 'index', value = 'No') Dementia = gr.Radio(label = "Comorbid Condition - Dementia", choices = unique_CC_DEMENTIA, type = 'index', value = 'No') 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') 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') 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') Surgical_Intervention = gr.Radio(label = "Surgical_Intervention", choices = unique_INTERVENTION, type = 'index', value = 'No') Blood_Transfusion = gr.Slider(label="Blood Transfusion (mL)", minimum = 0, maximum = 5000, step = 50, value = 0) 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(): gr.Markdown( """

Mortality

This model uses the Random Forest algorithm.

""" ) with gr.Row(): y1_predict_btn_rf = gr.Button(value="Predict") gr.Markdown( """
""" ) label1 = gr.Markdown() gr.Markdown( """
""" ) with gr.Row(): y1_interpret_btn_rf = gr.Button(value="Explain") gr.Markdown( """
""" ) plot1 = gr.Plot() gr.Markdown( """
""" ) with gr.Box(): gr.Markdown( """

Discharge Disposition

This model uses the CatBoost algorithm.

""" ) with gr.Row(): y2_predict_btn_cb = gr.Button(value="Predict") gr.Markdown( """
""" ) label2 = gr.Markdown() gr.Markdown( """
""" ) with gr.Row(): y2_interpret_btn_cb = gr.Button(value="Explain") gr.Markdown( """
""" ) plot2 = gr.Plot() gr.Markdown( """
""" ) with gr.Box(): gr.Markdown( """

Prolonged Length of Stay

This model uses the Random Forest algorithm.

""" ) with gr.Row(): y3_predict_btn_rf = gr.Button(value="Predict") gr.Markdown( """
""" ) label3 = gr.Markdown() gr.Markdown( """
""" ) with gr.Row(): y3_interpret_btn_rf = gr.Button(value="Explain") gr.Markdown( """
""" ) plot3 = gr.Plot() gr.Markdown( """
""" ) with gr.Box(): gr.Markdown( """

Prolonged Length of ICU Stay

This model uses the CatBoost algorithm.

""" ) with gr.Row(): y4_predict_btn_cb = gr.Button(value="Predict") gr.Markdown( """
""" ) label4 = gr.Markdown() gr.Markdown( """
""" ) with gr.Row(): y4_interpret_btn_cb = gr.Button(value="Explain") gr.Markdown( """
""" ) plot4 = gr.Plot() gr.Markdown( """
""" ) with gr.Box(): gr.Markdown( """

Major Complications

This model uses the XGBoost algorithm.

""" ) with gr.Row(): y5_predict_btn_xgb = gr.Button(value="Predict") gr.Markdown( """
""" ) label5 = gr.Markdown() gr.Markdown( """
""" ) with gr.Row(): y5_interpret_btn_xgb = gr.Button(value="Explain") gr.Markdown( """
""" ) plot5 = gr.Plot() gr.Markdown( """
""" ) y1_predict_btn_rf.click( y1_predict_rf, inputs = [Age, Sex, Race, Ethnicity, Weight, Height, Systolic_Blood_Pressure, Pulse_Rate, Supplemental_Oxygen, Pulse_Oximetry, Respiratory_Assistance, Respiratory_Rate, Temperature, GCS__Eye, GCS__Verbal, GCS__Motor, Total_GCS, Fracture_of_C1_Vertebra, Fracture_of_C2_Vertebra, Fracture_of_C3_Vertebra, Fracture_of_C4_Vertebra, Fracture_of_C5_Vertebra, Fracture_of_C6_Vertebra, Fracture_of_C7_Vertebra, Rupture_of_Cervical_Intervertebral_Disc, Subluxation_and_Dislocation_of_C0C1_Vertebrae, Subluxation_and_Dislocation_of_C1C2_Vertebrae, Subluxation_and_Dislocation_of_C2C3_Vertebrae, Subluxation_and_Dislocation_of_C3C4_Vertebrae, Subluxation_and_Dislocation_of_C4C5_Vertebrae, Subluxation_and_Dislocation_of_C5C6_Vertebrae, Subluxation_and_Dislocation_of_C6C7_Vertebrae, Subluxation_and_Dislocation_of_C7T1_Vertebrae, Concussion_and_Edema_of_cSC, Complete_Lesion_of_cSC, Anterior_Cord_Syndrome_of_cSC, BrownSequard_Syndrome_of_cSC, Other_Incomplete_Lesions_of_cSC, Current_Smoker, Alcohol_Use_Disorder, Substance_Abuse_Disorder, Diabetes_Mellitus, Hypertension, Congestive_Heart_Failure, History_of_Myocardial_Infarction, Angina_Pectoris, History_of_Cerebrovascular_Accident, Peripheral_Arterial_Disease, Chronic_Obstructive_Pulmonary_Disease, Chronic_Renal_Failure, Cirrhosis, Bleeding_Disorder, Disseminated_Cancer, Currently_Receiving_Chemotherapy_for_Cancer, Dementia, Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder, Mental_or_Personality_Disorder, Ability_to_Complete_AgeAppropriate_ADL, Pregnancy, Anticoagulant_Therapy, Steroid_Use, Days_from_Incident_to_ED_or_Hospital_Arrival, Transport_Mode, InterFacility_Transfer, Trauma_Type, Injury_Intent, Mechanism_of_Injury, Protective_Device, WorkRelated, Surgical_Intervention, Blood_Transfusion, 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,], outputs = [label1] ) y2_predict_btn_cb.click( y2_predict_cb, inputs = [Age, Sex, Race, Ethnicity, Weight, Height, Systolic_Blood_Pressure, Pulse_Rate, Supplemental_Oxygen, Pulse_Oximetry, Respiratory_Assistance, Respiratory_Rate, Temperature, GCS__Eye, GCS__Verbal, GCS__Motor, Total_GCS, Fracture_of_C1_Vertebra, Fracture_of_C2_Vertebra, Fracture_of_C3_Vertebra, Fracture_of_C4_Vertebra, Fracture_of_C5_Vertebra, Fracture_of_C6_Vertebra, Fracture_of_C7_Vertebra, Rupture_of_Cervical_Intervertebral_Disc, Subluxation_and_Dislocation_of_C0C1_Vertebrae, Subluxation_and_Dislocation_of_C1C2_Vertebrae, Subluxation_and_Dislocation_of_C2C3_Vertebrae, Subluxation_and_Dislocation_of_C3C4_Vertebrae, Subluxation_and_Dislocation_of_C4C5_Vertebrae, Subluxation_and_Dislocation_of_C5C6_Vertebrae, Subluxation_and_Dislocation_of_C6C7_Vertebrae, Subluxation_and_Dislocation_of_C7T1_Vertebrae, Concussion_and_Edema_of_cSC, Complete_Lesion_of_cSC, Anterior_Cord_Syndrome_of_cSC, BrownSequard_Syndrome_of_cSC, Other_Incomplete_Lesions_of_cSC, Current_Smoker, Alcohol_Use_Disorder, Substance_Abuse_Disorder, Diabetes_Mellitus, Hypertension, Congestive_Heart_Failure, History_of_Myocardial_Infarction, Angina_Pectoris, History_of_Cerebrovascular_Accident, Peripheral_Arterial_Disease, Chronic_Obstructive_Pulmonary_Disease, Chronic_Renal_Failure, Cirrhosis, Bleeding_Disorder, Disseminated_Cancer, Currently_Receiving_Chemotherapy_for_Cancer, Dementia, Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder, Mental_or_Personality_Disorder, Ability_to_Complete_AgeAppropriate_ADL, Pregnancy, Anticoagulant_Therapy, Steroid_Use, Days_from_Incident_to_ED_or_Hospital_Arrival, Transport_Mode, InterFacility_Transfer, Trauma_Type, Injury_Intent, Mechanism_of_Injury, Protective_Device, WorkRelated, Surgical_Intervention, Blood_Transfusion, 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,], outputs = [label2] ) y3_predict_btn_rf.click( y3_predict_rf, inputs = [Age, Sex, Race, Ethnicity, Weight, Height, Systolic_Blood_Pressure, Pulse_Rate, Supplemental_Oxygen, Pulse_Oximetry, Respiratory_Assistance, Respiratory_Rate, Temperature, GCS__Eye, GCS__Verbal, GCS__Motor, Total_GCS, Fracture_of_C1_Vertebra, Fracture_of_C2_Vertebra, Fracture_of_C3_Vertebra, Fracture_of_C4_Vertebra, Fracture_of_C5_Vertebra, Fracture_of_C6_Vertebra, Fracture_of_C7_Vertebra, Rupture_of_Cervical_Intervertebral_Disc, Subluxation_and_Dislocation_of_C0C1_Vertebrae, Subluxation_and_Dislocation_of_C1C2_Vertebrae, Subluxation_and_Dislocation_of_C2C3_Vertebrae, Subluxation_and_Dislocation_of_C3C4_Vertebrae, Subluxation_and_Dislocation_of_C4C5_Vertebrae, Subluxation_and_Dislocation_of_C5C6_Vertebrae, Subluxation_and_Dislocation_of_C6C7_Vertebrae, Subluxation_and_Dislocation_of_C7T1_Vertebrae, Concussion_and_Edema_of_cSC, Complete_Lesion_of_cSC, Anterior_Cord_Syndrome_of_cSC, BrownSequard_Syndrome_of_cSC, Other_Incomplete_Lesions_of_cSC, Current_Smoker, Alcohol_Use_Disorder, Substance_Abuse_Disorder, Diabetes_Mellitus, Hypertension, Congestive_Heart_Failure, History_of_Myocardial_Infarction, Angina_Pectoris, History_of_Cerebrovascular_Accident, Peripheral_Arterial_Disease, Chronic_Obstructive_Pulmonary_Disease, Chronic_Renal_Failure, Cirrhosis, Bleeding_Disorder, Disseminated_Cancer, Currently_Receiving_Chemotherapy_for_Cancer, Dementia, Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder, Mental_or_Personality_Disorder, Ability_to_Complete_AgeAppropriate_ADL, Pregnancy, Anticoagulant_Therapy, Steroid_Use, Days_from_Incident_to_ED_or_Hospital_Arrival, Transport_Mode, InterFacility_Transfer, Trauma_Type, Injury_Intent, Mechanism_of_Injury, Protective_Device, WorkRelated, Surgical_Intervention, Blood_Transfusion, 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,], outputs = [label3] ) y4_predict_btn_cb.click( y4_predict_cb, inputs = [Age, Sex, Race, Ethnicity, Weight, Height, Systolic_Blood_Pressure, Pulse_Rate, Supplemental_Oxygen, Pulse_Oximetry, Respiratory_Assistance, Respiratory_Rate, Temperature, GCS__Eye, GCS__Verbal, GCS__Motor, Total_GCS, Fracture_of_C1_Vertebra, Fracture_of_C2_Vertebra, Fracture_of_C3_Vertebra, Fracture_of_C4_Vertebra, Fracture_of_C5_Vertebra, Fracture_of_C6_Vertebra, Fracture_of_C7_Vertebra, Rupture_of_Cervical_Intervertebral_Disc, Subluxation_and_Dislocation_of_C0C1_Vertebrae, Subluxation_and_Dislocation_of_C1C2_Vertebrae, Subluxation_and_Dislocation_of_C2C3_Vertebrae, Subluxation_and_Dislocation_of_C3C4_Vertebrae, Subluxation_and_Dislocation_of_C4C5_Vertebrae, Subluxation_and_Dislocation_of_C5C6_Vertebrae, Subluxation_and_Dislocation_of_C6C7_Vertebrae, Subluxation_and_Dislocation_of_C7T1_Vertebrae, Concussion_and_Edema_of_cSC, Complete_Lesion_of_cSC, Anterior_Cord_Syndrome_of_cSC, BrownSequard_Syndrome_of_cSC, Other_Incomplete_Lesions_of_cSC, Current_Smoker, Alcohol_Use_Disorder, Substance_Abuse_Disorder, Diabetes_Mellitus, Hypertension, Congestive_Heart_Failure, History_of_Myocardial_Infarction, Angina_Pectoris, History_of_Cerebrovascular_Accident, Peripheral_Arterial_Disease, Chronic_Obstructive_Pulmonary_Disease, Chronic_Renal_Failure, Cirrhosis, Bleeding_Disorder, Disseminated_Cancer, Currently_Receiving_Chemotherapy_for_Cancer, Dementia, Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder, Mental_or_Personality_Disorder, Ability_to_Complete_AgeAppropriate_ADL, Pregnancy, Anticoagulant_Therapy, Steroid_Use, Days_from_Incident_to_ED_or_Hospital_Arrival, Transport_Mode, InterFacility_Transfer, Trauma_Type, Injury_Intent, Mechanism_of_Injury, Protective_Device, WorkRelated, Surgical_Intervention, Blood_Transfusion, 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,], outputs = [label4] ) y5_predict_btn_xgb.click( y5_predict_xgb, inputs = [Age, Sex, Race, Ethnicity, Weight, Height, Systolic_Blood_Pressure, Pulse_Rate, Supplemental_Oxygen, Pulse_Oximetry, Respiratory_Assistance, Respiratory_Rate, Temperature, GCS__Eye, GCS__Verbal, GCS__Motor, Total_GCS, Fracture_of_C1_Vertebra, Fracture_of_C2_Vertebra, Fracture_of_C3_Vertebra, Fracture_of_C4_Vertebra, Fracture_of_C5_Vertebra, Fracture_of_C6_Vertebra, Fracture_of_C7_Vertebra, Rupture_of_Cervical_Intervertebral_Disc, Subluxation_and_Dislocation_of_C0C1_Vertebrae, Subluxation_and_Dislocation_of_C1C2_Vertebrae, Subluxation_and_Dislocation_of_C2C3_Vertebrae, Subluxation_and_Dislocation_of_C3C4_Vertebrae, Subluxation_and_Dislocation_of_C4C5_Vertebrae, Subluxation_and_Dislocation_of_C5C6_Vertebrae, Subluxation_and_Dislocation_of_C6C7_Vertebrae, Subluxation_and_Dislocation_of_C7T1_Vertebrae, Concussion_and_Edema_of_cSC, Complete_Lesion_of_cSC, Anterior_Cord_Syndrome_of_cSC, BrownSequard_Syndrome_of_cSC, Other_Incomplete_Lesions_of_cSC, Current_Smoker, Alcohol_Use_Disorder, Substance_Abuse_Disorder, Diabetes_Mellitus, Hypertension, Congestive_Heart_Failure, History_of_Myocardial_Infarction, Angina_Pectoris, History_of_Cerebrovascular_Accident, Peripheral_Arterial_Disease, Chronic_Obstructive_Pulmonary_Disease, Chronic_Renal_Failure, Cirrhosis, Bleeding_Disorder, Disseminated_Cancer, Currently_Receiving_Chemotherapy_for_Cancer, Dementia, Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder, Mental_or_Personality_Disorder, Ability_to_Complete_AgeAppropriate_ADL, Pregnancy, Anticoagulant_Therapy, Steroid_Use, Days_from_Incident_to_ED_or_Hospital_Arrival, Transport_Mode, InterFacility_Transfer, Trauma_Type, Injury_Intent, Mechanism_of_Injury, Protective_Device, WorkRelated, Surgical_Intervention, Blood_Transfusion, 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,], outputs = [label5] ) y1_interpret_btn_rf.click( y1_interpret_rf, inputs = [Age, Sex, Race, Ethnicity, Weight, Height, Systolic_Blood_Pressure, Pulse_Rate, Supplemental_Oxygen, Pulse_Oximetry, Respiratory_Assistance, Respiratory_Rate, Temperature, GCS__Eye, GCS__Verbal, GCS__Motor, Total_GCS, Fracture_of_C1_Vertebra, Fracture_of_C2_Vertebra, Fracture_of_C3_Vertebra, Fracture_of_C4_Vertebra, Fracture_of_C5_Vertebra, Fracture_of_C6_Vertebra, Fracture_of_C7_Vertebra, Rupture_of_Cervical_Intervertebral_Disc, Subluxation_and_Dislocation_of_C0C1_Vertebrae, Subluxation_and_Dislocation_of_C1C2_Vertebrae, Subluxation_and_Dislocation_of_C2C3_Vertebrae, Subluxation_and_Dislocation_of_C3C4_Vertebrae, Subluxation_and_Dislocation_of_C4C5_Vertebrae, Subluxation_and_Dislocation_of_C5C6_Vertebrae, Subluxation_and_Dislocation_of_C6C7_Vertebrae, Subluxation_and_Dislocation_of_C7T1_Vertebrae, Concussion_and_Edema_of_cSC, Complete_Lesion_of_cSC, Anterior_Cord_Syndrome_of_cSC, BrownSequard_Syndrome_of_cSC, Other_Incomplete_Lesions_of_cSC, Current_Smoker, Alcohol_Use_Disorder, Substance_Abuse_Disorder, Diabetes_Mellitus, Hypertension, Congestive_Heart_Failure, History_of_Myocardial_Infarction, Angina_Pectoris, History_of_Cerebrovascular_Accident, Peripheral_Arterial_Disease, Chronic_Obstructive_Pulmonary_Disease, Chronic_Renal_Failure, Cirrhosis, Bleeding_Disorder, Disseminated_Cancer, Currently_Receiving_Chemotherapy_for_Cancer, Dementia, Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder, Mental_or_Personality_Disorder, Ability_to_Complete_AgeAppropriate_ADL, Pregnancy, Anticoagulant_Therapy, Steroid_Use, Days_from_Incident_to_ED_or_Hospital_Arrival, Transport_Mode, InterFacility_Transfer, Trauma_Type, Injury_Intent, Mechanism_of_Injury, Protective_Device, WorkRelated, Surgical_Intervention, Blood_Transfusion, 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,], outputs = [plot1], ) y2_interpret_btn_cb.click( y2_interpret_cb, inputs = [Age, Sex, Race, Ethnicity, Weight, Height, Systolic_Blood_Pressure, Pulse_Rate, Supplemental_Oxygen, Pulse_Oximetry, Respiratory_Assistance, Respiratory_Rate, Temperature, GCS__Eye, GCS__Verbal, GCS__Motor, Total_GCS, Fracture_of_C1_Vertebra, Fracture_of_C2_Vertebra, Fracture_of_C3_Vertebra, Fracture_of_C4_Vertebra, Fracture_of_C5_Vertebra, Fracture_of_C6_Vertebra, Fracture_of_C7_Vertebra, Rupture_of_Cervical_Intervertebral_Disc, Subluxation_and_Dislocation_of_C0C1_Vertebrae, Subluxation_and_Dislocation_of_C1C2_Vertebrae, Subluxation_and_Dislocation_of_C2C3_Vertebrae, Subluxation_and_Dislocation_of_C3C4_Vertebrae, Subluxation_and_Dislocation_of_C4C5_Vertebrae, Subluxation_and_Dislocation_of_C5C6_Vertebrae, Subluxation_and_Dislocation_of_C6C7_Vertebrae, Subluxation_and_Dislocation_of_C7T1_Vertebrae, Concussion_and_Edema_of_cSC, Complete_Lesion_of_cSC, Anterior_Cord_Syndrome_of_cSC, BrownSequard_Syndrome_of_cSC, Other_Incomplete_Lesions_of_cSC, Current_Smoker, Alcohol_Use_Disorder, Substance_Abuse_Disorder, Diabetes_Mellitus, Hypertension, Congestive_Heart_Failure, History_of_Myocardial_Infarction, Angina_Pectoris, History_of_Cerebrovascular_Accident, Peripheral_Arterial_Disease, Chronic_Obstructive_Pulmonary_Disease, Chronic_Renal_Failure, Cirrhosis, Bleeding_Disorder, Disseminated_Cancer, Currently_Receiving_Chemotherapy_for_Cancer, Dementia, Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder, Mental_or_Personality_Disorder, Ability_to_Complete_AgeAppropriate_ADL, Pregnancy, Anticoagulant_Therapy, Steroid_Use, Days_from_Incident_to_ED_or_Hospital_Arrival, Transport_Mode, InterFacility_Transfer, Trauma_Type, Injury_Intent, Mechanism_of_Injury, Protective_Device, WorkRelated, Surgical_Intervention, Blood_Transfusion, 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,], outputs = [plot2], ) y3_interpret_btn_rf.click( y3_interpret_rf, inputs = [Age, Sex, Race, Ethnicity, Weight, Height, Systolic_Blood_Pressure, Pulse_Rate, Supplemental_Oxygen, Pulse_Oximetry, Respiratory_Assistance, Respiratory_Rate, Temperature, GCS__Eye, GCS__Verbal, GCS__Motor, Total_GCS, Fracture_of_C1_Vertebra, Fracture_of_C2_Vertebra, Fracture_of_C3_Vertebra, Fracture_of_C4_Vertebra, Fracture_of_C5_Vertebra, Fracture_of_C6_Vertebra, Fracture_of_C7_Vertebra, Rupture_of_Cervical_Intervertebral_Disc, Subluxation_and_Dislocation_of_C0C1_Vertebrae, Subluxation_and_Dislocation_of_C1C2_Vertebrae, Subluxation_and_Dislocation_of_C2C3_Vertebrae, Subluxation_and_Dislocation_of_C3C4_Vertebrae, Subluxation_and_Dislocation_of_C4C5_Vertebrae, Subluxation_and_Dislocation_of_C5C6_Vertebrae, Subluxation_and_Dislocation_of_C6C7_Vertebrae, Subluxation_and_Dislocation_of_C7T1_Vertebrae, Concussion_and_Edema_of_cSC, Complete_Lesion_of_cSC, Anterior_Cord_Syndrome_of_cSC, BrownSequard_Syndrome_of_cSC, Other_Incomplete_Lesions_of_cSC, Current_Smoker, Alcohol_Use_Disorder, Substance_Abuse_Disorder, Diabetes_Mellitus, Hypertension, Congestive_Heart_Failure, History_of_Myocardial_Infarction, Angina_Pectoris, History_of_Cerebrovascular_Accident, Peripheral_Arterial_Disease, Chronic_Obstructive_Pulmonary_Disease, Chronic_Renal_Failure, Cirrhosis, Bleeding_Disorder, Disseminated_Cancer, Currently_Receiving_Chemotherapy_for_Cancer, Dementia, Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder, Mental_or_Personality_Disorder, Ability_to_Complete_AgeAppropriate_ADL, Pregnancy, Anticoagulant_Therapy, Steroid_Use, Days_from_Incident_to_ED_or_Hospital_Arrival, Transport_Mode, InterFacility_Transfer, Trauma_Type, Injury_Intent, Mechanism_of_Injury, Protective_Device, WorkRelated, Surgical_Intervention, Blood_Transfusion, 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,], outputs = [plot3], ) y4_interpret_btn_cb.click( y4_interpret_cb, inputs = [Age, Sex, Race, Ethnicity, Weight, Height, Systolic_Blood_Pressure, Pulse_Rate, Supplemental_Oxygen, Pulse_Oximetry, Respiratory_Assistance, Respiratory_Rate, Temperature, GCS__Eye, GCS__Verbal, GCS__Motor, Total_GCS, Fracture_of_C1_Vertebra, Fracture_of_C2_Vertebra, Fracture_of_C3_Vertebra, Fracture_of_C4_Vertebra, Fracture_of_C5_Vertebra, Fracture_of_C6_Vertebra, Fracture_of_C7_Vertebra, Rupture_of_Cervical_Intervertebral_Disc, Subluxation_and_Dislocation_of_C0C1_Vertebrae, Subluxation_and_Dislocation_of_C1C2_Vertebrae, Subluxation_and_Dislocation_of_C2C3_Vertebrae, Subluxation_and_Dislocation_of_C3C4_Vertebrae, Subluxation_and_Dislocation_of_C4C5_Vertebrae, Subluxation_and_Dislocation_of_C5C6_Vertebrae, Subluxation_and_Dislocation_of_C6C7_Vertebrae, Subluxation_and_Dislocation_of_C7T1_Vertebrae, Concussion_and_Edema_of_cSC, Complete_Lesion_of_cSC, Anterior_Cord_Syndrome_of_cSC, BrownSequard_Syndrome_of_cSC, Other_Incomplete_Lesions_of_cSC, Current_Smoker, Alcohol_Use_Disorder, Substance_Abuse_Disorder, Diabetes_Mellitus, Hypertension, Congestive_Heart_Failure, History_of_Myocardial_Infarction, Angina_Pectoris, History_of_Cerebrovascular_Accident, Peripheral_Arterial_Disease, Chronic_Obstructive_Pulmonary_Disease, Chronic_Renal_Failure, Cirrhosis, Bleeding_Disorder, Disseminated_Cancer, Currently_Receiving_Chemotherapy_for_Cancer, Dementia, Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder, Mental_or_Personality_Disorder, Ability_to_Complete_AgeAppropriate_ADL, Pregnancy, Anticoagulant_Therapy, Steroid_Use, Days_from_Incident_to_ED_or_Hospital_Arrival, Transport_Mode, InterFacility_Transfer, Trauma_Type, Injury_Intent, Mechanism_of_Injury, Protective_Device, WorkRelated, Surgical_Intervention, Blood_Transfusion, 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,], outputs = [plot4], ) y5_interpret_btn_xgb.click( y5_interpret_xgb, inputs = [Age, Sex, Race, Ethnicity, Weight, Height, Systolic_Blood_Pressure, Pulse_Rate, Supplemental_Oxygen, Pulse_Oximetry, Respiratory_Assistance, Respiratory_Rate, Temperature, GCS__Eye, GCS__Verbal, GCS__Motor, Total_GCS, Fracture_of_C1_Vertebra, Fracture_of_C2_Vertebra, Fracture_of_C3_Vertebra, Fracture_of_C4_Vertebra, Fracture_of_C5_Vertebra, Fracture_of_C6_Vertebra, Fracture_of_C7_Vertebra, Rupture_of_Cervical_Intervertebral_Disc, Subluxation_and_Dislocation_of_C0C1_Vertebrae, Subluxation_and_Dislocation_of_C1C2_Vertebrae, Subluxation_and_Dislocation_of_C2C3_Vertebrae, Subluxation_and_Dislocation_of_C3C4_Vertebrae, Subluxation_and_Dislocation_of_C4C5_Vertebrae, Subluxation_and_Dislocation_of_C5C6_Vertebrae, Subluxation_and_Dislocation_of_C6C7_Vertebrae, Subluxation_and_Dislocation_of_C7T1_Vertebrae, Concussion_and_Edema_of_cSC, Complete_Lesion_of_cSC, Anterior_Cord_Syndrome_of_cSC, BrownSequard_Syndrome_of_cSC, Other_Incomplete_Lesions_of_cSC, Current_Smoker, Alcohol_Use_Disorder, Substance_Abuse_Disorder, Diabetes_Mellitus, Hypertension, Congestive_Heart_Failure, History_of_Myocardial_Infarction, Angina_Pectoris, History_of_Cerebrovascular_Accident, Peripheral_Arterial_Disease, Chronic_Obstructive_Pulmonary_Disease, Chronic_Renal_Failure, Cirrhosis, Bleeding_Disorder, Disseminated_Cancer, Currently_Receiving_Chemotherapy_for_Cancer, Dementia, Attention_Deficit_Disorder_or_Attention_Deficit_Hyperactivity_Disorder, Mental_or_Personality_Disorder, Ability_to_Complete_AgeAppropriate_ADL, Pregnancy, Anticoagulant_Therapy, Steroid_Use, Days_from_Incident_to_ED_or_Hospital_Arrival, Transport_Mode, InterFacility_Transfer, Trauma_Type, Injury_Intent, Mechanism_of_Injury, Protective_Device, WorkRelated, Surgical_Intervention, Blood_Transfusion, 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,], outputs = [plot5], ) gr.Markdown( """

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.

""" ) demo.launch()