Diagnosing COVID-19 with Bayesian Networks

LATCHIYA
3 min readMay 22, 2024

--

Diagnosing COVID-19 with Bayesian Networks: A Streamlit Application

Introduction

The COVID-19 pandemic has underscored the importance of rapid and accurate diagnostic tools. Traditional diagnostic methods, such as PCR tests, though reliable, can be time-consuming and resource-intensive. In response to this challenge, we explore a probabilistic approach to diagnosing COVID-19 based on observable symptoms using Bayesian networks. Leveraging data from the World Health Organization (WHO), we construct a Bayesian network model and develop a user-friendly interface with Streamlit to facilitate instant preliminary diagnoses.

Problem Statement

Our goal is to develop a Bayesian network model that can diagnose COVID-19 infection based on symptoms such as fever, cough, and fatigue. This model will be implemented using Python and will include a Streamlit application to allow users to input symptoms and receive an immediate diagnosis probability.

Understanding Bayesian Networks

Bayesian networks are graphical models that represent the probabilistic relationships among a set of variables. They are particularly useful in medical diagnosis because they can handle uncertainty and incorporate both prior knowledge and new evidence. In the context of COVID-19, a Bayesian network can model the relationships between symptoms (e.g., fever, cough, fatigue) and the likelihood of infection.

Steps to Build the Model

  1. Data Acquisition: We begin by obtaining a dataset from WHO that includes information on COVID-19 diagnoses and associated symptoms. This dataset is crucial for training our Bayesian network model.
  2. Data Preprocessing: The dataset is cleaned and preprocessed to ensure it is suitable for model building. This involves handling missing values, encoding categorical variables, and normalizing the data if necessary.
  3. Model Construction: We define the structure of the Bayesian network, specifying nodes for symptoms and the COVID-19 diagnosis, and edges representing the probabilistic dependencies between them.
  4. Probability Estimation: Using the dataset, we calculate the conditional probabilities required for the Bayesian network. This step involves determining the likelihood of each symptom given the presence or absence of COVID-19.
  5. Implementation: We implement the Bayesian network using the pgmpy library in Python. This library provides tools for creating and querying probabilistic graphical models.
  6. User Interface Development: To make the model accessible, we develop a Streamlit application. This web-based interface allows users to input their symptoms and receive an instant probability of COVID-19 infection.

Implementing the Bayesian Network

The core of our implementation involves constructing the Bayesian network and estimating the required probabilities.

Our Streamlit application provides a simple and interactive way for users to input their symptoms and receive a diagnosis probability. The user interface allows users to select whether they have symptoms such as fever, cough, and fatigue, and then calculates the probability of COVID-19 infection based on these inputs.

Conclusion

By leveraging Bayesian networks and the power of probabilistic modeling, we can create a quick and efficient tool for preliminary COVID-19 diagnosis. This model, implemented with a user-friendly Streamlit application, provides an accessible means for individuals to assess their likelihood of infection based on symptoms. While this tool is not a replacement for professional medical diagnosis, it can serve as a valuable preliminary screening tool, potentially guiding users towards seeking further medical advice and testing.

Dharunkumar

Kanmani Krishnan

Professor Sathish Ramanujam

--

--