Introduction

The consequences of a long stay and demand for hospital resources due to COVID-19 have been disastrous for health systems in middle and low-income countries (LMICs)1,2, requiring immediate clinical decisions, especially when dealing with limited resources3,4. An accurate COVID-19 prognosis assessment is crucial for screening and treatment procedures and may increase patient survival5,6. In Brazil7, many cities are at their saturation capacity for the provision of clinical care, especially regarding ICU beds and mechanical ventilators8,9,10,11,12,13,14,15,16,17,18,19,20. Data-driven solutions are needed to support decision-making11.

COVID-19 has shown to rapidly worsen a few days after infection12,13. The median time from disease onset to ICU admission is 9–12 days14,15. About 26–32% of the hospitalized patients are eventually admitted to ICU, and mortality in this group ranges from 39 to 72%, depending on the local characteristics of patients14,15. The median length of ICU stay and use of mechanical ventilation is approximately 9 days (95% CI 6.5–11.2) and 8.4 days (95% CI 1.6–13.7), respectively16.

Previous studies have used blood tests17, CT images18,19, sociodemographic and comorbidities history20 to develop COVID-19 diagnostic and prognostic models, including machine learning techniques21,22,23. Biomarkers from blood tests have emerged as important variables for poor prognostic factors24, which are a promising tool in poorer regions, due to its low cost and inclusion in standard protocols for clinical care. However, the majority of studies25 rely on algorithms trained on a single prognostic outcome, which in theory require the training of specific algorithms for each distinct negative outcome.

This study proposes to develop multipurpose machine learning algorithms to analyze if it is possible to predict overall poor prognosis for COVID-19 patients. We aim to test if the algorithms can generalize risk patterns for severe conditions, so they can be used as tools to assist in the prognosis of distinct negative outcomes for COVID-19 patients.

Results

Descriptive statistics

Table 1 shows the descriptive statistics for the demographic characteristics of the patients. The sample of the study (1040 patients with COVID-19) was mostly comprised by men (53.3%), with an average age of 51.7 years, and the majority of patients (63.8%) were white. The full descriptive statistics for all variables are presented in Supplementary Table 1.

Table 1 Descriptive statistics of the demographics characteristics of the sample, BP Hospital—A Beneficência Portuguesa de São Paulo, Brazil, 2020.

Algorithms performance

We analyzed the predictive performance of the algorithms for three negative prognostic outcomes: ICU admission (n = 263, 25.5%), mechanical ventilation (MV) intubation (n = 106, 10.2%) and death (n = 92, 9.4%).

First, we tested the predictive performance of the machine learning algorithms for a specific individual outcome (e.g. death) to get a baseline for comparison. Then, we used observations from patients who had the other two outcomes (in this specific example, mechanical ventilation and ICU admission) to train an aggregated model. In the aggregated model, we tested the performance when predicting the severe outcome not included in training (e.g. death). Finally, we compared the performance of the two strategies (e.g. individual against aggregated models) using the 95% confidence interval of the area under the receiver operating characteristic curve (AUROC).

Table 2 shows the results of the models trained with the aggregated outcomes and the models with a single outcome. Every model, even the ones trained with different outcomes, presented high predictive performance, always with an AUROC over 0.91 in the test set. The individual models presented better AUC compared to the aggregated models when predicting ICU, MV or death with AUROC over 0.959, 0.945 and 0.972 respectively.

Table 2 Predictive performance comparison in the test set for aggregated and individual models, BP Hospital—A Beneficência Portuguesa de São Paulo, Brazil, 2020.

Despite the individual models being overall better, the difference between the aggregated and individual models were all within the 95% confidence intervals. Supplementary Fig. 1 shows the AUROC for each model. The sensitivity and specificity of the machine learning algorithms were also very high, in most cases over 0.8, with an average sensitivity of 0.92 and specificity of 0.82.

The positive predictive values (PPV) for the aggregated models were higher than the individual models when predicting mechanical ventilation and ICU, reaching 0.398 and 0.729 respectively, while for death there was a decrease to 0.290. This means that two out of three of the aggregated models had higher PPV when predicting which patients would develop severe illness and require hospital resources than the individual models. In Supplementary Table 2 we present the final hyperparameters for each model.

Interpretability

Figure 1 presents the prediction density for each individual outcome according to the different training strategies. The results point to a low overlap between negative and positive cases, indicating a good discriminative ability of the algorithms irrespective of the training strategy.

Figure 1
figure 1

Density plots for the three severe COVID-19 outcomes, BP Hospital—A Beneficência Portuguesa de São Paulo, Brazil, 2020. (ac) Density plots for the single outcome models. (df) Density plots for the aggregated models predicting unspecific outcome.

Figure 2 presents the top five variables that most contributed to predict a severe outcome in the aggregated models, according to the Shapley values. The variables are ranked according to the contribution for each specific algorithm. The Braden score played an important role in the aggregated outcome algorithms, ranking as the most important predictor in two of the three models. Also, the C-reactive protein and ratio of lymphocytes per C-reactive protein were found to be good predictors, appearing in the top five in all three models. Urea, age, creatinine, and arterial lactate were important for only one of the aggregated models.

Figure 2
figure 2

Top five feature contributions to predict severe outcome in the aggregated models, BP Hospital—A Beneficência Portuguesa de São Paulo, Brazil, 2020. (a) Combined outcomes (MV + ICU) to predict death (b) Combined outcomes (Death + ICU) to predict MV. (c) Combined outcomes (Death + MV) to predict ICU.

Discussion

Previous studies have used machine learning to develop early COVID-19 prognostic models for a specific severe outcome with overall good performance21,23, frequently reaching over 0.90 AUROC26. We used a different approach, by combining severe outcomes to train algorithms to predict another outcome, in order to test its potential for predicting multiple untrained outcomes.

We found that machine learning algorithms were able to predict negative prognostic outcomes with high overall performance for COVID-19, even when the specific outcome was not included in the training of the algorithms. All models presented an AUROC higher than 0.91 (average of 0.92) in the test set, with high sensitivity and specificity (average of 0.92 and 0.82, respectively). The results highlight the possibility that high-performance machine learning algorithms are able to predict unspecific negative COVID-19 outcomes using routinely-collected data.

The development of multipurpose prognostic algorithms, i.e. algorithms that identify nonspecific outcomes and overall future clinical deterioration, can be used in a large number of situations, especially in the case of complex and unknown diseases that lead to the development of several different negative outcomes. Instead of having to develop a different algorithm for each of the specific outcomes, multipurpose models can provide more comprehensive and clinically relevant information about the risks of future health problems of patients. The algorithms can be embedded in an app for smartphones or in electronic medical records to be used with routinely-collected data to perform simple predictions for each incoming patient, thus supporting screening procedures and decision-making. In the case of developing countries, while the issue of current availability of electronic medical records in poorer areas is still a challenge, in Brazil there have been promising recent advances regarding the use of electronic medical records27.

Brazil is currently the third country in the world in total number of cases and second in deaths from COVID-1928. There is a growing demand in Brazil, and in many other developing countries, for decision support in the allocation of scarce hospital resources, especially in relation to the availability of ICU beds and mechanical ventilators29,30. From a clinical standard, knowledge about immediate risks of negative prognosis can also contribute to the early start of preventive measures and new interventions, and thereby increase patient survival5,6.

For every outcome, variable importance analysis identified that age, C-reactive protein (CRP), creatinine, urea and the Braden Scale were usually among the most important. While the age of the patient is widely found to be an important predictor for most negative health outcomes, CRP has been increasingly included among the main inflammatory biomarkers for the prognosis of cardiovascular31 and respiratory diseases32. High levels of CRP have been also previously associated with individual severity of SARS-CoV-233,34. Interestingly, previous studies have also identified that chronic kidney disease is associated with developing severe conditions in COVID-19 patients35,36,37, where it has been observed that patients with higher levels of creatinine and urea are more at risk38. The Braden Scale is often used as a predictor for pressure ulcers, a common clinical classification scale for predicting pneumonia39 during clinical reception, and in this study, it was an important predictor for negative prognosis in COVID-19 patients. The scale has a score between 1 (worst score) and 4 (best score) where the factors included are sensory perception, skin moisture, activity, mobility, nutritional status and friction40. The percentage of lymphocytes in the blood has been described as a strong predictor of prognosis for the severity of the new coronavirus. A randomized study by Tan et al.41 suggested that, in most confirmed cases, the percentage of lymphocytes was reduced to 5% in 2 weeks after the onset of COVID-19, in line with other studies findings42.

The study has a few limitations that need to be mentioned. First, some of the outcomes overlap, which may have helped the performance of the aggregated models, even though in the majority of cases the outcomes were independent. In the case of ICU admission, 55% of the patients did not die or used MV, while in the case of MV and death, 63% and 70% of their respective aggregated model was trained on other outcomes. Ideally, the outcomes would never overlap, but this is clinically unfeasible given the interlaced nature of negative prognostic outcomes. Another limitation is that we analyzed data from an urban COVID-19 hotspot in Brazil, in a period where clinical protocols for the disease were still being established, so this could affect the incidence of prognostic outcomes and may not directly generalize to other periods.

In conclusion, we found that machine learning algorithms can predict severe outcomes in COVID-19 patients with high performance, including previously unobserved outcomes, using only routinely-collected laboratory, clinical and demographic data. The use of multipurpose algorithms for the prediction of overall negative prognosis is a promising new area that can support doctors with clinical and administrative decisions, especially regarding priorities for hospital admission and monitoring.

Methods

Data source

We followed a cohort of 3280 patients with a RT-PCR diagnostic exam for COVID-19 from a large hospital chain in the city of São Paulo (BP-A Beneficência Portuguesa de São Paulo) between March 1, 2020, and 28 June, 2020. Of these, 1040 (31.7%) patients were positive for COVID-19 and were included in the analysis. The study was approved by the Institutional Review Board (IRB) of BP—A Beneficência Portuguesa de São Paulo (CAAE:31177220.4.3001.5421), including a waiver of informed consent. The study followed the guidelines of the transparent reporting of a multivariable prediction model for individual prognosis or diagnosis (TRIPOD)43.

Individual patient data was collected from electronic medical records. We included as predictors only variables collected in early hospital admission, i.e. within 24 h before and 24 h after the RT-PCR exam. From a total of 82 routinely-collected variables from the hospital, 57 variables were selected for the development of the predictive models, after removing variables with 90% or higher missing values, highly-correlated variables (above 0.9) and identifying variables such as patient number and hospital identification variables. The flowchart for feature selection is described in Supplementary Fig. 2 and the complete variable list, including demographic data, laboratory tests and vital signs is described in Supplementary Table 1. Figure 3 illustrates the overall process.

Figure 3
figure 3

Overview of the study process. (a) From hospital admission to the final outcome. (b) Population inclusion criteria and outcomes intersection. (c) The algorithm was trained and tested using a combination of two outcomes. The same algorithm was then used to predict the remaining outcome.

Machine learning techniques

Five of the most popular machine learning models for structured data (artificial neural networks44, extra trees45, random forests46, catboost47, and extreme gradient boosting48) were trained with 70% of the data, and tested in the other 30%, simulating new unknown data. All the results reported in this study are from the test set. K-fold cross-validation with 10 folds was used to adjust the hyperparameters with Bayesian optimization (HyperOpt). Due to the unbalanced nature of the outcomes, random undersampling was performed in the training set, by randomly selecting examples from the majority class for exclusion. This technique was implemented using the RandomUnderSampler imbalanced-learn class49.

Variables with more than two categories were represented by a set of dummy variables, with one variable for each category. Continuous variables were standardized using the z-score. Variables with a correlation greater than 0.90 (mean arterial pressure, total bilirubin, and creatine kinase) were discarded, and missing values were imputed by the median. To assess the performance of the models, measures such as accuracy, sensitivity (also known as recall), specificity, positive predictive value (PPV) (also known as precision), negative predictive value (NPV), and F1 score were analyzed. The value of the AUROC was used to select the best model. To understand the individual contribution of each variable to the predictive models, we calculated their respective Shapley values. All the analyzes were performed using the Python programming language with the scikit-learn library.