Development of machine learning models to predict RT-PCR results for severe acute respiratory syndrome coronavirus 2 (SARS-CoV-2) in patients with influenza-like symptoms using only basic clinical data

Background Reverse Transcription-Polymerase Chain Reaction (RT-PCR) for Severe Acute Respiratory Syndrome Coronavirus 2 (SARS-COV-2) diagnosis currently requires quite a long time span. A quicker and more efficient diagnostic tool in emergency departments could improve management during this global crisis. Our main goal was assessing the accuracy of artificial intelligence in predicting the results of RT-PCR for SARS-COV-2, using basic information at hand in all emergency departments. Methods This is a retrospective study carried out between February 22, 2020 and March 16, 2020 in one of the main hospitals in Milan, Italy. We screened for eligibility all patients admitted with influenza-like symptoms tested for SARS-COV-2. Patients under 12 years old and patients in whom the leukocyte formula was not performed in the ED were excluded. Input data through artificial intelligence were made up of a combination of clinical, radiological and routine laboratory data upon hospital admission. Different Machine Learning algorithms available on WEKA data mining software and on Semeion Research Centre depository were trained using both the Training and Testing and the K-fold cross-validation protocol. Results Among 199 patients subject to study (median [interquartile range] age 65 [46–78] years; 127 [63.8%] men), 124 [62.3%] resulted positive to SARS-COV-2. The best Machine Learning System reached an accuracy of 91.4% with 94.1% sensitivity and 88.7% specificity. Conclusion Our study suggests that properly trained artificial intelligence algorithms may be able to predict correct results in RT-PCR for SARS-COV-2, using basic clinical data. If confirmed, on a larger-scale study, this approach could have important clinical and organizational implications. Supplementary Information The online version contains supplementary material available at 10.1186/s13049-020-00808-8.


Background
At the end of 2019, an outbreak of pneumonia, of unknown origin at the time, turned out to have stemmed from Wuhan, Hubei, China and consequently spread throughout the world, reaching Italy in February 2020 [1][2][3].
A new betacoronavirus, subsequently named Severe Acute Respiratory Syndrome Coronavirus 2 (SARS-COV-2), was identified as the cause of the epidemic [4]. The infection with SARS-COV-2 has, in humans, a broad spectrum of clinical presentations [5] and was named Coronavirus Disease 2019 . Initial symptoms are nonspecific and similar to other seasonal viral diseases, which entail fever, dry cough and fatigue. This could lead to a fairly impossible clinical diagnosis. Therefore, etiological diagnosis relies on Reverse Transcription-Polymerase Chain Reaction (RT-PCR) to detect the genome of SARS-COV-2.
There are several important limitations to RT-PCR. First, current techniques take up to 6-8 h in order to obtain plausible results and often laboratories cannot handle the overload. Second, not all hospitals have the equipment and staff to run tests 24/7. Consequently, swabs are sent out to other facilities, thus slowing down the process and swamping central laboratories. Third, RT-PCR, on a retropharyngeal swab, may result falsely negative in the initial phase of the disease, in spite of the presence of typical symptoms [6][7][8]. Last of all, this technique carries a certain cost, which could mean a considerable financial burden weighing upon both health systems and patients.
A direct consequence of these limitations is the time spent by a large number of patients awaiting results in the emergency department before a decision can be taken as to where admit them to, e.g. in wards and intensive care units focused on COVID-19 patients, or in "non-infective" wards of the hospital [2,[9][10][11][12]. This is particularly troublesome for critically ill patients requiring immediate endotracheal intubation and mechanical ventilation. Specialized medical staff need to attend to these patients in emergency departments where, however, the health system is already under a lot of pressure.
Finding an easy and fast method of predicting positivity or negativity to SARS-COV-2, would prove to be of great clinical value. Algorithms have already been proposed using advanced imaging, e.g. chest computed tomography (CT) [13,14]. However, not all hospitals or countries can carry out a CT scan on every patient.
The main goal of our study was therefore to develop a machine learning model to predict the results of RT-PCR for SARS-COV-2 using only basic clinical, radiological and routine laboratory data at hand in all emergency departments.
We hypothesized that using Artificial Neural Networks (ANNs), and other Machine Learning Systems (MLS), would allow to obtain accurate results on RT-PCR testing for SARS-COV-2 and that these systems could possibly be applied in the future. The performance of different ANNs and MLS was analyzed so as to distinguish between patients resulting positive or negative to SARS-COV-2, thus identifying those variables which express the maximum amount of relevant information.

Study design and selection of participants
This retrospective, single centre study, was approved by the Institutional Review Board of our hospital (N°3733). The need for informed consent from individual patients was waived owing to the retrospective nature of the study. While not developed specifically for models using machine learning [15], the study followed the guidelines of the Transparent reporting of a multivariable prediction model for individual prognosis or diagnosis (TRI-POD) [16]." All patients admitted to the emergency department of our hospital between February 22, 2020 and March 16, 2020, were screened for eligibility. Symptoms of presentation compatible with COVID-19 (fever, sore throat, cough, dyspnoea, chest pain, headache, syncope, asthenia, arthralgia, diarrhoea, nausea and vomit) constituted the inclusion criteria. Age < 12 years and absence of evaluation of the leukocyte formula (defined as percentages of the five types of leukocytes: neutrophils, lymphocytes, eosinophils, basophils and monocytes) in the emergency department constituted exclusion criteria.

Data collection
Clinical data regarding the admission to the emergency department were retrieved from the Patient Data Management System of our hospital. Data included age, gender, presence and type of comorbidities, reported symptoms and medication currently being taken. Each drug was placed in a specific category.
In our hospital, there is no formal checklist to collect the medical and medication history. Therefore, if specified by the ER physicians, comorbidities and medication use were considered as present, otherwise if not specified, they were considered as absent. In addition, information regarding vital signs upon admission to the emergency department (first measurement), presence and type of ventilatory support, routinely performed blood tests, major electrocardiographic characteristics (presence of sinus rhythm and ST abnormalities) and chest X-rays (presence of any type of parenchymal involvement, presence of pleural effusion) were collected.
The results of the RT-PCR swab for SARS-COV-2 were recorded. Should the outcome have proved negative in a symptomatic patient, our hospital made it mandatory for a second swab to be carried out after 48 h and these swabs were checked to confirm negativity. The complete list of collected variables is summed up in Table 1.

Statistical analysis and sample size
All data were tested for consistency with variance and normality of distribution using the Shapiro-Wilk test. Normally distributed data were expressed as mean ± standard deviation, while non-normally distributed data were reported as median and interquartile range. Binary data were summed up in percentages, frequency of occurrence, and compared through Chi-Square test. Continuous variables were compared through Student T-Test or Wilcoxon Rank-Sum test, as appropriate.
Pearson's and Spearman's correlation was used to assess the correlation between collected variables (continuous and nominal, respectively) and RT-PCR for SARS-COV-2 results. A P-value lower than 0.05 was considered as statistically significant. Analysis was performed with SigmaPlot v.12.0 (Systat Software Inc., USA).
The study was carried out on a convenience sample of 200 patients admitted to the emergency department and tested for SARS-COV-2.

Training and testing validation protocol
The target variable to be predicted was the result of the RT-PCR for SARS-COV-2 performed in the emergency department. In order to predict and estimate the results of the RT-PCR for SARS-COV-2 using an input of 74 variables under study (Table 1), different Machine Learning algorithms available on WEKA data mining software [17][18][19] and on Semeion Research Centre depository (Massimo Buscema, Deep Supervised ANNs, Semeion SW #12, version 33.0, 1999-2019) were trained. These classification tools were first applied to predict RT-PCR results using the Training and Testing validation protocol, with the following steps: 1 Subdivision of the dataset into two sub-samples, A and B, each containing 50% of records and having an equal proportion of cases and controls (in our case SARS-COV-2 positive and SARS-COV-2 negative). The two sub-samples were obtained through the application of the TWIST algorithm, (i.e. they were not obtained by random extraction), in order to create two subsamples with similar probability density for all the input variables (see below). A homogeneity check was performed to confirm the substantial equivalence of the two subsets with regard to the distribution of variables. In the first run, A was used as Training Set and B as Testing Set. 2 Application of ANN on the Training Set. In this phase, the ANN learned to associate the input variables with those indicated as targets. 3 After the training phase, the weights matrix produced by the algorithm was saved and frozen together with all parameters used for the training. 4 The Testing Set was then shown to a virgin twin (same architecture and base parameters) ANN with the same weights matrix of the trained ANN, acting as final classifier. This operation took place for all records and the results (right or wrong classification) was not communicated to the classifier. This allowed to assess the generalization ability of trained ANN. 5 In a second run, another virgin ANN was applied to subset B which was used as training subset and then to subset A which was used as testing subset. 6 Therefore, the results are relevant to two sequences of training testing protocol: A-B and B-A.
Results were drawn up in terms of sensitivity (correct classification of positive patients), specificity (correct classification of negative patients), global accuracy (arithmetic mean between sensitivity and specificity). Overall results are expressed as average of the two experiments. This crossover procedure allows to classify blindly all records with the trained algorithm ensuring the generalization capability of the model on records never seen before.
However, since noisy input attributes can sometimes hide the small meaningful information embedded in other attributes, a pruning procedure was used as a preprocessing tool to eliminate noisy variables before the outcome prediction of the main test. In order to conduct this procedure, an input selection algorithm named

TWIST algorithm
As previously shown [40], the TWIST algorithm is a complex algorithm able to search for the best distribution of the global dataset divided in two optimally balanced subsets containing a minimum number of input features, useful for optimal pattern recognition. TWIST is an evolutionary algorithm based on a paper about Genetic Doping Systems [19], which has already been applied to medical data with very promising results [40][41][42][43][44]. A detailed description of the algorithm is available in the Online supplement.

5-K-fold
In addition to the Training and Testing validation protocol, a 5 K-fold cross-validation protocol was applied [45], in order to analyze data also with a standard and popular approach. The dataset was randomly split in 5 groups (folds) with a similar number of subjects. Each unique group was used as a hold out, or validation dataset, and the remaining groups were used as training datasets. The model fitted on the training set was evaluated on the validation set. Five different models for each employed machine learning system were created, and each model provided an evaluation score. The skill of the 5 models was summarized as mean sensitivity, specificity, overall accuracy and balanced accuracy.

Assessment of model calibration
Cost Curves [46] were applied to the studied algorithms in order to assess model calibration (Results presented in the Online Supplement).

Results
Three hundred forty-seven patients fulfilled the inclusion criteria, 148 patients presented exclusion criteria (9 patients < 12 years, 139 patients without leukocyte formula), leaving 199 patients for the analysis. Table 4 summarizes the main characteristics of the overall study population (n = 199) and of the two subgroups, i.e. patients who tested positive (n = 124) and negative (n = 75) to SARS-COV-2. There were no missing data regarding the recorded variables. A comparison between the characteristics of the study population (n = 199) and of patients excluded due to the absence of leukocyte formula (n = 139) can be found in the Online Data Supplement (Table S3). Median age in the overall population was 65  years, with similar distribution in the two subgroups (65  vs. 66  years p = .94, for positive and   Regarding current medications, positive patients had lower chronic use of anti-epileptics and drugs for psychiatric disorders, as compared to patients that tested negative (0.8% vs. 12.0%, p = .002 and 0.8% vs. 8.0%, p = .02, respectively). Furthermore, administration of antibiotics before access to the emergency department was higher in the positive subgroups (29.0% vs. 14.7%, p = .03). As for reported signs and symptoms, fever and coughing were more prevalent in patients with COVID-19 (96.0% vs. 73.3%, p < .001 and 73.4% vs. 52.0%, p = .004, respectively).

Population description and classic statistics
Several clinical findings turned out to be significantly different between the two population studies (Table 4). In particular, SARS-COV-2 positive patients had a slightly higher external body temperature (37.8 ± 0.8 vs. 37.2 ± 1.0, p = <.001), lower prevalence of pleural effusion at chest X-ray (5.7% vs. 17.3%, p = .01) and a significant difference regarding the complete blood count and leukocyte formula (Table 4). Table 5 summarizes the positive and negative linear correlation index between descriptive variables and the results of RT-PCR for SARS-COV-2.

Prediction of the RT-PCR outcome with machine learning algorithms
The TWIST system selected 42 variables of the original attributes. Selected variables are marked with and asterisk in Table 5. A global dataset of 42 input and 2 target attributes was thus generated. Thereafter, two optimal subsets were created, in order to apply the training and testing procedure described above. Table 6 shows the results obtained by the application of an array of machine learning systems to the variables selected by TWIST system. These results are the average of two training-testing procedures (A-B and B-A sequences). Detailed predictive results for each experiment (A-B and B-A) is available in Table S1 in the Online Supplement.
The best machine learning system reached ad accuracy of 91.4% with 94.1% sensitivity (correct prediction of positivity to SARS-COV-2) and 88.7% specificity (correct prediction of negativity to SARS-COV-2). Table 7 shows the results obtained through applying a selected number of machine learning systems to the variables selected by the TWIST system. These results are the average of five Training-Testing procedures of a K-fold cross-validation protocol. Detailed predictive results for each experiment are available in Table S2 in the Online Supplement.

Discussion
In our exploratory, model development study, we analyzed data of 199 adult patients admitted to the emergency department of the largest hospital in Milan, Lombardy, with symptoms compatible with COVID-19 during the first 3 weeks of SARS-COV-2 outbreak in Italy. In the present manuscript, we describe this population and highlight the differences between patients who actually tested positive to SARS-COV-2 and those who did not. Few attempts in applying artificial intelligence to rapidly predict positivity/negativity to SARS-COV-2 were made since the outbreak, using mostly CT imaging and lab results, collected in Chinese population [35,47,48]. Nevertheless, we present the first European attempt and promising results applying artificial intelligence to predict the results of RT-PCR for SARS-COV-2, using only basic clinical data, available in the vast majority of emergency departments all over the world. The wide application of a similar decision support tool could have a major clinical and organizational impact during the current pandemic.
In our study, several differences were observed between the two study groups (Table 4). However, none of these, or a combination of them, allows, so far, to clearly differentiate between patients with COVID-19 and patients with other diseases, having a similar clinical presentation. Our data underline the key finding of Coronavirusinduced alterations in the white blood cell differential count (Table 4). On the one hand, in contrast to other reports [49][50][51][52] we did not observe a marked lymphocytopenia, possibly because of the early stage of the viral disease. On the other, other subtypes such as eosinophils might play a key role in COVID-19 [53].
When applying artificial intelligence to our dataset, in particular ANNs and MLS, we were able to predict with high sensitivity and specificity the results of RT-PCR for SARS-COV-2 (Table 6).
Artificial Neural Networks allow forecasting through understanding of the relationship between variables, in particular through the application of nonlinear relationships [40,54,55]. These systems initially learn from a set of data with a known solution (training). Thereafter, the networks, inspired by the analytical processes of the human brain, are able to reconstruct imprecise rules, which may be underlying a complex dataset (testing). Machine learning systems and, in particular, ANNs analyse realworld data very efficiently. The internal validity of their assessment is provided by uniquely strict validation protocols, seldom used in classical statistics [54,56,57].
In the present manuscript, it was possible to predict with reasonable accuracy the status of being positive or negative to SARS-COV-2 based on 42 simple variables. This was achieved using the TWIST algorithm, which does not have, at the moment, the same popularity of other techniques, such as K Fold, Boosting and others. Nevertheless, it has been used extensively in the past 15 years in different contexts [18,58,59]. The reason of its low diffusion is partly that TWIST is very complex to program, as it includes two evolutionary algorithms that work together managing a huge population of ANNs, kNN and Naive Bayes algorithms. The execution of TWIST needs therefore to be programmed in C language to be sufficiently fast. Thus, for its complexity and for needed running time, TWIST is not suitable for programming in Phyton, R or similar languages.  TWIST system allowed reaching a global accuracy of 91.4% with the best machine learning system: 94.1% sensitivity (correct prediction of positivity to SARS-COV-2) and 88.7% specificity (correct prediction of negativity to SARS-COV-2). Considering the eight best machinelearning systems their average performance was the following: sensitivity of 91.8%, specificity of 89.6% and global accuracy of 90.8%.
Comparing the two testing procedures (A-B and B-A), explained in the mathematical section, the differences in predicting values between these two experiment is small, therefore reasonably excluding overfitting of the model [16]. Furthermore, also the Cost Curves performed to assess mode calibration have shown acceptable results (Figs. S2-S5 of the Online Supplement).
In order to analyze our dataset also with a more popular and widely applied procedure, we applied a 5 k-fold cross-validation protocol, using a selected number of machine learning systems (Table 7). With this type of analysis, the best machine learning system obtained an overall accuracy of 87.7% with a sensibility and specificity of 89.2 and 86.2%, respectively. Global average performance was the following: sensitivity of 87.6%, specificity of 75.4% and a global accuracy of 81.5%.
Comparing these results with those obtained by the same machine learning systems, using the AB -BA Table 6 Predictive results with variables selection using Semeion ( a ) and WEKA ( b ) Machine learning systems  Train-Testing protocol (shown in Table 6), the latter allows to obtain slightly better predictive results, reasonably related to the optimal splitting of the records, with an average performance of 89.1% sensibility, 82.2% specificity and 85.7% global accuracy. The high variance of results obtained with the K-Fold protocol and the low variance of the same results using TWIST protocol is suggestive of the high polarization affecting the K-Fold protocol with this kind of data. This is the reason why we have chosen to rely on an optimized distribution of records in training and testing subsets, rather than on a random allocation. Nevertheless, also the application of a standard K-fold cross-validation, i.e. a system widely available, was able to predict accurately the results of RT-PCR for SARS-COV-2.
It is useful to analyse variables selected by AI, as they certainly bear specific clinical information. As mentioned above, the white blood cells and their differential count are certainly very informative.
Indeed, total white blood cell count (R = − 0.46), lymphocytes (R = 0.26) and eosinophils (R = − 0.34) correlated either negatively or positively with the presence of COVID-19 and were included in the model.
In addition, the final model included also variables with very low correlation with RT-PCR results, such as dyspnea (R = − 0.07), basophils (R = -0.06), mean cell haemoglobin (R = − 0.06), non-invasive ventilation (R = − 0.05), monocytes (R = 0.05), age (R = 0.04), female sex (R = 0.02) and headache (R = 0.02). The fact that these variables have been included in the model confirms the ability of ANN to handle highly nonlinear functions.
Other authors have applied AI for the diagnosis of SARS-COV-2. Rao et al. employed an AI framework to a mobile phone-based survey, exclusively based on prehospital clinical symptoms and demographic characteristics to assess the probability of SARS-COV-2 infection [60]. Three different research groups tried to predict positivity to SARS-COV-2 using, among other variables, CT scans [14,47,61]. Chest CT scan was analysed via deep learning by Li et al. to differentiate SARS-COV-2 induced viral pneumonia from other lung diseases [62]. Two other research groups developed machine learning models and online applications, using only lab test results [35,48].
Our model significantly differs from the abovementioned. First, it relies on basic clinical information, available in almost every emergency department. The required information is quickly obtainable for every patient at hospital admission. For this reason, we decided to include chest X-Ray rather than CT in our model. Indeed, despite CT being certainly more sensitive in identifying alterations typical of viral pneumonia [13], not every SARS-COV-2 suspect will have access to a CT scan. Second, our study is the first one analysing data from a European country. While there is no evidence so far, it is possible that different ethnicities will show slightly different responses to viral invasion.

Limitations
This exploratory study has certainly several limitations. First, it is a retrospective, single-center study. Second, the study was conducted on a convenience sample of 200 patients. This aspect has two important implications: i) in this exploratory model development study no formal a priori sample size determination was performed and ii) the small sample size and the high number of input variables bear an intrinsic risk of over-fitting [37]. An additional limitation is the high exclusion rate (40%), potentially leading to a selection bias. However, the main reason for patients' exclusion was the lack of data regarding the leukocyte formula. This exam was not part of the standard biochemical panel in our emergency department at the beginning of the pandemic. The clinical implications of this laboratory exam became quickly evident and the test was therefore frequently added to the biochemical panel later on in the pandemic. In light of this explanation and of the comparison between included and excluded patients (Table S3) we think that it is safe to exclude the presence of a selection bias. Furthermore, for organizational issues we were not able to perform an external validation, which certainly would have strengthened our results. In addition, some fundamental clinical data, such as arterial blood gas analysis were not available for all patients and this information was thus not included in the model. Given the typical profound hypoxemia of patients with COVID-19, it is conceivable that adding these variables to the system could further improve its accuracy. Finally, while no definitive data are available regarding the accuracy of RT-PCR testing for SARS-COV-2 [63], several studies have described a certain percentage of false negative results [6][7][8]. However, every negative result was re-tested after 48 h. This methodological aspect should reduce the risk of falsely negative results.

Possible clinical and organizational implications
Facing a highly contagious viral outbreak requires a complex effort in terms of political, economic, social and health systems re-organization [64,65]. A fundamental aspect is to define a clear management protocol, in order to separate infected from non-infected patients, i.e., those admitted for other clinical conditions. Indeed, it is of paramount importance to set up clearly separate pathways, in order to avoid the spread of viral infections within the hospital. A quick and reliable system to identify SARS-COV-2 infected patients is therefore fundamental. Currently, the gold standard for the diagnosis is a RT-PCR assay searching for SARS-COV-2 genome [9]. This type of molecular assay has certainly several limitations. During the first month of outbreak in Italy, the processing of samples became more efficient, theoretically reducing the technical time needed for the result. Despite this, the problem of delayed diagnosis still exists. This is due to the availability RT-PCR machines, considering the high demand during the outbreak. Furthermore, laboratories of referral hospitals, such as ours, analyse samples also arriving from smaller hospitals not equipped for SARS-COV-2 testing. Finally, of course, RT-PCR is not a perfect test, and false negative result have been described, even in the presence of strong clinical suspicion for COVID-19 [6][7][8].
For these reasons, applying AI as a rapid decision support tool for the diagnosis of COVID-19 and therefore to speed up the sorting of infected from non-infected patients would be of great clinical help. Indeed, a simple online software, fed with basic clinical data, easily obtainable in almost every emergency department, could apply trained ANNs to predict with high accuracy the RT-PCR result. The results obtained from this software should of course be integrated with available clinical data.
The application of AI to clinical practice is still limited for its complexity and for limited in-hospital availability of technical infrastructures and support. This, of course, could be particular troublesome for small centres with limited resources. The decision support software that could integrate the information contained in the present manuscript could ideally retrieve data directly from the electronic patient management system. Otherwise, data could be manually entered in an online software, which however significantly increases the risk of errors. An active support from and collaboration with the local information technology infrastructure is therefore fundamental in order to be able, in the future, to integrate AI into clinical practice.
Finally, it is conceivable that the information obtained from the present study might be useful also at the end of the current pandemic. Indeed, it is likely that SARS-COV-2 might become a seasonal virus. In this regard, the early identification would be a key factor to reduce the risk of a further epidemic outbreak.

Conclusions
In summary, our exploratory study suggests that basic clinical data might be sufficient for properly trained ANNs and MLS algorithms to predict with good accuracy the positivity and negativity to SARS-COV-2. If confirmed in larger multicentre studies, this could have important clinical and organizational implications. Indeed, while not directly changing the treatment of COVID-19 patients, it could reduce the time patients spend unnecessarily in the emergency department awaiting the results of RT-PCR, could reduce the workload of intensive care staff and, finally, reduce the risk of collapsing healthcare systems.