Hospital Discharge Prediction Using Machine Learning

preprint OA: closed CC-BY-NC-ND-4.0
📄 Open PDF Full text JSON View at publisher
Full text 51,073 characters · extracted from preprint-html · click to expand
Hospital Discharge Prediction Using Machine Learning | medRxiv /* */ /* */ <!-- <!-- /*! * yepnope1.5.4 * (c) WTFPL, GPLv2 */ (function(a,b,c){function d(a){return"[object Function]"==o.call(a)}function e(a){return"string"==typeof a}function f(){}function g(a){return!a||"loaded"==a||"complete"==a||"uninitialized"==a}function h(){var a=p.shift();q=1,a?a.t?m(function(){("c"==a.t?B.injectCss:B.injectJs)(a.s,0,a.a,a.x,a.e,1)},0):(a(),h()):q=0}function i(a,c,d,e,f,i,j){function k(b){if(!o&&g(l.readyState)&&(u.r=o=1,!q&&h(),l.onload=l.onreadystatechange=null,b)){"img"!=a&&m(function(){t.removeChild(l)},50);for(var d in y[c])y[c].hasOwnProperty(d)&&y[c][d].onload()}}var j=j||B.errorTimeout,l=b.createElement(a),o=0,r=0,u={t:d,s:c,e:f,a:i,x:j};1===y[c]&&(r=1,y[c]=[]),"object"==a?l.data=c:(l.src=c,l.type=a),l.width=l.height="0",l.onerror=l.onload=l.onreadystatechange=function(){k.call(this,r)},p.splice(e,0,u),"img"!=a&&(r||2===y[c]?(t.insertBefore(l,s?null:n),m(k,j)):y[c].push(l))}function j(a,b,c,d,f){return q=0,b=b||"j",e(a)?i("c"==b?v:u,a,b,this.i++,c,d,f):(p.splice(this.i++,0,a),1==p.length&&h()),this}function k(){var a=B;return a.loader={load:j,i:0},a}var l=b.documentElement,m=a.setTimeout,n=b.getElementsByTagName("script")[0],o={}.toString,p=[],q=0,r="MozAppearance"in l.style,s=r&&!!b.createRange().compareNode,t=s?l:n.parentNode,l=a.opera&&"[object Opera]"==o.call(a.opera),l=!!b.attachEvent&&!l,u=r?"object":l?"script":"img",v=l?"script":u,w=Array.isArray||function(a){return"[object Array]"==o.call(a)},x=[],y={},z={timeout:function(a,b){return b.length&&(a.timeout=b[0]),a}},A,B;B=function(a){function b(a){var a=a.split("!"),b=x.length,c=a.pop(),d=a.length,c={url:c,origUrl:c,prefixes:a},e,f,g;for(f=0;f<d;f++)g=a[f].split("="),(e=z[g.shift()])&&(c=e(c,g));for(f=0;f<b;f++)c=x[f](c);return c}function g(a,e,f,g,h){var i=b(a),j=i.autoCallback;i.url.split(".").pop().split("?").shift(),i.bypass||(e&&(e=d(e)?e:e[a]||e[g]||e[a.split("/").pop().split("?")[0]]),i.instead?i.instead(a,e,f,g,h):(y[i.url]?i.noexec=!0:y[i.url]=1,f.load(i.url,i.forceCSS||!i.forceJS&&"css"==i.url.split(".").pop().split("?").shift()?"c":c,i.noexec,i.attrs,i.timeout),(d(e)||d(j))&&f.load(function(){k(),e&&e(i.origUrl,h,g),j&&j(i.origUrl,h,g),y[i.url]=2})))}function h(a,b){function c(a,c){if(a){if(e(a))c||(j=function(){var a=[].slice.call(arguments);k.apply(this,a),l()}),g(a,j,b,0,h);else if(Object(a)===a)for(n in m=function(){var b=0,c;for(c in a)a.hasOwnProperty(c)&&b++;return b}(),a)a.hasOwnProperty(n)&&(!c&&!--m&&(d(j)?j=function(){var a=[].slice.call(arguments);k.apply(this,a),l()}:j[n]=function(a){return function(){var b=[].slice.call(arguments);a&&a.apply(this,b),l()}}(k[n])),g(a[n],j,b,n,h))}else!c&&l()}var h=!!a.test,i=a.load||a.both,j=a.callback||f,k=j,l=a.complete||f,m,n;c(h?a.yep:a.nope,!!i),i&&c(i)}var i,j,l=this.yepnope.loader;if(e(a))g(a,0,l,0);else if(w(a))for(i=0;i (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0];var j=d.createElement(s);var dl=l!='dataLayer'?'&l='+l:'';j.src='//www.googletagmanager.com/gtm.js?id='+i+dl;j.type='text/javascript';j.async=true;f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','GTM-P4HH5NV'); Skip to main content Home About Submit ALERTS / RSS Search for this keyword Advanced Search Hospital Discharge Prediction Using Machine Learning Joaquim Oristrell , Anna Pascual , Pere Millet , Guillermo R. Lázaro , Anna Benavent doi: https://doi.org/10.1101/2024.06.20.24309256 Joaquim Oristrell 1 Parc Taulí Hospital Universitari. Institut d’Investigació i Innovació Parc Taulí (I3PT-CERCA). Universitat Autònoma de Barcelona . Catalonia MD, PhD Roles: Emeritus researcher Find this author on Google Scholar Find this author on PubMed Search for this author on this site For correspondence: joristrell{at}tauli.cat Anna Pascual 2 Digital Organization. Parc Taulí Hospital Universitari. Institut d’Investigació i Innovació Parc Taulí (I3PT-CERCA). Universitat Autònoma de Barcelona . Catalonia PhD Roles: Projects chief Find this author on Google Scholar Find this author on PubMed Search for this author on this site Pere Millet 3 Digital Organization. Parc Taulí Hospital Universitari. Institut d’Investigació i Innovació Parc Taulí (I3PT-CERCA). Universitat Autònoma de Barcelona . Catalonia BSCEN Roles: Programmer analyst Find this author on Google Scholar Find this author on PubMed Search for this author on this site Guillermo R. Lázaro 4 Grupo AIA . Madrid. Spain PhD Roles: Data scientist Find this author on Google Scholar Find this author on PubMed Search for this author on this site Anna Benavent 5 Parc Taulí Hospital Universitari. Institut d’Investigació i Innovació Parc Taulí (I3PT-CERCA). Universitat Autònoma de Barcelona . Catalonia MSTE Roles: Director of Digital Strategy Find this author on Google Scholar Find this author on PubMed Search for this author on this site Abstract Full Text Info/History Metrics Data/Code Preview PDF Abstract OBJECTIVE Reliable hospital discharge predictions still remain an unmet need. In this study, we aimed to forecast daily hospital discharges by ward, until seven days ahead, using machine learning methods. METHODS We analyzed all (n=67308) hospital admissions proceeding from the Emergency department in a University Hospital, from January-2018 to August-2023. Several train-test splits were defined simulating a prospective, weekly acquisition of data on new admissions. First, we trained Light Gradient Boosting Machines (LGBM) and Multilayer Perceptron (MLP) models to generate predictions on length of stay (LOS) for each admission. Based on predicted LOS, timeseries were built and predictions on daily hospital discharges, by ward, seven days into the future, were created employing diverse forecasting techniques. Mean absolute error (MAE) between predicted and observed discharges was used to measure the accuracy of predictions. Discharge predictions were also categorized as successful if they did not exceed by 10% the mean number of hospital daily discharges. RESULTS LGBM slightly outperformed MLP in 25 weekly LOS predictions (MAE 4.7±0.7 vs 4.9±0.7 days, p<0.001). The best techniques to forecast, seven days ahead, the daily number of hospital discharges were obtained using Prophet (MAE 5.0, R 2 =0.85), LGBM (MAE 5.2, R 2 =0.85), seasonal ARIMA (MAE 5.5, R 2 =0.81) and Temporal Fusion Transformer (TFT)(MAE 5.7, R 2 =0.83). After categorizing the predictions, LGBM, Prophet, seasonal ARIMA and TFT reached successful predictions in 82.3%, 81.1%, 77.7% and 77.1% of days, respectively. CONCLUSIONS Successful predictions of daily hospital discharges, seven days ahead, were obtained combining LOS predictions using LGBM and timeseries forecasting techniques. Lay abstract Currently, most public hospitals in western countries have close to full occupancy for significant periods of time. Under these conditions, it is common for emergency admissions to be delayed, which causes significant patient discomfort and can negatively impact their quality of care. Predicting the daily number of hospital discharges would enable hospital administrators to implement measures to prevent hospital overcrowding. In this study, we used several artificial intelligence methods to predict, seven days in advance, the number of daily hospital discharges, obtaining successful predictions in more than 80% of the days that were analyzed. In conclusion, we have shown that available machine learning methods offer new and valuable options to predict hospital discharges, until seven days in advance, with high efficiency and reliability. HIGHLIGHTS Accurate predictions of hospital discharges could enable optimization of patient flow management within hospitals. Emerging machine learning and time-series forecasting methods present novel avenues for refining hospital discharge predictions. In this study, we integrated length of stay predictions using Light Gradient Boosting Machines with several time-series forecasting techniques to produce daily hospital discharge forecasts. Through the combined used of these methodologies, we were able to obtain successful predictions on more than 80% of the days. Introduction Currently, most public hospitals in western countries have close to full occupancy for significant periods of time. Under these conditions, it is common for emergency admissions to be delayed, which causes significant patient discomfort and can negatively impact their quality of care. Predicting the daily number of hospital discharges would enable hospital administrators to implement measures to prevent hospital overcrowding [ 1 ]. Although many studies have analyzed the factors that impact on hospital stays in specific services or populations [ 2 – 6 ], forecasting the overall daily number of hospital ward discharges is complex and has received less attention [ 7 ]. In recent years, some experiences using machine learning methods to predict hospital discharges have been published, some of them based on administrative data with few or no clinical covariates [ 8 – 10 ], and others being modeled to generate discharge forecasts only 24h in advance [ 11 – 13 ], which is a very short time lapse for hospital managers to be able to adapt hospital resources to the predicted healthcare demands. In this study we aimed to predict the number of daily discharges by ward, seven days into the future, in a large university hospital. First of all, using clinical variables, we predicted the individual length of stay (LOS) with two different machine learning algorithms. Secondly, the number of hospital and ward daily discharges was predicted based on individual LOS predictions and calendar-related variables using a tree-based and timeseries forecasting methods. Material and Methods Design We retrospectively analyzed the electronic medical records of the patients discharged from the Corporació Sanitaria Parc Taulí (CSPT). Our institution is a 714-bed public university hospital serving a population of 394,000 in Barcelona county (Catalonia). We included all the patients ≥18 years being admitted from the Emergency department (ED) and discharged from our hospital from 1 st January 2018 until 31 st August 2023. The patients admitted in 2020 were excluded from the analysis due to the uncommon hospital dynamics as a result of the COVID’s pandemic. Programmed admissions, and patients admitted to Pediatrics, Psychiatry or Rehabilitation services were excluded. To generate forecasts, a prospective inclusion of patients was simulated. All hospitalized patients until 25 index dates (every Monday from March 6 until August 21, 2023) were analyzed. First of all, for each patient, a LOS prediction was made based on variables collected at the time of admission (see section “Patient-related variables” described below). Secondly, aggregating the patients admitted before each index date by their predicted day of discharge, a timeseries dataframe with the predicted number of discharges per day, by departments and wards, was obtained. Since new, unknown, admissions occur between each index date and the day to be predicted, a second model was developed, using a timeseries approach, that included the predicted number of discharges per day of the previous model as well as other temporal and autoregressive variables (see section “Calendar-related variables” described below), combining an estimate of discharges that will occur for known patients as well as discharges for patients yet to be admitted. Variables used for the analysis Patient-related variables. All patient-related variables were collected in the ED, before hospital admission. These included the age, gender, ED diagnoses and comorbidities, medical procedures performed or requested from the ED, prescription of broad-spectrum antibiotics (Anatomical Therapeutic Chemical codes J01DH or J01CR05), number of ED visits in the last 6 months, weekday at admission, and time elapsed from ED admission until hospital admission. Finally, the clinical service, hospital ward, physician on charge, and LOS were also collected. Principal diagnoses were encoded using ICD-10-CM and grouped into 1195 categories according to pathophysiology or 1211 categories according to organ involvement. Principal diagnoses and comorbidities were also classified into 159 common syndromes. Finally, a comorbid index was developed using the B coefficients of comorbidities that significantly impacted on LOS in a linear regression model ( Supplementary Table 1 ). ED procedures were also classified using ICD-10-PCS codes and 53 variables identifying the most common emergency procedures were generated. Calendar-related variables: the timeseries dataframe with predicted discharges by day was completed with variables identifying weekdays, non-working days, and their respective lagged variables. Sine and cosine Fourier’s terms were also included as independent variables to capture weekly or monthly patterns in hospital discharges using the numpy.fft function of the NumPy package, version 1.23.5 [ 14 ]. Prediction of length of stay (LOS) We used Light Gradient Boosting Machines (LGBM) and Multilayer Perceptron (MLP) to predict the LOS for all admissions occurring until 25 index dates. LGBM is a tree-based, open access machine learning method developed by Microsoft [ 15 , 16 ], while MLP is a network of fully connected neurons with a non-linear activation function [ 17 ]. For both methodologies, we employed patient-related variables collected at the ED before hospital admission. Mean absolute error (MAE) was used as the metric applied to the loss function. Further details on LGBM and MLP methods applied are described in the Supplementary Methods section. Predictions of daily number of hospital discharges Weekly forecasts on daily number of hospital discharges were generated with LGBM and compared with six timeseries forecasting methods: Seasonal ARIMA with exogenous variables (SARIMAX), Prophet, Long-Short term memory (LSTM), Temporal Fusion Transformer (TFT), Neural Hierarchical Interpolation for timeseries forecasting (N_HiTS), and Temporal Convolutional Network (TCN). The SARIMAX model is a statistical timeseries forecasting technique that extends the traditional Autoregressive Integrated Moving Average (ARIMA) model to account for seasonality and additional covariables [ 18 ]. Prophet is a non-linear, additive regression model developed by Facebook that captures the linear trend and uses Fourier’s terms to capture the seasonality of the timeseries. Holiday or other categorical effects can also be added as dummy variables [ 19 , 20 ]. LSTM is a recurrent neural network used for natural language processing and timeseries forecasting [ 21 ]. TFT is a neural network developed by Google that allows to generate timeseries forecasts adding attention mechanisms to LSTM-type encoders [ 22 ]. N_HiTS is a recently described neural network architecture for timeseries forecasting based on multiple interconnected blocks of MLP networks [ 23 ]. Finally, TCN has been developed for timeseries forecasting using several stacked, one-dimensional, convolutional networks, feeding only from past observations to forecast future timesteps [ 24 ]. Building the timeseries After obtaining the LGBM-predicted length of stay for each episode, the predicted date of discharge was calculated by adding the predicted length of stay to the corresponding date of admission. Grouping the episodes by the predicted date of discharge, hospital departments, wards and gender resulted in department and ward-specific timeseries dataframes, each one with predicted and real discharges by date. These timeseries dataframes were completed with known calendar-related variables and splitted into train and test datasets. The real number of discharges in each test dataset were set to missing before running the predictions. All this process was repeated for each index date, from 2023-03-06 until 2023-08-21, in order to obtain 25 train-test datasets and weekly predictions on daily discharges. For hospital discharge predictions using LGBM, we used the whole study period. However, due to the exclusion of year 2020 admissions, we only included data from January 2021 to August 2023 for all timeseries forecasting methods. Further details on LGBM and timeseries methods applied to predict the daily number of discharges are described in the Supplementary Methods section. Comparing the prediction methods and classification of the predictions Mean absolute error (MAE) and median absolute errors (MdAE) were the metrics applied to compare the different machine learning methods. In addition, Akaike Information Criterion [ 25 ] was also calculated for predictions performed in three index dates (6 th March, 8 th May and 10 th July 2023), and their mean values were used to compare between the most efficient methodologies. Finally, as an excess of real discharges over predicted ones usually does not raise significant concerns for patient flow, we categorized daily predictions as unsuccessful if the predicted discharges exceeded by 10% the mean number of daily discharges; otherwise, they were considered successful. Statistical analysis Continuous variables are reported as mean and standard deviation and categorical variables are summarized by frequencies and percentages. Associations between continuous variables were analyzed using Pearson’s correlation. Differences on continuous variables between groups were assessed using Student’s t test if univariate or linear regression for multivariate analysis. These analyses were performed using the Python’s scipy version 1.10.1 [ 26 ] and statsmodels version 0.14.0 [ 27 ] packages. Ethics All data were treated anonymously in order for this study to comply with the provisions of Spanish and European laws on Protection of Personal Data. The study was approved by the ethics committee of the CSPT. Results A total of 67308 hospitalization episodes proceeding from the Emergency department (ED) took place in the Medical (n=35935), Surgical (n=14156), Gynecological-Obstetrical (n=8533) or Short-stay (n=7677) departments of the CSPT during the period of study. Additionally, 1007 patients were discharged from the Intensive Care Unit (57.1% due to exitus, and 24.3% being transferred to other hospitals). Mean age of the admitted patients was 65.3 (Standard deviation [SD] 20.7) years and 51.8% were women. The length of hospital stay showed an exponential distribution with a mean length of stay of 8.1 days (SD 11.4; range 0-355; median 4.0) ( Supplementary Figure 1 ). Mean number of diagnoses established in the ED was 1.4 (SD 0.9), and mean number of past comorbidities was 4.2 (SD 3.9). A more detailed description of the characteristics of the episodes of hospitalization included in this study is depicted in Table 1 . View this table: View inline View popup Download powerpoint Table 1. Characteristics of the hospitalization episodes included in the study Prediction of length of stay (LOS) Weekly LOS predictions for new admission episodes occurring from 6 th March until 27 th August 2023 are shown in Supplementary Table 2 . LOS predictions using LGBM slightly outperformed MLP, with MAE values of 4.7 (SD 0.7) for 25 weekly LGBM predictions versus 4.9 (SD 0.7) for MLP, t-test p<0.001) ( Supplementary Table 2 ). Due to these results, the predicted number of daily discharges inferred from LGBM LOS predictions was used, in addition to calendar-derived variables, for the final prediction of daily hospital discharges. Feature importance in LGBM LOS predictions is shown in Supplementary Figure 2 . Median stay by ward and service, and mean or median stay by diagnosis (ungrouped and grouped), age, time spent in the ED before admission, main procedures, use of broad spectrum antibiotics, and the comorbidity index were the most important variables to predict LOS. Using univariate and multivariate linear regression analysis ( Supplementary Table 3 ) we observed that higher errors in LGBM LOS predictions were associated with higher comorbidity indexes, admission on Medical or Surgical departments (instead of Obstetrics or Short stay wards), use of broad spectrum antibiotics, or being diagnosed with a disease with longer mean LOS. Prediction of hospital daily discharges Mean number of daily discharges was 38.9 (SD 17.6) for all admitted patients proceeding from the ED. Mean daily discharges for medical, surgical, obstetrical and short-stay departments were 21.0 (SD 12.9), 8.3 (4.4), 4.5 (SD 2.1) and 4.6 (SD 2.5), respectively. Daily discharges in our hospital showed a strong weekly seasonal pattern, with important fluctuations between weekends and working days, more evident for medical and surgical departments than for other services ( Supplementary Figure 3 ). Forecasts on hospital daily discharges were generated using LGBM and diverse timeseries methodologies. Mean and SD of MAE for 25 weekly predictions of whole hospital discharges was 5.0 (SD 1.7) using Prophet; 5.2 (SD 1.6) for LGBM; 5.5 (SD 1.7) with SARIMAX; 5.7 (SD 1.7) for TFT; 6.2 (SD 6.0) for LSTM; 6.5 (SD 2.8) for TCN; and 7.7 (SD 6.7) discharges for N_HiTS. Similarly, Pearson’s correlations between predicted and observed whole hospital discharges were R 2 =0.85 for LGBM and Prophet, 0.83 for TFT, 0.81 for SARIMAX, 0.76 with LSTM, 0.72 for TCN and 0.66 with N_HiTS. Mean MAE of all predictions on discharges, by forecasting method, department and ward are detailed in Table 2 . View this table: View inline View popup Download powerpoint Table 2. Accuracy of different machine learning methods to predict the daily number of hospital discharges, by departments and wards. The best results for hospital discharge prediction were obtained using Prophet, LGBM, SARIMAX or TFT ( Table 2 , Figure 1 ). Prophet and SARIMAX offered a lower Akaike Information Criterion compared to LGBM and TFT since they reached similar predictions with lower number of variables. LGBM obtained the best predictions in medical wards, while SARIMAX and Prophet generated slightly better results in the surgical department ( Table 2 , Supplementary Fig 4 ). Download figure Open in new tab Figure 1. Concatenated weekly predictions of all hospital discharges. A: Light Gradient Boosting Machines and Prophet. B: SARIMAX and Temporal Fusion Transformer. The most relevant variables for predicting daily hospital discharges using LGBM, as revealed by feature importance analysis, were the number of LOS-predicted discharges, lagged-values of daily admissions and discharges, transformed Fourier’s sinus and cosinus variables, and a category identifying the non-working days ( Supplementary Fig 5 ). Proportion of dates with a successful prediction Finally, as already mentioned, predictions for the whole hospital were classified as unsuccessful if they exceeded by 10% the mean number of daily discharges. With a mean number of 38.4 daily discharges we considered an unsuccessful prediction if the number of predicted discharges, for the whole hospital, exceeded in >4 the number of observed discharges. According with this definition, we observed that 144 (82.3%), 142 (81.1%), 136 (77.7%) and 135 (77.1%) of the 175 dates between 6 th March and 27 th August 2023 were successfully predicted with LGBM, Prophet, SARIMAX or TFT respectively ( Figure 2 ). Download figure Open in new tab Figure 2. Categorization of discharge predictions as successful or unsuccessful (see criteria on the text) on 175 consecutive days. A. Prophet’s predictions. B. Light Gradient Boosting Machines predictions. C. SARIMAX predictions. D. Temporal Fusion Transformer predictions. Discussion In this study we have combined individual length of stay predictions with temporal series forecasting to predict the hospital discharges by department and wards, seven days in the future from 25 index dates. This approach outperforms previous studies, most of them aimed to predict daily hospital discharges based on the length of stay (LOS) of each particular admission episode without considering trends or seasonalities [ 28 – 31 ], or predicting daily discharges using timeseries forecasting methods without considering individual clinical variables that impact on LOS [ 8 , 10 ]. Our study is retrospective. However, we managed to make 25 weekly predictions, each one based on new admissions along the last week, simulating a prospective collection of data and generating weekly predictions for a period of five months. Our results show that it is feasible to obtain a significant estimation of the number of daily discharges by ward, up to seven days in advance, with a single weekly acquisition of data on new admissions, making it easy to be applied in many settings. We only analyzed hospital admissions proceeding from the ED. It is conceivable that the inclusion of programmed admissions (i.e. programmed surgery), which often have a more predictable hospital stay [ 12 ] would probably improve our predictions. First of all we tried to compare LGBM, a tree-based algorithm, with a MLP neural network to predict individual LOS. In our assays, a correctly tuned LGBM to prevent overfitting offered better results than MLP, at higher speed, and with no need of scaling input data. We are not aware of previous attemps to use LGBM to predict LOS, although other boosting techniques have been tried and showed better results than classical tree-based methods like random forest [ 32 ]. In our opinion, the superiority of LGBM could be explained by its known high efficiency in handling large datasets with many categorical variables and sparse data [ 15 ]. Among the limitations for LOS predictions we should mention that we did not include some variables that could probably impact on better LOS predictions, like the social status (i.e. patients living alone, poverty,..), laboratory values, or variables on drug therapies other than broad-spectrum antibiotics. In addition, we only analyzed the diagnoses and procedures performed or requested from the ED. It is probable that incorporating more precise diagnoses achieved during hospitalization, or new procedures performed after hospital admission, would probably improve the predictions. In any case, since we intended to predict the discharges several days in advance, unlike some previous studies [ 12 ], we did not find convenient to take into account the diagnoses established at discharge. Secondly, after performing individual LOS predictions, we compared LGBM and diverse timeseries forecasting methods to predict hospital daily discharges. In the past, linear regression models [ 3 ] and classical timeseries analysis with ARIMA, seasonal ARIMA, ARMA or exponential smoothing have already been applied to forecast hospital patient flow with little success [ 9 , 33 ]. SARIMAX was previously used to predict hospital admissions and occupancy [ 10 ], but it has not been applied, to our knowledge, to forecast hospital discharges. In recent years, new and efficient computational tools have appeared for timeseries forecasting that have now been assayed in this study. Facebook’s Prophet, described in 2017, has already been assayed to predict hospital discharges using holidays as the unique covariate [ 8 ]. Using the predicted number of daily discharges (derived from predicted LOS) as an additional covariate, we have been able to increase Prophet’s predictability. In our opinion, although very good predictions could be obtained with Prophet or SARIMAX, both methods are rather simple prediction tools, where forecasts are mainly built on past values of the target variable, with few covariates, so that they could generate misleading predictions in changing scenarios like the opening or closing of new hospital wards, or if significant changes in inhospital patient composition do occur. LGBM also offered very good predictions. In the past, other tree-based methods, like random forest or XGBoost, have been used in classification tasks, to identify hospitalized patients that will probably leave the hospital 24 hours in advance [ 12 , 34 ]. We are not aware that LGBM, or any other boosting technique, have been used in regression tasks, as we did, to predict the daily number of hospital discharges. LGBM is a flexible method, that can be adjusted with covariates, rapid to execute and interpretable. We also tried four different timeseries neural network architectures (LSTM, N_HiTS, TCN and TFT). We are not aware of previous attemps to use, neither of them, to predict hospital discharges. Among these methods, TFT clearly reached the best predictions, very close to those obtained with LGBM, Prophet or SARIMAX, but with significantly higher computational costs. Finally, we categorized the predictions as successful if they did not exceed by 10% the mean number of daily discharges, in a similar way as other authors have applied to classify predictions on hospital admissions [ 10 ]. Using this approach, successful predictions in more than 80% of the dates were obtained with LGBM and Prophet. In conclusion, we have shown that available machine learning methodologies and timeseries forecasting techniques offer new and valuable options to predict hospital discharges by ward or department, until seven days in advance, with high efficiency and reliability. We have also shown that a two-phase forecast, initially predicting LOS using LGBM and subsequently forecasting the number of daily discharges applying LGBM or Prophet, yielded the best results. These methods should enable the departmental directors and hospital managers to better adjust hospital resources to future healthcare needs. Data Availability Data produced in the present study are available upon reasonable request to the authors SUPPLEMENTARY MATERIAL 1.- Supplementary Methods 1.- PREDICTING THE LENGTH OF STAY (LOS) a) Prediction of LOS using Light Gradient Boosting Machines (LGBM) Patient-related variables were used to build LGBM models using the Python’s lightgbm package, version 3.3.5 [ 1 , 2 ]. Training datasets comprised all patients admitted from 1 st January 2018 until 78 days before each index date, while the test datasets involved the patients admitted during the last 77 days before each index date. The length of the test periods was chosen empirically after trying different proportions of train/test periods. Limits to the number of leaves, and a minimum number of episodes by leave were established to prevent LGBM trees to overfit. Finally, all models were validated by means of 5-fold cross-validation on the training dataset. b) Prediction of LOS using Multilayer Perceptron (MLP) A MLP neural network was built with the TensorFlow package, version 2.13.0 [ 3 ], using the same covariables and test periods as for LGBM. For MLP each training period was splitted into a train and a validation dataset, the latter including the admissions of the last 4 months of the training period. Different network architectures, number of epochs and learning rates were assayed, plotting the validation loss curves to control overfitting. The final model was a three-layered MLP, with an input layer capturing 376 different variables, a hidden layer with 4 fully connected neurons and a dense fully connected output layer. 2.- PREDICTING THE DAILY NUMBER OF HOSPITAL/DEPARTMENT/WARD DISCHARGES Hospital discharge predictions with LGBM For hospital discharge prediction with LGBM we also used the Python’s lightgbm package, version 3.3.5. The train-test split was set to 120 days before each index date, extending the test period until seven days ahead from each corresponding index date. Seven LGBM models, one for each day of the week were built to predict the number of discharges by hospital department and ward, seven days ahead from each index date. Mean absolute error (MAE) was the metric applied to the loss function. Limits to the number of leaves, and a minimum number of days by leave were established to prevent LGBM models to overfit. Hospital discharge predictions using seasonal ARIMA with exogenous variables (SARIMAX) Different combinations of the components of the ARIMA class forecasting methodology were assayed using the statsmodels version 0.14.0 [ 4 ] and pmdarima auto-arima version 2.0.4 [ 5 ] packages. A seasonal ARIMA (0,0,[ 7 ])x(1,1,0,7) model, with exogenous variables (SARIMAX) was chosen as it offered the lower Akaike Information Criterion and higher Log-Likelihood [ 6 ] values. One-shot, seven-days ahead, 25 weekly predictions were built using all discharge observations until the eve of each index date for training, and assigning to the test period all observations from each index date up to six additional days ahead. Independent predictions were done for each department and ward using the predicted number of discharges (obtained with LGBM LOS predictions), non-working days and holiday eves as covariates. Hospital discharge predictions using Prophet One-shot, seven-days ahead, weekly discharge predictions were also generated with Facebook’s Prophet version 1.1.5 [ 7 ], using identical train-test splitting and covariates as for SARIMAX. Hospital discharge predictions using LSTM For LSTM predictions, a test period of 21 days preceding each index date and spanning 7 days into the future, was established. The validation phase covered 80 days prior to the test period, while the training data extended from 1 st January 2021 until the beginning of the validation period. One-day sliding window was used to generate supervised arrays with an input length of 21 days and an output length of 7 days, for the training, validation and test datasets. Scikit-learn [ 8 ] MinMaxScaler was used to scale all variables from −1 to +1 values. LSTM models were built with the TensorFlow package, using root mean squared error as the loss function. Training and validation loss plots were used to control overfitting. Final predictions were obtained after inverse transforming the scaled predictions on the test datasets. Hospital discharge predictions using TFT Pytorch-Forecasting version 1.0.0, TemporalFusionTransformer package [ 9 ] was used for TFT forecasts. Test datasets extended from 70 days before each index date until 7 days after this date. The validation dataset included the observations of the last 7 days before each test dataset, and the training datasets extended from 1 st January 2021 until the beginning of each validation dataset. One-day sliding window was used to generate supervised arrays with an input length of 70 days and an output length of 7 days. Early stopping on validation losses, patience limits, and validation loss plots with TensorBoard were used to control overfitting. Different attention head sizes, hidden sizes and learning rates were empirically tried to obtain the best results. Quantile loss was the metric used for the loss function. Hospital discharge predictions using N_HiTS Pytorch-Forecasting version 1.0.0 N_HiTS package was used for N_HiTS forecasts [ 9 ]. The same train, validation and tests timeseries dataframes and one-day sliding windows arrays used for TFT’s forecasting served for N_HiTS forecasts. Early stopping on validation losses, patience limits, and validation loss plots on TensorBoard were also used to control overfitting. MQF2DistributionLoss was the metric applied for the loss function. Hospital discharge predictions using TCN TensorFlow and Keras version 2.14.0 [ 10 ] packages were used to build TCN models. Independent models were created for overall hospital discharges and for each major hospital departments. In addition, weekly predictions with individual forecasts from day one until seven days ahead were generated using convolutional widths of 7 days and six stacked convolutional layers with progressive dilations. A validation dataset was used for each prediction. Validation losses, patience limits and validation loss plots on TensorBoard were used to control overfitting. MAE was the metric used for the loss function. 2.-Supplementary Tables View this table: View inline View popup Download powerpoint Supplementary Table 1. Impact of comorbidities on length of stay (multiple linear regression) View this table: View inline View popup Download powerpoint Supplementary Table 2. Accuracy of weekly predictions of length of stay for episodes of hospitalization View this table: View inline View popup Download powerpoint Supplementary Table 3. Factors associated with higher errors in LOS predictions 3.-Supplementary Figures Download figure Open in new tab Supplementary Figure 1. Distribution of length of stays in 67,308 hospitalization episodes proceeding from the Emergency department. Download figure Open in new tab Supplementary Figure 2. Feature importance in the prediction of length of hospital stay using Light Gradient Boosting Machines. Download figure Open in new tab Supplementary Figure 3. Seasonality of hospital discharges in patients admitted from the Emergency department. A: Overall discharges. B: Hospital discharges by department (sample May 2023). Download figure Open in new tab Supplemental Figure 4. Concatenated weekly predictions of discharges. A: Light Gradient Boosting Machines and Prophet in Medical Deapartment. B: SARIMAX and Temporal Fusion Transformer in Medical Department. C: Light Gradient Boosting Machines and Prophet in Surgical Deapartment. B: SARIMAX and Temporal Fusion Transformer in Surgical Department. Download figure Open in new tab Supplemental Figure 5. Feature importance for LGBM hospital discharge predictions: A: Model for first day prediction; B: Model for 2nd day prediction; C: Model for 3rd day prediction; D: Model for 4th day prediction; E: Model for 5th day prediction; F: Model for 6th day prediction; G: Model for 7th day prediction. FUNDING This research was partially financed by the Digital Strategy Department of the Corporació Sanitària Parc Taulí. Corporació Sanitària Parc Taulí is a 714-bed public university hospital serving a population of 394,000 in Barcelona county (Catalonia). The coauthors: Anna Pascual, Pere Millet and Anna Benavent are membres of this department at the Corporació Sanitària Parc Taulí. Guillermo R.Lázaro, employed at Grupo AIA, a private enterprise specializing in artificial intelligence, received funding from the Digital Strategy Department of the Corporació Sanitària Parc Taulí for the development of this project. Joaquim Oristrell, former Director of the Internal Medicine Service at Corporació Parc Taulí did not receive any funding for this project. COMPETING INTERESTS None declared. ETHICAL APPROVAL This study was approved by the ethics committee of the Corporació Sanitària Parc Taulí. ACKNOWLEDGEMENTS Tomás Gil (Digital Strategy department, Corporació Sanitària Parc Taulí) for his participation in the acquisition of data. Vicens Gaitán (SCALAI Scientific Director. Barcelona) for his contribution in the design of this study. Ricard Comet (Internal Medicine Department, Corporació Sanitària Parc Taulí) and Xavier Bonfill (Epidemiology Department, Hospital de la Santa Creu I Sant Pau, Barcelona) for their useful comments on the manuscript. REFERENCES 1.-. ↵ Resar R , Nolan K , Kaczynski D , Jensen K. Using real-time demand capacity management to improve hospitalwide patient flow . Jt Comm J Qual Patient Saf 2011 ; 37 : 217 – 227 . OpenUrl PubMed 2.-. ↵ LaFaro RJ , Pothula S , Kubal KP , et al. Neural network prediction of ICU length of stay following cardiac surgery based on pre-incision variables . PLoS ONE 2015 : 10 : e0145395 . OpenUrl 3.-. ↵ Verburg IWM , de Keizer NF , de Jonge E , et al. Comparison of regression methods for modeling intensive care length of stay . PLoS ONE 2014 ; 9 : e109684 . OpenUrl CrossRef PubMed 4.-. ↵ Moran JL , Solomon PJ , ANZICS Centre for Outcome and Resource Evaluation (CORE) of the Australian and New Zealand Intensive Care Society (ANZICS). A review of statistical estimators for risk-adjusted length of stay: analysis of the Australian and New Zealand Intensive Care Adult Patient Data-Base, 2008-2009 . BMC Med Res Methodol 2012 ; 12 : 68 . 5.-. ↵ Tsai PF , Chen PC , Chen YY , et al. Length of hospital stay prediction at the admission stage for cardiology patients using artificial neural network . J Healthc Eng 2016 ; 7035463 . 6.-. ↵ Launay CP , Kabeshova A , Lanoéz A , Beauchet O. Age effect on the prediction of risk of prolonged length hospital stay in older patients visiting the emergency department: results from a large prospective geriatric cohort study . BMC Geriatr 2018 : 18 , 127 . 7.-. ↵ de Grood A , Blades K , Pendharkar SR. A review of discharge-prediction processes in acute care hospitals . Healthc Policy 2016 ; 12 : 105 – 115 . OpenUrl 8.-. ↵ McCoy TH Jr , Pellegrini AM , Perlis RH. Assessment of time-series machine learning methods for forecasting hospital discharge volume . JAMA Netw Open 2018 ; 1 : e184087 . OpenUrl 9.-. ↵ Lin WT. Modeling and forecasting hospital patient movements: univariate and multiple time series approaches . Int J Forecast 1989 ; 5 : 195 – 208 . OpenUrl 10.-. ↵ Eyles E , Redaniel MT , Jones T , Prat M , Keen T. Can we accurately forecast non-elective bed occupancy and admissions in the NHS? A time-series MSARIMA analysis of longitudinal data from an NHS Trust . BMJ Open 2022 ; 12 : e056523 . OpenUrl Abstract / FREE Full Text 11.-. ↵ van Walraven C , Forster AJ. The TEND (Tomorrow’s Expected Number of Discharges) model accurately predicted the number of patients who were discharged from the hospital the next day . Journal of Hospital Medicine 2018 ; 13 : 158 – 163 . OpenUrl 12.-. ↵ Zhou J , Brent AJ , Clifton DA , Walker AS , Eyre DW. Improving patient flow through hospitals with machine learning based discharge prediction . medRxiv preprint doi: 10.1101/2023.05.02.23289403 . OpenUrl Abstract / FREE Full Text 13.-. ↵ Levin S , Barnes S , Toerper M , et al. Machine-learning-based hospital discharge predictions can support multidisciplinary rounds and decrease hospital length-of-stay . BMJ Innov 2021 ; 7 : 414 – 421 . OpenUrl Abstract / FREE Full Text 14.-. ↵ Harris , C.R. , Millman , K.J. , van der Walt , S.J. , et al. Array programming with NumPy . Nature 2020 : 585 : 357 – 362 . Version 1.23.5. https://numpy.org . Accessed 28th March 2024 . OpenUrl CrossRef PubMed 15.-. ↵ Ke G , Meng Q , Finley T , et al. Lightgbm: A highly efficient gradient boosting decision tree . Adv Neur Inform Proces Systems 2017 ; 30 : 3149 – 3157 . OpenUrl 16.-. ↵ LightGBM. Version 3.3.5 . https://lightgbm.readthedocs.io/en/latest/index.html . Accessed 28th March 2024 . 17.-. ↵ Abadi M , Agarwal A , Barham P , et al. TensorFlow: Large-scale machine learning on heterogeneous systems . Version 2.13.0. https://www.tensorflow.org . Accessed 28th March 2024 . 18.-. ↵ Arunraj NS , Ahrens D , Fernandes M . Application of SARIMAX model to forecast daily sales in food retail industry . IJORIS 2016 ; 7 : 1 – 2 . OpenUrl 19.-. ↵ Taylor SJ , Letham B. Forecasting at a scale . Peer J Preprints . doi: 10.7287/peerj.preprints.3190v2 , publ: 27 Sep 2017 . Accessed 28th March 2024 . OpenUrl CrossRef 20.-. ↵ Zunic E , Korjenic K , Hodzic K , Donko D. Application of Facebook’s Prophet algorithm for successful sales forecasting based on real-world data . Int J Comp Sci Technol 2020 ; 12 : 23 – 36 . OpenUrl 21.-. ↵ Hochreiter S , Schmidhuber J. Long short-term memory . Neural Comput 1997 ; 9 : 1735 – 80 . OpenUrl CrossRef PubMed Web of Science 22.-. ↵ Lim B , Arik SO , Loeff N , et al. Temporal fusion transformers for interpretable multi-horizon time series forecasting . arXiv:1912.09363 , publ: 27 Sep 2020 . 23.-. ↵ Challu C , Olivares KG , Oreshkin BN , et al. N-HiTS: Neural Hierarchical Interpolation for Time Series Forecasting . arXiv: 2201.12886v6 , publ: 29 Nov 2022 . 24.-. ↵ Bai S , Kolter JZ , Koltun V. An empirical evaluation of generic convolutional and recurrent networks for sequence modeling . arXiv:1803.01271v2 , published 19 Apr 2018 . 25.-. ↵ Akaike H. A new look at the statistical model identification . IEEE Trans Automatic Control 1974 ; 19 : 716 – 723 . OpenUrl CrossRef 26.-. ↵ Virtanen P , Gommers R , Oliphant TE , et al. SciPy 1.0: Fundamental Algorithms for Scientific Computing in Python . Nature Methods , 2020 : 17 : 261 – 272 . OpenUrl 27.-. ↵ Seabold S , Perktold J. Statsmodels: Econometric and statistical modeling with python . Proceedings of the 9th Python in Science Conference . 2010 . 28.-. ↵ Launay CP , Rivière H , Kabeshova A , Beauchet O. Predicting prolonged length of stay in older emergency department users: Use of a novel analysis method, the Artificial Neural Network . Eur J Intern Med 2015 ; 26 : 478 – 482 . OpenUrl 29.-. Wrenn J , Jones I , Lanaghan K , Congdon CB , Aronsky D. Estimating patient’s length of stay in the Emergency Department with an artificial neural network . AMIA Annu Symp Proc 2005 ; 2005 : 1155 . 30.-. Tsai PF , Chen PC , Chen YY , et al. Length of hospital stay prediction at the admission stage for cardiology patients using Artificial Neural Network . J Healthc Eng 2016 ; 2016 : 7035463 . 31.-. ↵ Ahn I , Gwon H , Kang H , et al. Machine Learning-based hospital discharge prediction for patients With cardiovascular diseases: development and usability study . JMIR Med Inform 2021 ; 9 : e32662 . OpenUrl 32.-. ↵ Faria M , Barbosa A , Guimarães T , Lopes J , Santos M. Predictive analytics for hospital discharge flow determination . Procedia Comput Sci 2022 ; 210 : 248 – 53 . OpenUrl 33.-. ↵ Jones SA , Joy MP , Pearson J. Forecasting demand of emergency care . Health Care Management Sci 2022 ; 5 : 297 – 305 OpenUrl 34.-. ↵ Barnes S , Hamrock E , Toerper M. Real-time prediction of impatient length of stay for discharge prioritization . J AM Med Inform Assoc 2016 ; 23 : e2 – e10 . OpenUrl CrossRef PubMed SUPPLEMENTARY METHODS REFERENCES 1.-. Ke G , Meng Q , Finley T , et al. Lightgbm: A highly efficient gradient boosting decision tree . Adv Neur Inform Proces Systems 2017 ; 30 : 3149 – 3157 . OpenUrl 2.-. LightGBM. Version 3.3.5 . https://lightgbm.readthedocs.io/en/latest/index.html . Accessed 28th March 2024 . 3.-. Abadi M , Agarwal A , Barham P , et al. TensorFlow: Large-scale machine learning on heterogeneous systems . Version 2.13.0. https://www.tensorflow.org . Accessed 28th March 2024 . 4.-. Seabold S , Perktold J. Statsmodels: Econometric and statistical modeling with python . Proceedings of the 9th Python in Science Conference . 2010 . 5.-. Smith , TG. pmdarima: ARIMA estimators for Python , 2017 . http://www.alkaline-ml.com/pmdarima [Online; accessed 2024-04-02 ]. 6.-. Akaike H. A new look at the statistical model identification . IEEE Trans Automatic Control 1974 ; 19 : 716 – 723 . OpenUrl CrossRef 7.-. Taylor SJ , Letham B. Forecasting at a scale . Peer J Preprints . doi: 10.7287/peerj.preprints.3190v2 , publ: 27 Sep 2017. Accessed 28th March 2024 . OpenUrl CrossRef 8.-. Pedregosa F , Varoquaux G , Gramfort A , et al. Scikit-learn: Machine Learning in {P}ython . J Machine Learn Research 2011 ; 12 : 2825 – 2830 . OpenUrl 9.-. Beitner J. Pytorch Forecasting . https://pytorch-forecasting.readthedocs.io/en/stable/ . Accessed 28th March 2024 . 10.-. Chollet F. Keras . GitHub repository . https://github.com/fchollet/keras . Accessed on 28th March 2024 . View the discussion thread. Back to top Previous Next Posted June 21, 2024. Download PDF Data/Code Email Thank you for your interest in spreading the word about medRxiv. NOTE: Your email address is requested solely to identify you as the sender of this article. Your Email * Your Name * Send To * Enter multiple addresses on separate lines or separate them with commas. You are going to email the following Hospital Discharge Prediction Using Machine Learning Message Subject (Your Name) has forwarded a page to you from medRxiv Message Body (Your Name) thought you would like to see this page from the medRxiv website. Your Personal Message CAPTCHA This question is for testing whether or not you are a human visitor and to prevent automated spam submissions. Share Hospital Discharge Prediction Using Machine Learning Joaquim Oristrell , Anna Pascual , Pere Millet , Guillermo R. Lázaro , Anna Benavent medRxiv 2024.06.20.24309256; doi: https://doi.org/10.1101/2024.06.20.24309256 Share This Article: Copy Citation Tools Hospital Discharge Prediction Using Machine Learning Joaquim Oristrell , Anna Pascual , Pere Millet , Guillermo R. Lázaro , Anna Benavent medRxiv 2024.06.20.24309256; doi: https://doi.org/10.1101/2024.06.20.24309256 Citation Manager Formats BibTeX Bookends EasyBib EndNote (tagged) EndNote 8 (xml) Medlars Mendeley Papers RefWorks Tagged Ref Manager RIS Zotero Tweet Widget Facebook Like Google Plus One Subject Area Health Informatics Subject Areas All Articles Addiction Medicine (573) Allergy and Immunology (865) Anesthesia (302) Cardiovascular Medicine (4453) Dentistry and Oral Medicine (444) Dermatology (383) Emergency Medicine (609) Endocrinology (including Diabetes Mellitus and Metabolic Disease) (1515) Epidemiology (15242) Forensic Medicine (30) Gastroenterology (1131) Genetic and Genomic Medicine (6615) Geriatric Medicine (669) Health Economics (1001) Health Informatics (4552) Health Policy (1372) Health Systems and Quality Improvement (1614) Hematology (543) HIV/AIDS (1270) Infectious Diseases (except HIV/AIDS) (15929) Intensive Care and Critical Care Medicine (1106) Medical Education (624) Medical Ethics (147) Nephrology (670) Neurology (6625) Nursing (346) Nutrition (999) Obstetrics and Gynecology (1148) Occupational and Environmental Health (957) Oncology (3344) Ophthalmology (979) Orthopedics (369) Otolaryngology (421) Pain Medicine (436) Palliative Medicine (130) Pathology (665) Pediatrics (1696) Pharmacology and Therapeutics (693) Primary Care Research (714) Psychiatry and Clinical Psychology (5461) Public and Global Health (9252) Radiology and Imaging (2207) Rehabilitation Medicine and Physical Therapy (1371) Respiratory Medicine (1197) Rheumatology (597) Sexual and Reproductive Health (715) Sports Medicine (530) Surgery (714) Toxicology (99) Transplantation (289) Urology (265) (function(){function c(){var b=a.contentDocument||a.contentWindow.document;if(b){var d=b.createElement('script');d.innerHTML="window.__CF$cv$params={r:'a02ea0ca6dd5f478',t:'MTc3OTk4NTY2MA=='};var a=document.createElement('script');a.src='/cdn-cgi/challenge-platform/scripts/jsd/main.js';document.getElementsByTagName('head')[0].appendChild(a);";b.getElementsByTagName('head')[0].appendChild(d)}}if(document.body){var a=document.createElement('iframe');a.height=1;a.width=1;a.style.position='absolute';a.style.top=0;a.style.left=0;a.style.border='none';a.style.visibility='hidden';document.body.appendChild(a);if('loading'!==document.readyState)c();else if(window.addEventListener)document.addEventListener('DOMContentLoaded',c);else{var e=document.onreadystatechange||function(){};document.onreadystatechange=function(b){e(b);'loading'!==document.readyState&&(document.onreadystatechange=e,c())}}}})();

Text is read by the "Ask this paper" AI Q&A widget below. Extraction quality varies by source — PMC NXML preserves structure cleanly, OA-HTML may include some navigation residue, and OA-PDF can have broken hyphenation. The publisher copy (via DOI) is the canonical version.

My notes (saved in your browser only)

Ask this paper AI returns verbatim quotes from the full text · source: preprint-html

Answers must be backed by verbatim quotes from this paper's full text. Hallucinated quotes are dropped automatically; if no verbatim passage answers the question, we say so. How this works

Citation neighborhood (no data yet)

We don't have any in-corpus citations linked to this paper yet. This is a recent paper (2024) — citers typically take a year or two to land, and the OpenAlex reference graph may still be filling in.

Source provenance

europepmc
last seen: 2026-05-20T01:45:00.602351+00:00
unpaywall
last seen: 2026-05-26T02:00:01.498150+00:00
License: CC-BY-NC-ND-4.0