# Predicting Hospital Admissions to Reduce Crowding in the Emergency Departments
## 3 Method and Materials
### Data Preparation  
Some variables were either added or modified to increase predictive performance of the model. First, the dataset was cleansed to eliminate all those observations that were incomplete, which accounted for 189,337 observations (5.51%). Following this first cleansing, a quick analysis was performed to identify variables that might have abnormal values; 34,725 (1.01%) observations were eliminated for containing non-existent triage values, i.e., >5. In the category of symptoms (CCS), some observations had been classified as \"incomplete\" and were eliminated from the dataset as well; that accounted for 20,864 observations and 0.61% of the initial total.  
After this pre-processing stage of the data performed by both the government and the researcher, the number of observations for analysis dropped from 3,561,936 to 3,189,204. (See Figure 2).  
An extra variable was created to show the accumulated number of visits for each patient during the year observing that it was recurrent to have multiple visits for one patient in the 2018 exercise. The same procedure was used to see the absolute frequencies for the symptoms (CCS) variable, and a feature selection procedure was conducted to reduce the number of levels with very little frequency. In this case, it was decided to assign the label \"Other\" to all these observations whose CCS value appeared fewer than 30 times throughout the dataset. This would imply an average of less than one case every ten days in the whole Integral Healthcare System for Public Use in Catalonia, on average.  
Table 2 shows the number of distinct outcomes observed for each of the variables in the dataset.  
\begin{table}
\begin{tabular}{c c} \hline \hline
**Variable** & **Distinct Outcomes** \\ \hline ID & 1,805,096 \\ Accumulated visits & 77 \\ Age & 113 \\ Age days & 365 \\ Gender & 2 \\ CCS & 259 \\ CCS frequency & 255 \\ Triage & 5 \\ Admission & 2 \\ \hline \hline \end{tabular}
\end{table}
Table 2: Variable included in the model.  
Figure 2: Patients included in the analysis.  
Some of these variables were classified as numerical by default although they were categorical. Prior to analyzing the data, gender, CCS, and triage were factored. [PERSON], [PERSON] et al. (2018) [29] state that accuracy of the prediction at time of arrival for patients visiting the ED could be improved by dividing the observations into two subsets, (1) containing all those related to patients under 70 years of age; and (2) containing all those above 70, a division of the main dataset. To further contrast this enhanced predictive value, another division was created with the 18 years of age threshold in order to test the performance of a model dedicated to pediatrics against that of a model for adults. This resulted in 5 distinct datasets: the complete dataset, the pediatrics dataset [0-18] years, the adults dataset [18, 115] years, the adults under 70 dataset [18, 70] years (i.e., young adults dataset), and the adults over 70 dataset [70, 115] years (i.e., old adults dataset). For all the datasets, the variable age days was eliminated.