Bayesian Networks
Dive into Bayesian networks: Master nodes, edges, conditional probability tables, and unleash the power of Bayes' theorem.
Let's now dive into probabilistic graphical models. Our goal is to explain the concept in an accessible and intuitive way to help us build a strong foundation in understanding and working with Bayesian networks.
What are Bayesian networks?
A Bayesian network is a type of probabilistic graphical model that represents a set of variables and their conditional dependencies using a directed acyclic graph (DAG). In simpler terms, they are a visual representation of the relationships between variables, along with the probabilities associated with those relationships.
A Bayesian network consists of three main components:
Nodes: These represent the variables in the network. They can be any type of variable, such as discrete, continuous, or even hidden/latent variables.
Edges: These are directed arrows that connect nodes, representing the conditional dependencies between variables. The direction of the arrow indicates the direction of the dependency.
Conditional probability distribution (CPD): These tables contain the probabilities associated with the relationships between the connected nodes. They define the likelihood of one variable taking a particular value given the values of its parent nodes.
Test and disease scenario
Imagine our friend Pieter feeling a little bit sick, without any specific symptoms.
He decides to visit the doctor, who is also uncertain about what might be causing the discomfort. The doctor suggests running some tests. After a week, the results come back, revealing a positive test for a very rare disease that affects about 0.1% of the population. This disease has severe consequences, and it's not something one would want to have.
Naturally, Pieter is concerned and asks the doctor, "How certain is it that I have this disease?" The doctor explains that the test can correctly identify 99% of people who have the disease and only incorrectly identify 1% of people who don't have the disease. That sounds concerning.
At this point, Pieter might think the chances of actually having the disease are 99% because that's the accuracy of the test. However, this conclusion is not correct! To truly understand the situation, we need to explain to Pieter how to apply Bayes' theorem.
Now, we will explore the main concepts behind Bayes' theorem and its relationship with Bayesian networks, which will help us gain a better understanding of our likelihood of having the disease based on the test results and the prevalence of the disease in the population.
Defining the nodes
We are going to build this Bayesian network in parts. First, we are going to define the nodes. In a Bayesian network, nodes represent random variables or uncertain events.
To make this example simple and easy to understand, we will define only two nodes.
1. Disease presence: Node indicating the probability of the presence of the disease in Pieter's body.
2. Test result: Node indicating the accuracy of the test that Pieter is undergoing.
Defining the states of the nodes
In a Bayesian network, the states of a node are the possible outcomes or values that these random variables can take. Each state corresponds to a distinct, mutually exclusive outcome of the variable represented by the node. Let’s define the states for our two nodes:
1. Disease presence node: Node indicating the probability of the presence of the disease in Pieter's body.
Infected: Pieter has the infection
Non-infected: Pieter does not have the infection
2. Test result node: Node indicating the accuracy of the test that Pieter is undergoing.
True: The test is completely accurate with its diagnosis.
False: The test is totally inaccurate in its diagnosis.
Get hands-on with 1300+ tech skills courses.