Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Part B Bayesian Statistics over Bayesian Networks and Inferencing them using Pgmpy Python library: ! pip install pgmpy Theorem of Bayes Bayes' theorem is a
Part B
Bayesian Statistics over Bayesian Networks and Inferencing them using Pgmpy
Python library: pip install pgmpy
Theorem of Bayes
Bayes' theorem is a fundamental concept in Bayesian statistics, as it is used
by Bayesian methods to update probabilities, or degrees of belief, following the
acquisition of new data. The conditional probability of A occurring given that
occurs is represented as follows:
The law of total probability can be used to calculate the probability of the
evidence If dots, is a partition of the sample space, which is
the collection of all experimental results, then:
Bayesian Network
A Bayesian network is a probabilistic graphical model, a kind of statistical model
that utilizes a directed acyclic graph DAG to describe a set of variables and
their conditional relationships. Bayesian networks are perfect for analyzing past
occurrences and estimating the probability that any of numerous known causes
had a role.
We can use Bayes' rule and the total probability theorem to infer probabili
ties in a Bayesian network. Let's consider an example: students are required to
submit a project for Introduction in AI and the Professor attempts to predict
if students copied plagiarized the content. For this, the Professor would like
to create a statistical method that can take preemptive measures based on the
information given. Let's assume we have the following information:
L: A prediction from a NLP ML Natural Language Processing Machine
Learning model that can read the content of the Project and give a score
signalledprobability that this content is copiedplagiarized
I: Another student colleague marks the material as inappropriateplagiarism
S: The Project was suspended before for any bad remarks.
N: Score Probability that the Project should not be considered not
scored
R: Score Probability that the Student should be restricted for this lecture
ratrappage
Using Pgmpy Python Library
We will use the pgmpy Python library to compute the probabilities. You can
follow the tutorial and analyze the existing functions at:
https:pgmpyorgmodelsbayesiannetworkhtml
Import the libraries :
from pgmpymodels import BayesianModel
from pgmpyfactors.discrete import TabularCPD
from pgmpy inference import VariableElimination
import numpy as np
Question
Create the Bayesian network using: bayesNet BayesianModel
For all nodes: bayesNet.addnode NameNode"
For all edges: bayesNet.addedgeNameNode "NameNode
Add CPDs to each node using the function TabularCPD
Check if the model is correctly created using bayesNet.checkmodel
Create a solver that uses variable elimination internally for inference:
solver VariableElimination bayesNet
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started