# Bayesian Network with example

##### Introduction:
Bayesian Network is a probabilistic graphical model used to represent probabilistic relationships among variables. It is broadly used to support decision-making under uncertainty. It is a graphical model that represents a set of random variables and their conditional dependencies via directed acyclic graphs (DAG). This article aims to provide a detailed understanding of Bayesian Networks, their applications and an example depicting how Bayesian Networks work.

What are Bayesian Networks:

A Bayesian Network is a directed acyclic graph (DAG) defined by nodes and edges. Nodes in the graph represent random variables, and edges represent probabilistic dependencies between the variables. Each node in the Bayesian network can have multiple states, and the probability distribution over the states of a node depends on the states of its parents. Bayesian Networks are used for probabilistic inference, learning, and decision-making. Bayesian Networks can be used to model a wide range of applications such as medical diagnosis, fault diagnosis, natural language understanding, speech recognition, image recognition, credit scoring and many others. They are broadly applied in Artificial Intelligence and machine learning.

How do Bayesian Networks work:

Bayesian Networks work based on the assumption of Bayesian probabilities. It means that the probability of a particular event is determined by the prior probabilities of the relevant factors. For example, suppose we want to predict the probability of rain tomorrow. We collect the relevant data like humidity, temperature, pressure, etc., and we build a Bayesian Network based on the collected data. The Bayesian Network represents the probabilistic dependencies among the variables. The nodes represent the variables, and the edges represent the conditional probabilities. Suppose we have a Bayesian Network with two nodes: Rain and the Humidity. 'Rain' is the parent node, and 'Humidity' is the child node. Suppose the probability of rain tomorrow is 0.3. It means that the prior probability of rain tomorrow without any additional information is 0.3. Now suppose we know the humidity level, and it is high. Based on previous data, we know that if the humidity is high, the probability of rain increases to 0.6. Now, the new probability of rain tomorrow given that the humidity is high becomes 0.6. This is an example of Bayesian inference using Bayesian Networks.

Example: Counterfeit Money Detection Consider a scenario where some counterfeit money has been discovered in a bank, and the bank wants to know how the counterfeit money got inside the bank. The bank suspects that the counterfeit money was either deposited by an employee or a customer. The bank has collected the following data:

• There are 100 employees and 1000 customers
• 5% of the employees and 10% of the customers have a motive to deposit counterfeit money
• 30% of the counterfeit money deposited by employees was detected, and 20% of the counterfeit money deposited by customers was detected.
Now, we will create a Bayesian Network based on the above data. First, we will represent the variables in the network. We have two variables: Employee and Customer. We represent them with the nodes in the graph. Then, we add the edges to represent the dependencies between the variables. We add an edge from the Employee node to the Counterfeit node, and an edge from the Customer node to the Counterfeit node. The Counterfeit node represents the probability of counterfeit money in the bank. The Employee node represents the probability of an employee depositing counterfeit money. The Customer node represents the probability of a customer depositing counterfeit money. The Bank Detection node represents the probability of the bank detecting the counterfeit money deposited.

Now, we will add the probabilities to the nodes and edges. We will use the data provided in the problem statement to determine the probabilities.

• P (Employee) = 0.01 and P (Customer) = 0.99 (The sum of these probabilities is 1).
• P (Counterfeit | Employee) = 0.05 and P (Counterfeit | Customer) = 0.10 (The probability of Employees or Customers depositing counterfeit money)
• P (Detection | Employee) = 0.3 and P (Detection | Customer) = 0.2

Using Bayes' theorem, we can calculate the probability of the counterfeit money deposited by employees given that it was detected by the bank. We can compute this probability using the following formula: P (Employee | Detection) = P (Detection | Employee) * P (Employee) / P (Detection) Now, we will use the probabilities in the Bayesian network we have created to calculate the probabilities and answer the question. Suppose we want to calculate the probability of counterfeit money deposited by customers given that it was not detected by the bank. We can compute this probability using the following formula: P (Customer | Not Detection) = P (Not Detection | Customer) * P (Customer) / P (Not Detection) After the calculation, we can determine that the probability of counterfeit money deposited by customers given that it was not detected by the bank is 0.176.

##### Conclusion:
Bayesian Networks is a powerful tool that represents probabilistic relationships in a graphical format. They have diverse applications ranging from medical diagnosis to speech recognition. By modeling a system as a Bayesian Network, we can perform probabilistic inference, learning and decision-making. The example of Counterfeit Money Detection illustrates how Bayesian Networks can be applied to solve real-world problems. By building a Bayesian Network, we can calculate the probabilities of different events, which help us make informed decisions based on the available data.