key: cord-0736325-a3nt5wfw authors: Shafiekhani, Sajad; Namdar, Peyman; Rafiei, Sima title: A COVID-19 forecasting system for hospital needs using ANFIS and LSTM models: A graphical user interface unit date: 2022-03-28 journal: Digit Health DOI: 10.1177/20552076221085057 sha: 21a3d1a45fd24924467ef5bc5950ed70050f7adf doc_id: 736325 cord_uid: a3nt5wfw BACKGROUND: Centers for Disease Control and Prevention data showed that about 40% of coronavirus disease 2019 (COVID-19) patients had been suffering from at least one underlying medical condition were hospitalized; in which nearly 33% of them needed to be admitted to the intensive care unit (ICU) to receive specialized medical services. Our study aimed to find a proper machine learning algorithm that can predict confirmed COVID-19 hospital admissions with high accuracy. METHODS: We obtained data on daily COVID-19 cases in regular medical inpatient units, emergency department, and ICU in the time window between 21 July 2020 and 21 November 2021. Data for the first 183 days (training data set) were used for long short-term memory (LSTM) network, adaptive neuro-fuzzy inference system (ANFIS), support vector regression (SVR) and decision tree model training, whilst the remaining data for the last 60 days (test data set) were used for model validation. To predict the number of ICU and non-ICU patients, we used these models. Finally, a user-friendly graphical user interface unit was designed to load any time series data (here the trend of population of COVID-19 patients) and train LSTM, ANFIS, SVR or tree models for the prediction of COVID-19 cases for one week ahead. RESULTS: All models predicted the dynamics of COVID-19 cases in ICU and non- wards. The values of root-mean-square error and R(2) as model assessment metrics showed that ANFIS model had better predictive power among all models. CONCLUSION: Artificial intelligence-based forecasting models such as ANFIS system or deep learning approach based on LSTM or regression models including SVR or tree regression play a key role in forecasting the required number of beds or other types of medical facilities during the coronavirus pandemic. Thus, the designed graphical user interface of the present study can be used for optimum management of resources by health care systems amid COVID-19 pandemic. The coronavirus disease 2019 (COVID-19) caused by the severe acute respiratory syndrome-coronavirus-2 (SARS-CoV-2) virus, has put incredible pressure on health care systems worldwide and has led to above 60 million infected cases and over 1 million mortalities. 1 Centers for Disease Control and Prevention data show that 40% of diagnosed COVID-19 patients who were suffering from at least one underlying medical condition were hospitalized; which nearly 33% of them required to be admitted to the intensive care unit (ICU) to receive specialized medical services. 2 As the virus is extremely contagious and, in some cases, it causes severe diseases needing hospitalization, it is necessary to develop effective plans to ensure the adequacy of health care services in hospital settings. Thus, it is necessary to apply appropriate methods to forecast confirmed cases of COVID-19 who require hospital services in the future to facilitate the planning of a proper protection strategy. 3, 4 Despite the availability of different prediction models, machine learning and deep learning models were proven to have acceptable performance in hospital resource planning through figuring out the potential hospitalization requirements. Despite the importance of the issue, much of the existing literature has focused on forecasting models for COVID-19 cases or mortality rate. 5 Instead, this study aimed to develop a prediction model to facilitate the decision-making process through estimating the future states of hospital bed occupancy with an adaptive neuro-fuzzy inference system (ANFIS) and parameterized long short-term memory (LSTM) approach. In fact, during the outbreaks such as COVID-19 when the trend of the pandemic is oscillating, deep learning algorithms can play a key role in future expectations and plans. 6 Several studies have applied machine learning to health data to predict hospital length of stay, mortality, and unplanned emergency admissions. 7 In a systematic review by Hu et al., 8 different areas of deep learning application including disease detection, disease prognosis, unplanned readmission, prolonged length of stay and patient's final discharge diagnose were identified. In fact, deep learning algorithms are able to learn a more complex function with a high level of abstraction through the use of sequential layers of simple nonlinear functions. 5, 9 In a research conducted by Elmousalami et al., 10 ANFIS model was used to determine the COVID-19 cases. In addition to showing a good performance, the model had sufficient flexibility. Furthermore, through merging artificial neural networks and fuzzy logic systems, ANFIS can verify the nonlinearity in the time series. 10 To handle the complication of the COVID-19 time series data, several studies have proposed more effective models such as LSTM with the potential to predict a complex dynamic sequence accurately. 11 This model as an artificial recurrent neural network is the most widely used network with feedback connections in the field of deep learning. Therefore, in this study, an integrated use of prediction models such as LSTM and ANFIS was used to support the health care system for its hospital bed demand management. The method has some main advantages over other traditional approaches as it can maintain the power and accuracy of its estimates against uncertainty and environmental changes. In fact, through integrating neural networks and fuzzy logic, ANFIS has been widely used in forecasting systems. 9 Our study aimed to find a proper machine learning algorithm that can predict confirmed COVID-19 hospital admissions with higher accuracy. We obtained data on daily COVID-19 cases in regular medical inpatient units, emergency department, and ICU in the time window between 21 July 2020 and 21 November 2021 in a hospital dedicated to COVID-19 patients in Qazvin province, Iran. The data set included the number of COVID-19 cases hospitalized in the three mentioned wards. A sample of the data set is shown in Table 1 . We gathered data of ICU and non-ICU COVID-19 patients in 8 months; data for the first 183 days (training data set) was used for LSTM and ANFIS model training, whilst the remaining data for the last 61 days (test data set) was used for model validation. Actually, the data is divided into two training (75% of data) and test (25% of data) sections to train and validate the LSTM and ANFIS models. To predict the number of ICU and non-ICU patients, we designed two distinct LSTM and ANFIS models for the prediction of both ICU and non-ICU patients. After the model's parameterization, we tested the trained LSTM and ANFIS models by validation data sets to assess models' predictive power ( Figure 1 ). Actually, we used the following data set to train and test both LSTM and ANFIS models for the prediction of COVID-19 cases in both ICU and non-ICU units. . . . . . . . . . . . . We used the first two elements of ith, i ∈ [1:183] row of (1, 3) as inputs of LSTM and ANFIS models to predict the third element of that row. X non−ICU (t) and X ICU (t) represent the population of non-ICU and ICU COVID-19 patients in time point (day) t, respectively. Data set of (1, 3) was used to train both LSTM and ANFIS models. Trained models were evaluated by data set of (2, 4) to assess models' predictive power. The flowchart of LSTM and ANFIS models is provided in Figure 2 . LSTM and ANFIS models predict the population of new cases of COVID-19 by considering the population of COVID-19 cases of two days ago. In the following section, we will describe the details of implemented LSTM and ANFIS models, and the formulation of evaluation metrics of both models. LSTM architecture analyzes information in the form of input data and previous output values. The principle of LSTM is based on the long-term information reminder method through hidden layers named memory cells.The "adaptive moment estimation" optimization method was used to update weight and bias parameters in the LSTM structure. To train the LSTM model, we set the initial learning rate, learn rate schedule, learnratedropperiod,learnratedropfactor,andgradientthreshold as 0.005, piecewise, 125, 0.2, and 1, respectively. 12 Adaptive neuro-fuzzy inference system ANFIS integrates nonlinear neural networks and fuzzy logic systems into a unique framework with learning and prediction capability. Takagi-Sugeno-Kang as a popular fuzzy inference system (FIS) was introduced in early 1990s. ANFIS benefits from both neural networks and fuzzy systems to estimate nonlinear functions by considering uncertainty. It assigns a number of membership functions to each of the system inputs and, based on optimization algorithms, proposes optimal if-then rules. 13, 14 In this section, we describe the setting of the ANFIS model. The structure of the ANFIS model is illustrated in the left panel of Figure 3 . We considered three Gaussian membership functions for each of the two inputs and outputs of the ANFIS model. As shown in the left panel of Figure 3 , our model includes some fuzzy rules. "AND," "OR," "Implication," "Aggregation" and "Defuzzification" methods of our ANFIS model are "product," "sum," and "weighted average" methods, respectively. First and second columns of right panel show three Gaussian membership functions of input 1: X(t − 2) and input 2: X(t − 1). The X-axis of first and second columns of right panel describes the population of COVID-19 cases in the ICU unit at times t − 2, t − 1 and the Y-axis depicts the α-cut levels of fuzzy membership functions. As depicted in the left and right panels, in subtractive clustering algorithm only three membership functions are devoted to the inputs X(t − 2) and X(t − 1) to predict the population of COVID-19 new cases X(t) (the details are provided in Supplemental file). In this study, we generated a FIS using the fuzzy c-means (FCM) clustering method to extract a set of fuzzy rules which model the behavior and trend of COVID-19 cases in ICU and non-ICU sections. FCM rule extraction determines the number of fuzzy rules and estimates the parameters of membership functions for the antecedents and consequents of rules. We used mean square error (MSE), root-mean-square error (RMSE) and R 2 values as performance metrics for assessment of model's predictive powers. The formulation of MSE, RMSE and R 2 are given in equations (5) to (7): where X i is the recorded population of COVID-19 cases in ICU and non-ICU sections in the ith time point (day) and P i is the predicted population by the model in the same time point. We depicted the predicted population of COVID-19 patients in ICU and non-ICU sections to compare them with real data. Left and right panels of Figure 4 present the performance of the ANFIS model in training and test data sets, respectively. As provided in Table 2 , the values of RMSE in the test data set and R 2 in the overall data set of the ANFIS model for the prediction of COVID-19 hospitalized patients in ICU were 2.0627 and 0.97553, respectively, affirming the best performance of the metrics among all implemented models including support vector regression (SVR), tree regression, and LSTM model. Also, the values of RMSE in the test data set and R 2 in the test and overall data sets of the ANFIS model for the prediction of non-ICU patients clearly indicated that the ANFIS model was highly accurate and successful compared to other methods for the prediction of COVID-19 cases and hospital bed demand. In Figure 5 , the predicted population of COVID-19 patients in non-ICU (left panels) and ICU (right panels) sections by ANFIS (top panels) and LSTM (down panels) models are shown. In this figure, green lines show the mean of predicted dynamics of COVID-19 patients for 10 replications of models, while blue and red lines depict the average of lower and upper levels of 95% confidence interval. During the COVID-19 pandemic, most of the countries have experienced lack of health care resources including hospital beds which overwhelmed the health care systems. The issue has highlighted the necessity of applying an efficient supply management approach through the development of a demand prediction model for inpatient beds (of ICU, emergency, and regular medical wards) based on data obtained from the number of occupied beds in hospital wards due to the COVID-19 pandemic. 15 For this purpose, we applied time series prediction approaches to forecast future hospital bed occupancy based on past data with an ANFIS model, LSTM model, SVR model, and tree regression model. In a study conducted in Turkey, authors developed a forecasting medical equipment demand system based on different time series prediction approaches and regression models including autoregressive, SVR, tree, autoregressive moving average, linear regression, and LSTM model. 16 Their data analysis revealed that the LSTM model had the best predictive power. Also, in a study conducted in Bangladesh, the authors used ANFIS and LSTM models to predict the trend of new COVID-19 cases. They evaluated the ANFIS model under different settings of fuzzy membership functions and compared the predictive power of ANFIS and LSTM models. Their data analysis on Bangladesh's data set revealed that the performance of LSTM was better than ANFIS. 9 Similarly, Kumar et al. 17 proposed an LSTM network for forecasting the spread of COVID-19 through which policymakers and health authorities could make informed decisions with valid knowledge about the future cases of COVID-19. Focusing that deep learning models such as LSTM networks are suitable for modeling spatiotemporal sequences, Chandra et al. 18 applied the method to forecast the spread of COVID-infections among selected states in India resulting in good performance compared to epidemic models. Since the trend of the COVID-19 cases usually is oscillating, it is difficult to predict its trend using ordinary differential equation-based models such as susceptible-infected-recovered (SIR) modeling methods. Reliable prediction models such as LSTM and ANFIS can be used to support health care systems for their systematic resource management. 9, 19, 20 The ANFIS has some main advantages over other traditional approaches as it can maintain the power and accuracy of its estimates against uncertainty and environmental changes. In fact, through integrating neural networks and fuzzy logic, ANFIS has been widely used in forecasting systems. 13, [21] [22] [23] To our best knowledge, the ANFIS and LSTM models can be used by others with the purpose of doing similar predictions to provide needed information for forecasting health care utilization such as hospitalizations, the occupancy of ICU, and expected demand for hospital beds. [24] [25] [26] [27] [28] Applying the estimations in a periodic sequence makes it possible to effectively develop a surge capacity management plan and protect health systems from overwhelming health resources. 29 Most of the existing methods are poor in handling dynamic conditions and long-term dependencies. On the other hand, deep learning has a potential to create uninterrupted systems. 2, 9, 11, 19, 30 For this purpose, we built a dynamic memory neural network based on LSTM to collect and save experiences. Despite its applicability in addressing the challenges of complexities, and long-term dependencies the method has been used in a few numbers of researches conducted in the field of health care. [31] [32] [33] [34] [35] [36] For example, to predict the number of confirmed COVID-19 cases, and related deaths Parbat and Chakraborty 37 used the SVR model to predict the mentioned cases with an accuracy of 97%. Similarly, a number of researchers applied the machine learning method to forecast the COVID-19 confirmed cases, recovered cases and the number of deaths; most of which got an acceptable level of performance. [38] [39] [40] In our study, we expanded our study scope and forecasted the number of confirmed cases hospitalized in ICUs and non-ICUs through ANFIS and LSTM models. To our knowledge, this is the first study that had been carried out to predict the hospital bed demand based on LSTM and ANFIS models. Our findings showed that as our demand model considers a combination of factors including epidemiologic data, health system dynamics, and each hospital specification, it can be easily used in different health care settings. Furthermore, as the pattern of the SARS-CoV-2 virus spread in Iranian society is not uniform, the use of time series prediction methods instead of mathematical models such as SIR models can help predict the trend of new cases of the COVID-19. The validity of model was also confirmed through the real-world data records. We also used RMSE and R 2 values as performance metrics for the assessment of model's predictive power. In this study, we used the ANFIS model, LSTM network, SVR, and decision tree as rigorous time series prediction approaches and regression models to predict the trend of COVID-19 new cases in Qazvin province, Iran. LSTM is a deep model which can recognize sequential patterns. ANFIS combines the Fuzzy theorem and neural network which can be used as a time series predictive approach to forecasting the trend of new cases of COVID-19. 2, 9, 11, 19 In addition, our findings affirmed that the ANFIS model had better predictive power with fewer prediction errors compared to other models. Finally, we designed a user-friendly graphical user interface (GUI) to predict the trend of COVID-19 cases (for more detail see the Supplemental file). The GUI can be used by health care management systems for resource management. As shown in Figure 6 , the users can load their time series data in an application by clicking on the pushbutton "Load." Then, they can train ANFIS, LSTM, SVR, or tree models by selecting one of the defined models in the list box. Afterward, the training and prediction for one week ahead occur (100% of data for training). By clicking on the pushbutton "Train and predict," the trained model can predict the trend of COVID-19 cases for one week ahead. Finally, the predicted dynamics can be shown in the right panel of Figure 6 . As the demand for hospital beds (both in ICU and non-ICU wards) has increased dramatically since the beginning of the COVID-19 pandemic, predicting future demand for health care facilitates helps policymakers and health authorities plan and manage their resources more effectively. To do so, artificial intelligence models including ANFIS, deep learning approach based on LSTM network, regression models including SVR model and decision tree model play key role in forecasting the required number of beds or other types of medical facilities. To verify the validity of the system, a data set containing 240-day COVID-19 data was used: 180 days for training and 60 days for testing. The results yielded that the forecasted number of cases was approximately the same as actual values. We also designed a user-friendly graphical interface to analyze time series data and predict new COVID-19 cases. This GUI is configurable by any data set and can be used by health care systems for the optimal management of hospital resources. Acknowledgements: We sincerely appreciate the efforts of doctors, nurses and all healthcare workers trying to keep us safe in COVID-19 crisis. Data availability: All data are provided in the manuscript. Contributorship: SR designed the study, gathered data, drafted and revised the manuscript, and supervised the study. SS designed the study, implemented algorithms and designed models, analyzed the data, and drafted and revised the paper. Declaration of conflicting interests: The authors declared no potential conflicts of interest with respect to the research, authorship, and/or publication of this article. Supplemental material: Supplemental material for this article is available online. Severe acute respiratory syndrome coronavirus 2 (SARS-CoV-2) and corona virus disease-2019 (COVID-19): the epidemic and the challenges Patient-specific COVID-19 resource utilization prediction using fusion AI model Modeling and forecasting the COVID-19 pandemic in India Deep learning-based forecasting model for COVID-19 outbreak in Saudi Arabia A python based support vector regression model for prediction of COVID19 cases in India Forecasting models for coronavirus disease (COVID-19): a survey of the state-of-the-art Early prediction of unplanned 30-Day hospital readmission: model development and retrospective data analysis Weakly supervised deep learning for COVID-19 infection detection and classification from CT images Analysis and prediction of COVID-19 pandemic in Bangladesh by using ANFIS and LSTM network Day level forecasting for coronavirus disease (COVID-19) spread: analysis, modeling and recommendations COVID-19 growth prediction using multivariate long short term memory Long short-term memory ANFIS: adaptive-network-based fuzzy inference system Improved ANFIS model for forecasting wuhan city Air quality and analysis COVID-19 lockdown impacts on air quality Public Health England (PHE). Coronavirus (COVID-19) in the UK: Healthcare in England Forecasting of medical equipment demand and outbreak spreading based on deep long shortterm memory network: the COVID-19 pandemic in Turkey Forecasting the spread of COVID-19 using LSTM network Deep learning via LSTM models for COVID-19 infection forecasting in India Optimization method for forecasting confirmed cases of COVID-19 in China COVID-19 pandemic prediction for Hungary: a hybrid machine learning approach Oil consumption forecasting using optimized adaptive neuro-fuzzy inference system based on sine cosine algorithm Forecasting copper prices using hybrid adaptive neuro-fuzzy inference system and genetic algorithms A modified adaptive neuro-fuzzy inference system using multi-verse optimizer algorithm for Oil consumption forecasting Tracking and predicting COVID-19 epidemic in China mainland Prediction models for diagnosis and prognosis of COVID-19: systematic review and critical appraisal Machine learning to predict mortality and critical events in COVID-19 positive New York city patients: a cohort study Development and validation of a machine learning-based prediction model for near-term in-hospital mortality among patients with COVID-19 Using machine learning to predict ICU transfer in hospitalized COVID-19 patients The unexpected side effect of Covid-19: collaboration Fusion of medical imaging and electronic health records using deep learning: a systematic review and implementation guidelines Retain: an interpretable predictive model for healthcare using reverse time attention mechanism Recurrent neural networks for multivariate time series with missing values Learning to diagnose with LSTM recurrent neural networks A comparison of models for predicting early hospital readmissions Learning vector representation of medical objects via EMR-driven nonnegative restricted Boltzmann machines (eNRBM) Doctor AI: Predicting clinical events via recurrent neural networks A python based support vector regression model for prediction of COVID19 cases in India COVID-19 future forecasting using supervised machine learning models COVID-19 patient health prediction using boosted random forest algorithm COVID-19 outbreak prediction with machine learning