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 = (
"""
| 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) |