Answered step by step
Verified Expert Solution
Link Copied!

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
B occurs is represented as follows:
P(A|B)=P(B|A)*P(A)P(B)
The law of total probability can be used to calculate the probability of the
evidence P(B). If {A1,A2,dots,An} is a partition of the sample space, which is
the collection of all experimental results, then:
P(B)=i?P(B|Ai)*P(Ai)
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
(signalled)(probability) that this content is copied/plagiarized.
I: Another student (colleague) marks the material as inappropriate/plagiarism.
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://pgmpy.org/models/bayesiannetwork.html
Import the libraries :
from pgmpy.models import BayesianModel
from pgmpy.factors.discrete import TabularCPD
from pgmpy. inference import VariableElimination
import numpy as np
Question 1
Create the Bayesian network using: bayesNet = BayesianModel ()
For all nodes: bayesNet.add_node ("Name_Node")
For all edges: bayesNet.add_edge("Name_Node1", "Name_Node2")
Add CPDs to each node using the function TabularCPD ().
Check if the model is correctly created using bayesNet.check_model().
Create a solver that uses variable elimination internally for inference:
solver = VariableElimination (bayesNet)
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Neo4j

Authors: Gregory Jordan

1st Edition

1484200225, 9781484200223

More Books

Students also viewed these Databases questions