Classifying the evolution of COVID-19 severity on patients with combined
  dynamic Bayesian networks and neural networks
When we face patients arriving to a hospital suffering from the effects of
some illness, one of the main problems we can encounter is evaluating whether
or not said patients are going to require intensive care in the near future.
This intensive care requires allotting valuable and scarce resources, and
knowing beforehand the severity of a patients illness can improve both its
treatment and the organization of resources. We illustrate this issue in a
dataset consistent of Spanish COVID-19 patients from the sixth epidemic wave
where we label patients as critical when they either had to enter the intensive
care unit or passed away. We then combine the use of dynamic Bayesian networks,
to forecast the vital signs and the blood analysis results of patients over the
next 40 hours, and neural networks, to evaluate the severity of a patients
disease in that interval of time. Our empirical results show that the
transposition of the current state of a patient to future values with the DBN
for its subsequent use in classification obtains better the accuracy and g-mean
score than a direct application with a classifier.
David Quesada, Pedro Larrañaga, Concha Bielza
Classifying the evolution of COVID-19 severity on patients with combined dynamic Bayesian networks and neural networks

###### Abstract

When we face patients arriving to a hospital suffering from the effects of some illness, one of the main problems we can encounter is evaluating whether or not said patients are going to require intensive care in the near future. This intensive care requires allotting valuable and scarce resources, and knowing beforehand the severity of a patients illness can improve both its treatment and the organization of resources. We illustrate this issue in a dataset consistent of Spanish COVID-19 patients from the sixth epidemic wave where we label patients as critical when they either had to enter the intensive care unit or passed away. We then combine the use of dynamic Bayesian networks, to forecast the vital signs and the blood analysis results of patients over the next 40 hours, and neural networks, to evaluate the severity of a patients disease in that interval of time. Our empirical results show that the transposition of the current state of a patient to future values with the DBN for its subsequent use in classification obtains better the accuracy and g-mean score than a direct application with a classifier.

keywords: Dynamic Bayesian networks, Neural networks, Forecasting, Classification, COVID-19 +
Footnote †: journal: Journal of LaTeX Templates

## 1 Introduction

Throughout the COVID-19 pandemic, healthcare systems all around the world have suffered a staggering pressure due to the sheer number of infected patients that arrived to medical centers. The nature of this pandemic was such that patients could range from completely asymptomatic to presenting
critical respiratory issues. As such, and given that the amount of resources in medical centers is limited, it was a crucial task to discern whether or not a patient presented symptomatology that could devolve into a critical condition or into only mild afflictions.

The issue of predicting the clinical outcome of COVID-19 patients has seen much interest in recent years. Some authors opted for discerning the severity of the illness depending on certain comorbidities like heart failure [1], neurodegenerative diseases [2], cardiovascular diseases [3], or chronic pulmonary diseases [4]. These studies have shown that comorbidities related to COVID-19 increase the risk of death of a patient. As such, many efforts are also put into preprocessing clinical data and selecting an appropriate set of variables that define the effect of the illness.

From the point of view of predicting the outcome from data, many machine learning approaches have been tested in the literature. Some authors opted for performing a statistical analysis and applying logistic regression for classifying mortality [2; 5; 6; 7]. Another popular approach consists of training simple perceptron or multilayer neural network models to approximate a function that relates the variables in the system and classifies patient instances [8; 9; 10; 11]. Tree-based models like random forests [10; 12; 13; 14] or XGBoost [10; 15; 16; 17] are also some of the most popular and best performing tools for this task. In the case of interpretable models, Bayesian networks have also been applied to predicting the severity of COVID-19 on patients while also trying to gain some insight on the problem at hand [18; 19]

Another possible approach is to view the problem as a time series forecasting issue. Each patient that arrives at a hospital has its vital signs measured and has blood analysis performed on them. Afterwards, if the patient is not discharged and requires further care, new recordings are performed on a semi-regular basis. This generates time series data of each patient, where measurements are taken over a period of several hours each until either the patient overcomes the illness or passes away. In this scenario, time series models can be applied to forecast the state of a patient and predict whether they will be suffering from severe symptoms in the near future or not. This approach has also been explored in the literature with models like dynamic Bayesian networks [20], recurrent neural networks [21] and dynamic Markov processes [22].

In this work, we took a hybrid approach between static and dynamic models. We used data recovered from patients infected with the sixth Spanish COVID-19 wave that arrived to the Fundacion Jimenez Diaz hospitals in
Madrid. After preprocessing this data and selecting an appropriate variable set, we trained hybrid models between dynamic Bayesian networks (DBN) as forecasting models and neural networks (NN) as classifier models. The main idea of our proposal is to obtain the first vital signs and blood analysis from a patient and then perform forecasting of these variables with the DBN model up to a certain point in the near future. Afterwards, we can use the classifier model to identify the forecasted values as critical or not critical. This procedure can help identifying whether a patient that just arrived to triage in a medical center is going to worsen significantly in the following days.

The rest of this paper is organized as follows. Section 2 gives some background on dynamic Bayesian network models. Section 3 explains the architecture of the hybrid model with the neural network, where this classifying model is interchangeable with any other static classifier. Section 4 shows the experimental results of the tested models. Finally, Section 5 gives some conclusions and introduces future work.

## 2 Dynamic Bayesian networks

Dynamic Bayesian networks [23] are a type of probabilistic graphical model that represent conditional dependence relationships between variables using a directed acyclic graph. They extend the framework of Bayesian networks to the case of time series. Similarly to static BNs, each of the nodes in the graph represents a variable in the original system and the arcs represent their probabilistic relationships. In the case of DBNs, time is discretized into time slices that represent consecutive instants. This way, we have a representation of all the variables in our system across time. Let \(\mathbf{X}^{t}=\{X_{0}^{t},X_{1}^{t},\ldots,X_{n}^{t}\}\) be the set of all the variables in the time slice \(t\). Then, we can define the joint probability distribution of the network up to some horizon \(T\) as:

\[p(\mathbf{X}^{0},\ldots,\mathbf{X}^{T})\equiv p(\mathbf{X}^{0:T})=p(\mathbf{ X}^{0})\prod_{t=0}^{T-1}p(\mathbf{X}^{t+1}|\mathbf{X}^{0:t}), \tag{1}\]

where \(p(\mathbf{X})=\prod_{i=0}^{n}p(X_{i}|\mathbf{Pa}_{i})\) represents the probability distribution of a set of nodes \(\mathbf{X}\) and \(\mathbf{Pa}_{i}\) represents the set of parent nodes of \(X_{i}\) in the graph. However, in Equation 1 all time slices \(\mathbf{X}^{0:T}\) have to be taken into account to calculate the joint probability distribution. In this scenario, it is
very common to assume that the future state of the system is independent of the past given the present. A DBN that follows this assumption is called a first-order Markovian network. This implies that only the last instant is used to calculate the next one and it simplifies the calculation of the joint probability distribution greatly:

\[p(\mathbf{X}^{0:T})=p(\mathbf{X}^{0})\prod_{t=0}^{T-1}p(\mathbf{X}^{t+1}| \mathbf{X}^{t}). \tag{2}\]

An example of the structure of a DBN with Markovian order 1 is shown in Fig. (1). One advantage that DBN models present is that they do not need to be trained with time series of constant length. Due to the Markovian order assumption in Equation (2), we only need to recover several batches of two consecutive instants from the original dataset to learn the structure and parameters of the network. We can use several time series with different lengths recovered from the same stochastic process to train a DBN model from data. The reason for this is that we only need the values of the variables inside the temporal window defined by the Markovian order to train our model, so the total length of the time series is not relevant in the

Figure 1: Example of the structure of a first-order Markovian DBN with two time slices \(t_{0}\) and \(t_{1}\). To calculate the future values in \(t_{1}\), we would only need to know the current values of our variables in \(t_{0}\).
learning phase. This helps when applying this kind of model to real-world problems, where the length of the data from processes can vary depending on circumstances outside of the system.

## 3 Combining DBNs and static classifiers

When we predict COVID-19 severity on patients in the near future, we face several issues. On one hand, we only have the data of their vital signs and blood analysis when the patient first arrives at the hospital. As we are interested on their state on the following days, we need to forecast the evolution of these variables over time. On the other hand, we need a mechanism that identifies given a state vector of a patient whether they are in a critical state or not.

### Forecasting the state vector

When a patient afflicted with COVID-19 stays in intensive care for a prolonged period of time, they are monitored and new readings of their vital signs and blood analysis are recorded on a semi-regular basis of several hours. All the variables in these instances form a state vector \(\mathbf{S}=[s_{0},s_{1},\ldots,s_{n}]\) at each point in time, and the final data recovered from a patient \(k\) is a vector of instances \(\mathbf{P}_{k}=\left[\mathbf{S}^{0},\mathbf{S}^{1},\ldots,\mathbf{S}^{T}\right]\) ordered in time from the oldest vital sign readings and blood analysis to the most recent ones. When we combine several patients data, it generates a time series dataset that can be used to train a time series forecasting model. It is worth noting that the length \(T\) of the data from each patient depends on the time they spent in the hospital. If a patient is discharged with only one vital sign reading and blood analysis, then we do not have data with a time component. In this situation, this patient could not be used for training our temporal model.

Given that in our case all the variables in a state vector \(\mathbf{S}^{t}\) are continuous, we will use a Gaussian DBN to model the dependencies and to perform forecasting. A DBN model can help us gain some insight on which variables have a greater impact on the evolution of a patient. Furthermore, the ability of DBNs to be trained with different length time series after deciding a Markovian order is also relevant in this problem, given that the number of instances per patient varies greatly. By setting a Markovian order 1, we will be able to use the data from all patients except the aforementioned ones with a single reading, where no temporal data at all can be used.
After training the DBN model, we can use it to forecast the state vector of a patient up to a certain point in the future. This forecasting represents an estimate of the evolution that the patient will undergo, and it can be used to assess whether it will lead to severe symptoms or not. This process effectively gives an estimate of the future vital signs and blood analysis of a patient without spending additional resources and time on it.

### Classifying critical values

The task of evaluating whether a patient is in a critical state of the COVID-19 infection has been performed in the literature mainly through some kind of medical score [24] or by labelling instances due to some external indicator, for example being transferred to the intensive care unit. If we obtain a labelled dataset of patients through any of these methods, we can then take a machine learning approach by training classifier models that identify whether a patient is in a critical state given their state vector \(\mathbf{S}\).

If we combine this approach with the forecasting of the state vector, we get a hybrid model between static classifiers and time series models that is capable of evaluating the present and near future condition of a person suffering from COVID-19. When a patient arrives at a hospital and gets their vital signs and blood analysis recorded, we obtain the state vector \(\mathbf{S}^{0}\) of the very first instant of time. Then we can feed \(\mathbf{S}^{0}\) to a trained classifier model to evaluate whether this patient is already in a critical state or not. If this is not the case, we can then use \(\mathbf{S}^{0}\) as the starting point for our DBN to perform forecasting. This will return us the values of \(\mathbf{S}^{1},\mathbf{S}^{2},\ldots,\mathbf{S}^{t}\) up to a certain point \(t\) in time. All these state vectors can in turn be classified to evaluate the expected severity of the symptoms in that patient. With this method, we can see if a patient is expected to end up suffering from critical COVID-19 and when approximately will this situation occur. To illustrate this whole process, a schematic representation of this framework can be seen in Fig. (2).

Our proposed framework supports any kind of classifier that is able to produce a discrete prediction given a continuous state vector \(\mathbf{S}^{t}\). We used a modular implementation where the classifier used can be a support vector machine, an XGBoost, a neural network and a Bayesian classifier. All these classifiers have seen use in the literature and could find applications where one is more effective than the others. Due to this architecture, any other classifier model could potentially be introduced as a new module if the need arises.
In our case, the architecture that was most effective was the combination with a neural network. The network had an internal structure of 5 hidden dense layers with 64, 32, 16, 16 and 8 neurons each. They all used RELU activation functions and had their weights initialized with the identity. The last layer used a single neuron with a sigmoid activation function for binary classification. A result greater than 0.5 is equated to predicting a critical status for a patient, and a result lesser or equal to 0.5 predicts a non-critical scenario. A representation of this structure can be seen in Fig. (3).

## 4 Experimental results

For our experiments, we used a dataset consisting of anonymous data recovered from 4 different Spanish hospitals from the Fundacion Jimenez Diaz in Madrid. After preprocessing it, we used this data to fit our proposed model and evaluate its capabilities to predict the future critical status of patients suffering from COVID-19 infections.

Figure 2: Schematic representation of the classifier-DBN framework. After obtaining a state vector \(\mathbf{S}_{0}\) from a patient, we can use it to forecast the next \(t\) state vectors with the DBN model and check if they are critical with our static classifier.
### Preprocessing

Our raw dataset covers the period from the 27th of October 2021 to the 23rd of March 2022. In total, there are 21.032 rows with incomplete data from 15.858 patients and 532 variables, most of which present missing values for the majority of patients. This is a common occurrence in a medical dataset of these characteristics, given that not the same tests are performed to all the patients and some of the results have to be recorded manually. This data covered patients that had confirmed cases of COVID-19 via a positive PCR test.

The consecutive rows in the dataset that correspond to a same patient are ordered in time forming time series sequences. However, the frequency at which the instances were recorded is uneven. This is due to the fact that performing blood analysis from patients and obtaining the results does not take a fixed amount of time and is not always performed after fixed intervals. To tackle this issue, we established a period of 4 hours between each row and formed batches of instances where missing data was filled with the average values of the rest of instances in the same batch. This 4 hour period was chosen because usually new tests were performed on average roughly after every 4 hours in our dataset.

From the 21.032 rows, 13.971 were from patients that appear only in a single instance, where the vast majority were discharged from the hospital

Figure 3: Structure of the neural network model used in the experiments.
afterwards due to mild symptomatology and only 48 of these patients passed away. This data cannot be used to train the DBN models, given that a single register is not enough to form a time series sequence. However, it will be used to train the classifier models. From the remaining patients with more than a single instance, the majority of them have either two or three rows of recorded values. To illustrate this, we show a histogram with the distribution of the number of instances per patient in Fig. (4).

Regarding the 532 variables in our dataset, most of them correspond to specific values in uncommon tests and analysis, and they have over 70% of missing values across all instances. In our case, we have opted for reducing the number of variables to only those that are obtained from the vital signs of a patient, like their body temperature and their heart rate, their descriptive characteristics like age, gender and body mass index, and the variables from

Figure 4: Histogram with the number of instances per patient greater than 1 in the dataset. Inside the last bracket we have grouped all the patients with 10 or more instances. A higher number of instances indicates a longer stay in the hospital and as such a more severe case of COVID-19, which is far less common than a mild case.
a regular blood analysis like the albumin and D-dimer values. All these variables are routinely taken when a patient arrives at urgent care and obtaining them does not pose a severe expense of resources. This reduced the number of variables to 62, and from those we chose to retain the vital sign readings and the descriptive characteristics, while allowing feature subset selection on the blood analysis related variables. This subset selection was performed via random forest importance on classification on our objective variable, which will be whether or not a patient was put in the intensive care unit or passed away. This is what defines our critical cases of COVID-19, which are only a 18.8% of the total number of patients in our dataset.

### Experiment results

In this section we show the experimental results obtained with different combinations of classifier-DBN models. For our experiments, we used an XGBoost, a support vector machine, a neural network and a Bayesian classifier. In particular, this Bayesian classifier is a tree-augmented naive Bayes built following the hill climbing super-parent (HCSP) algorithm [25]. All the project was coded in R and is publicly available online in a GitHub repository1. The dataset used is not made public due privacy and legal reasons.

Footnote 1: [https://github.com/dkesada/Class-DBN](https://github.com/dkesada/Class-DBN)

Regarding the software we used in our experiments, the DBN models where trained using our own public package "dbnR"2, the XGBoost models where trained with the "xgboost" package [26], the support vector machines where trained with the "e1071" package [27], the neural networks with the "keras" R interface [28] and the Bayesian classifiers were trained with the "bnclassify" package [29]. The parameters of each classifier were optimized using differential evolution with the R package "DEoptim" [30] based on the geometric mean (g-mean) [31] of the models. This metric is defined as \(g_{m}=\sqrt{recall*specificity}\), which uses all values in the resulting confusion matrix when calculating the final score. Using both the recall and the specificity of the predictions ensures that the imbalance between critical cases and non-critical cases is taken into account when optimizing the parameters. We do not want a model optimized solely on accuracy because it would lead to models that only predict the majority class of non-critical for all patients.

Footnote 2: [https://github.com/dkesada/dbnR](https://github.com/dkesada/dbnR)

To alleviate the issue of imbalanced data, we also applied SMOTE oversampling with the 'DMwR' package [32; 33] to synthetically generate in
stances of both critical and non-critical cases. This is a common practice that creates synthetic data to offset the difference between the number of instances of the majority and minority classes. In our case, we will use SMOTE to create modified datasets for training our classifiers. This will help the models to avoid getting stuck on predicting the majority non-critical class for almost all instances.

To test our hybrid models, we take the state vector of a patient in an instance and forecast up to 10 instants into the future with the DBN model. Then, we use the classifier model to classify each of this forecasts as critical or not and we compare the predicted label with the true label of the instance. Given that each instance is separated from the next one by 4 hours, in total we forecast 40 hours into the future with the DBN model. With this method, we will be able to see the behaviour of the classifiers and the changes in accuracy and g-mean as we use state vectors from further into the future. The average results obtained across all forecasts of the models can be seen in Table 1.

The results in Table 1 show that, on average, the most accurate model is the neural network in both accuracy and g-mean. The performance of both the SVM and the HCSP are very similar in terms of accuracy, but the difference in g-mean score of the SVM shows that it is able to discern better the more uncommon critical instances. For this particular case, although the XGBoost model is very popular in the literature, it obtains worse overall results than the rest of the classifiers. In our experiments, due to the imbalance between classes we had to find a compromise between the global accuracy and the accuracy of the minoritary class. If left unchecked, the models would become biased to the majoritary class and predict almost unanimously every

\begin{table}
\begin{tabular}{l c c c c} \hline \hline  & **Accuracy** & **g-mean** & **Train (h)** & **Exec (s)** \\ \hline XGBoost & 0.698 & 0.455 & 1.950 & 9.634 \\ SVM & 0.735 & 0.522 & 1.145 & 9.654 \\ NN & 0.771 & 0.541 & 1.384 & 9.863 \\ HCSP & 0.736 & 0.468 & 1.046 & 9.878 \\ \hline \hline \end{tabular}
\end{table}
Table 1: Mean results in terms of the accuracy, g-mean score, training and execution time of the models on average for all the experiments. It is worth noting that training time includes optimization of parameters, which involves the creation of multiple models to evaluate different configurations.
single instance as non-critical, invalidating the use of the model while obtaining accuracies close to 90%. By using the g-mean as optimization metric in combination with the SMOTE oversampling, we were able to alleviate this problem. A high accuracy on the majoritary class of non-critical patients will be able to help reduce the oversaturation of ICU resources, given that all models can evaluate whether a patient will reach a critical state of the COVID-19 infection or not in less than 10 seconds. On the other hand, being able to discern the few critical cases that arise is also needed to help doctors determine which patients need more specific care to try to reduce the mortality rate. On the topic of training time, training and tuning the models takes on average between one and two hours. Given that these kind of models should not need to be retrained until some significant issue happens with the disease, like a new variant or new specific symptoms appear on patients that differ from the training data used, this training times should be reasonable to be performed once.

Given that the model with the NN obtains the best average results, we show in Fig. (5) the details of its performance depending on the time horizon. The first instant at 0 hours is equivalent to performing classification with the NN model directly to the state vector obtained from the patient. From

Figure 5: Classification results of the neural network model as we feed it state vectors further ahead in time with the DBN model. The classification performance of the neural network improves monotonically by combining it with the DBN forecastings.
there, we perform forecasting up to 40 hours with the DBN model of this state vector and use the results as input for the NN model. We can see that the NN model performs considerably better if we pair it with the DBN to classify the forecasted state of the patients rather than their initial state. As we forecast the state vector of patients further into the future, the NN improves its classification performance monotonically.

In addition, DBNs perform multivariate inference and are interpretable models. This allows them to offer doctors the forecasted values of any variable in the system as well as the underlying relationships between the rest of variables that led to those results. In the case of relevant values like the oxygen saturation of a patient, which is a good indicator of the state of a patient

Figure 6: Subset of relevant variables to the forecasting of maximum oxygen saturation (light blue) in the DBN model. The initial and maximum oxygen saturation variables from the last instant (in red) affect the calculation of the next maximum oxygen saturation value. Other variables like body temperature, systolic and diastolic blood pressures and heart rate also influence this value in the forecast.
suffering from respiratory issues, we show an example of the relationships present in the DBN model in Fig. (6). This subgraph shows the variables directly related with the maximum oxygen saturation registered in a 4 hours interval. We can see the previous maximum value of oxygen saturation from the last instant, which is to be expected due to the autoregressive component of time series. On a similar note, the initial values of oxygen saturation registered serve the model to define the range of the maximum value: lower initial oxygen saturation will likely lead to lower maximums and vice versa. Additionally, we also find in that the body temperature leading to fever, maximum diastolic blood pressure and minimum heart rate are also direct indicators of maximum oxygen saturation and play an important role in its forecasting. Lastly, minimum systolic and diastolic blood pressures are also affected. A lower level of oxygen saturation will cause higher blood pressure, increasing both minimums. This situation is reflected in the fact that this values are child nodes that depend on the current value of oxygen saturation.

## 5 Conclusions

In this work we have presented a hybrid model between DBNs and static classifiers where the state vector recovered from a patient suffering from COVID-19 is used to forecast their future state. This information is then used to assess how severe will their infection be in the future 40 hours based on their current vital signs and blood analysis. This method shows the best performance when combining DBN and NN models. While the NN is capable of discerning whether or not a patient will reach a critical state with better accuracy than the other classifiers, the DBN adds an explainable layer regarding the variables extracted from the patient. This model could help doctors decide whether or not a patient needs further specialized care and allow for a better organization of the resources available in medical centers. Additionally, we offer the code of all our models online for future reference and use.

For future work, this model could be applied in different industrial environments that require forecasting time series and classifying the state of the system. The combination of a generative model that forecasts the state of a system with a classifier model that evaluates this expected future state is a promising framework that could prove useful in applications like remaining useful life estimations. Another possible improvement could be the potential use of the DBN model as a simulator, introducing interventions in the
forecasting in order to see the effects that possible actions can have in the expected future. In the medical case, the effects of specific meds or treatments could potentially be reflected in the DBN predictions, and in other industrial cases this could lead to optimizing the expected future based on possible interventions in the initial state.

## Acknowledgements

This work was partially supported by the Madrid Autonomous Region through the "MadridDataSpace4Pandemics-CM" (REACT-EU) project. We are also grateful to the Fundacion Jimenez Diaz for providing the data for this work and to the doctors Sara Heili and Lucia Llanos for their valuable insights.
