Home » Machine Learning/Artificial Intelligence

# Bayesian Network in Machine Learning

In this article, we are going to discuss about **Bayesian Network which is a part of directed graph in PGMs**.

Submitted by Bharti Parmar, on March 15, 2019

## Bayesian Network

It also is known as a belief network also called student network which relies on a directed graph. It is defined for a rule for finding out the probability of an event given that another event already happened.

**P (One event \ another event)**

Here, we could isolate the probability of **B** given **A** and probability of **A** Given **B** and compute for simple probability. It is a very simple and important **Bayes theorem** problem for calculating the probability.

**Diagram:**

P(A/B) = P(B/A) * P(A) / P(B) P(B/A) = P(A/B) * P(B) / P(A)

## Bayes Network

A Bayes network is a structure that can be represented as a direct acyclic graph.

- It allows a compact representation of the distribution from the chain rule of Bayes network.
- It observes conditional independencies relationships between random variables.

A **DAG (directed acyclic graph)** is a finite directed graph with no directed cycles.

**Diagram:** Example of Bayes network

There are 4 random variables in graph **G**, **F**, **P**, **O**:

- In
**Genes (G)**0 is for bad and 1 is for good. - In
**bool (F)**0 is for no and 1 for yes. - We take grade in bad, okay and brilliant.
- Then we check performance in bad, okay and brilliant in the spot or no spot.

The edges in the graph encoded the dependencies in the graph,

- The "Genes" depends on the "good" and "bad and the form in bool "yes" and "no".
- The "Genes" in turn, determines whether the genes are "good" or "bad" with bool form in "yes" or "no".

The direction of arrows tells us about cause-effect relationships — "Performance" affects the "final probability" score.

Finally, let’s look at the tables associated with each of the nodes. Formally, these are called conditional probability distributions (CPDs).

**Conditional probability "P":**

The CPDs for "Genes" and "form" are simple, because these variables do not depend on any of the other variables. Basically, the table encodes the probabilities of these variables. As you might have noticed, the values in each of the tables must sum to 1.

The CPD for "O" encodes the conditional probabilities p(prob=O | conditional prob. = P).

The CPD for "P" is easy to understand because it has two parents, the conditional probabilities will be of the form(prob. P | Genes=G, form = F), that is, what is the probability of "prob." being P. Each row now corresponds to a pair of values of "Genes" and "form." Again, the row values add up to 1. An essential requirement for Bayesian networks is that the graph must be a directed acyclic graph (DAG).

**Probability "O":**

**Working:**

- Each node in the Bayes network will have a CPD associated with it.
- If the node has parents, the associated CPD represents P(value \ Parents value).
- If a node has no parents, the CPD represents P(value), the unconditional probability of the value.

**Conclusion:** In this article, we have learned about **Bayesian network and Bayes network with example and conditional probability distribution**. We will know more about ML in the upcoming article. Have a nice day! Happy learning!

TOP Interview Coding Problems/Challenges

- Run-length encoding (find/print frequency of letters in a string)
- Sort an array of 0's, 1's and 2's in linear time complexity
- Checking Anagrams (check whether two string is anagrams or not)
- Relative sorting algorithm
- Finding subarray with given sum
- Find the level in a binary tree with given sum K
- Check whether a Binary Tree is BST (Binary Search Tree) or not
- 1[0]1 Pattern Count
- Capitalize first and last letter of each word in a line
- Print vertical sum of a binary tree
- Print Boundary Sum of a Binary Tree
- Reverse a single linked list
- Greedy Strategy to solve major algorithm problems
- Job sequencing problem
- Root to leaf Path Sum
- Exit Point in a Matrix
- Find length of loop in a linked list
- Toppers of Class
- Print All Nodes that don't have Sibling
- Transform to Sum Tree
- Shortest Source to Destination Path

Comments and Discussions

**Ad:**
Are you a blogger? Join our Blogging forum.