Abstract
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 R2 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.
Keywords
Introduction
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.
Materials and methods
Data
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.
Four-day data set of COVID-19 cases used to train and test LSTM and ANFIS models.
COVID-19: coronavirus disease 2019; LSTM: long short-term memory; ANFIS: adaptive neuro-fuzzy inference system; ICU: intensive care unit.
After the model’s parameterization, we tested the trained LSTM and ANFIS models by validation data sets to assess models’ predictive power (Figure 1).

The operation process of LSTM and ANFIS models for the prediction of hospital bed demand.
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.

Flowchart of the LSTM and ANFIS models.
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 network
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, learn rate drop period, learn rate drop factor, and gradient threshold 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.

(Left) structure of adaptive neuro-fuzzy inference system (ANFIS) model, (right) fuzzy rule sets of 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:
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.
Model assessment metrics
We used mean square error (MSE), root-mean-square error (RMSE) and
Results
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.

ANFIS model assessment in ICU.
As shown in Figure 4, the values of MSE (and RMSE) of the ANFIS model for the prediction of COVID-19 patients in ICU in train and test data sets are 2.87 (1.69), and 4.25 (2.06), respectively. The error of model predictions in the test data set is bigger than the training data set. In both left-top and right-top panels, black and red lines represent the recorded population of COVID-19 patients in ICU and predicted population by the ANFIS model. The black line (Target) depicts the daily COVID-19 cases in ICU and the red lines (Output) depict ANFIS model prediction. MSE, RMSE, mean and standard deviation of the error, and histogram of fitting errors are depicted in down panels.
The performance of the ANFIS model for the prediction of COVID-19 patients in the non-ICU section is shown in Supplemental Figure S1. The panels of this figure are similar to Figure 4. Results confirm that the values of MSE (and RMSE) for the prediction of COVID-19 patients in the non-ICU section in the training and test data sets are 18.81 (4.33), and 29.23 (5.40), respectively.
As shown in Supplemental Figure S2, the values of
As shown in Supplemental Figures S3 to S5, the LSTM model had lower predictive power and all prediction errors of the LSTM model were bigger than the ANFIS model. Description of Supplemental Figures S3 to S5 is similar to Figure 4 and Supplemental Figures S1 and S2. Finally, we used the trained LSTM and ANFIS models to predict the population of COVID-19 patients in ICU and non-ICU sections.
As provided in Table 2, the values of RMSE in the test data set and R2 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 R2 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.
Assessment metrics of different regression models.
ANFIS: adaptive neuro-fuzzy inference system; LSTM: long short-term memory; ICU: intensive care unit; RMSE: root-mean-square error.
The italic bold values represent the best results among all models.
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.

Predicted population of COVID-19 patients in non-ICU (left panels) and ICU (right panels) by ANFIS (top panels) and LSTM (down panels) models.
Discussion
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 spatio-temporal 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–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–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–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–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 R2 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.

Graphical user interface for the prediction of new coronavirus disease 2019 (COVID-19) cases.
Conclusion
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.
Supplemental Material
sj-doc-1-dhj-10.1177_20552076221085057 - Supplemental material for A COVID-19 forecasting system for hospital needs using ANFIS and LSTM models: A graphical user interface unit
Supplemental material, sj-doc-1-dhj-10.1177_20552076221085057 for A COVID-19 forecasting system for hospital needs using ANFIS and LSTM models: A graphical user interface unit by Sajad Shafiekhani, Peyman Namdar and Sima Rafiei in Digital Health
Supplemental Material
sj-doc-2-dhj-10.1177_20552076221085057 - Supplemental material for A COVID-19 forecasting system for hospital needs using ANFIS and LSTM models: A graphical user interface unit
Supplemental material, sj-doc-2-dhj-10.1177_20552076221085057 for A COVID-19 forecasting system for hospital needs using ANFIS and LSTM models: A graphical user interface unit by Sajad Shafiekhani, Peyman Namdar and Sima Rafiei in Digital Health
Supplemental Material
sj-doc-3-dhj-10.1177_20552076221085057 - Supplemental material for A COVID-19 forecasting system for hospital needs using ANFIS and LSTM models: A graphical user interface unit
Supplemental material, sj-doc-3-dhj-10.1177_20552076221085057 for A COVID-19 forecasting system for hospital needs using ANFIS and LSTM models: A graphical user interface unit by Sajad Shafiekhani, Peyman Namdar and Sima Rafiei in Digital Health
Supplemental Material
sj-doc-4-dhj-10.1177_20552076221085057 - Supplemental material for A COVID-19 forecasting system for hospital needs using ANFIS and LSTM models: A graphical user interface unit
Supplemental material, sj-doc-4-dhj-10.1177_20552076221085057 for A COVID-19 forecasting system for hospital needs using ANFIS and LSTM models: A graphical user interface unit by Sajad Shafiekhani, Peyman Namdar and Sima Rafiei in Digital Health
Supplemental Material
sj-doc-5-dhj-10.1177_20552076221085057 - Supplemental material for A COVID-19 forecasting system for hospital needs using ANFIS and LSTM models: A graphical user interface unit
Supplemental material, sj-doc-5-dhj-10.1177_20552076221085057 for A COVID-19 forecasting system for hospital needs using ANFIS and LSTM models: A graphical user interface unit by Sajad Shafiekhani, Peyman Namdar and Sima Rafiei in Digital Health
Supplemental Material
sj-docx-6-dhj-10.1177_20552076221085057 - Supplemental material for A COVID-19 forecasting system for hospital needs using ANFIS and LSTM models: A graphical user interface unit
Supplemental material, sj-docx-6-dhj-10.1177_20552076221085057 for A COVID-19 forecasting system for hospital needs using ANFIS and LSTM models: A graphical user interface unit by Sajad Shafiekhani, Peyman Namdar and Sima Rafiei in Digital Health
Supplemental Material
sj-m-8-dhj-10.1177_20552076221085057 - Supplemental material for A COVID-19 forecasting system for hospital needs using ANFIS and LSTM models: A graphical user interface unit
Supplemental material, sj-m-8-dhj-10.1177_20552076221085057 for A COVID-19 forecasting system for hospital needs using ANFIS and LSTM models: A graphical user interface unit by Sajad Shafiekhani, Peyman Namdar and Sima Rafiei in Digital Health
Supplemental Material
sj-m-9-dhj-10.1177_20552076221085057 - Supplemental material for A COVID-19 forecasting system for hospital needs using ANFIS and LSTM models: A graphical user interface unit
Supplemental material, sj-m-9-dhj-10.1177_20552076221085057 for A COVID-19 forecasting system for hospital needs using ANFIS and LSTM models: A graphical user interface unit by Sajad Shafiekhani, Peyman Namdar and Sima Rafiei in Digital Health
Supplemental Material
sj-m-10-dhj-10.1177_20552076221085057 - Supplemental material for A COVID-19 forecasting system for hospital needs using ANFIS and LSTM models: A graphical user interface unit
Supplemental material, sj-m-10-dhj-10.1177_20552076221085057 for A COVID-19 forecasting system for hospital needs using ANFIS and LSTM models: A graphical user interface unit by Sajad Shafiekhani, Peyman Namdar and Sima Rafiei in Digital Health
Supplemental Material
sj-m-11-dhj-10.1177_20552076221085057 - Supplemental material for A COVID-19 forecasting system for hospital needs using ANFIS and LSTM models: A graphical user interface unit
Supplemental material, sj-m-11-dhj-10.1177_20552076221085057 for A COVID-19 forecasting system for hospital needs using ANFIS and LSTM models: A graphical user interface unit by Sajad Shafiekhani, Peyman Namdar and Sima Rafiei in Digital Health
Supplemental Material
sj-m-12-dhj-10.1177_20552076221085057 - Supplemental material for A COVID-19 forecasting system for hospital needs using ANFIS and LSTM models: A graphical user interface unit
Supplemental material, sj-m-12-dhj-10.1177_20552076221085057 for A COVID-19 forecasting system for hospital needs using ANFIS and LSTM models: A graphical user interface unit by Sajad Shafiekhani, Peyman Namdar and Sima Rafiei in Digital Health
Supplemental Material
sj-m-13-dhj-10.1177_20552076221085057 - Supplemental material for A COVID-19 forecasting system for hospital needs using ANFIS and LSTM models: A graphical user interface unit
Supplemental material, sj-m-13-dhj-10.1177_20552076221085057 for A COVID-19 forecasting system for hospital needs using ANFIS and LSTM models: A graphical user interface unit by Sajad Shafiekhani, Peyman Namdar and Sima Rafiei in Digital Health
Supplemental Material
sj-xlsx-14-dhj-10.1177_20552076221085057 - Supplemental material for A COVID-19 forecasting system for hospital needs using ANFIS and LSTM models: A graphical user interface unit
Supplemental material, sj-xlsx-14-dhj-10.1177_20552076221085057 for A COVID-19 forecasting system for hospital needs using ANFIS and LSTM models: A graphical user interface unit by Sajad Shafiekhani, Peyman Namdar and Sima Rafiei in Digital Health
Footnotes
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.
Code availability (software application or custom code)
The MATLAB codes of model simulations are available.
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.
Funding
The authors received no financial support for the research, authorship, and/or publication of this article.
Guarantor
SS.
Ethical approval
This study was approved by the institutional review board of Qazvin University of Medical Sciences. The ethical code was IR.QUMS.REC.1399.213.
Informed Consent
Not applicable, because this article does not contain any studies with human or animal subjects.
Trial Registration
Not applicable, because this article does not contain any clinical trials.
Supplemental material
Supplemental material for this article is available online.
References
Supplementary Material
Please find the following supplemental material available below.
For Open Access articles published under a Creative Commons License, all supplemental material carries the same license as the article it is associated with.
For non-Open Access articles published, all supplemental material carries a non-exclusive license, and permission requests for re-use of supplemental material or any part of supplemental material shall be sent directly to the copyright owner as specified in the copyright notice associated with the article.
