Home » Technical Topics » The Mathematics of AI

Understanding the Value of Bayesian Networks

  • ajitjaokar 
Big data network and IOT concept.
Bayesian Networks are used to determine the probabilities of events occurring given other events, and mark a middle ground between machine learning and graph analytics.

Machine learning algorithms are based on correlation – they do not specify cause and effect relations. Increasingly, Hence, Causality (cause and effect relations) is an important theme – missing in machine learning

A Bayesian network is a probabilistic graphical model representing a set of variables and their conditional dependencies via a directed acyclic graph (DAG).  Bayesian networks are used for causal inference because they can consider an event and predict the likelihood of several causes that could contribute to the event’s occurrence. For example, you could model a disease and its symptoms in a Bayesian network such that you could predict the disease given a set of symptoms. 

Bayesian networks are directed acyclic graphs (DAGs) whose nodes represent Bayesian variables (as observable quantities, latent variables, unknown parameters or hypotheses). In a DAG, Edges represent conditional dependencies. Each node is associated with a probability function that takes, as input, a particular set of values for the node’s parent variables and gives (as output) the probability (or probability distribution) of the variable represented by the node. 

Consider the event of wet grass.

Screenshot-2022-07-17-20.22.21

Two events can cause grass to be wet: an active sprinkler or rain. Rain directly affects the use of the sprinkler (namely, when it rains, the sprinkler usually is not active). This situation can be modelled with a Bayesian network. Each variable has two possible values, T (for true) and F (for false).

The joint probability function is, by the chain rule of probability,

Screenshot-2022-07-17-16.37.42-1

where G = “Grass wet (true/false)”, S = “Sprinkler turned on (true/false)”, and R = “Raining (true/false)”.

The model can answer questions about the presence of a cause given the presence of an effect like “What is the probability that it is raining, given the grass is wet?” by using the conditional probability formula and summing across the network.

So far, so good

But to put it in context, there are other methods of causality. A/B testing is commonly used. More formally, Randomised Controlled Trials (RCTs) could be used. But these are expensive. A detailed approach to the various causal techniques is HERE

But how do you implement causality using Bayesian networks?

We have been exploring some libraries in this regard.

CausalNex CausalNex allows data scientists and domain experts to co-develop models that go beyond correlation and consider causal relationships. You can implement effective analytics interventions, perform root cause analysis and perform what if analysis.  And the library is open-sourced. Another example is pywhy a unique collaboration between Microsoft and AWS.

I expect more such libraries will implement Bayesian networks to solve the problem of causal machine learning.

References and image source wikipedia