Lecture W13a
Lecture W13a
• Bayesian Networks
Recap of Probability Distributions
3
Recap - Bayes Theorem
𝑃 𝐵 𝐴 .𝑃(𝐴)
•𝑃 𝐴 𝐵 =
𝑃(𝐵)
• where
• 𝑃 𝐴 𝐵 is Posterior
• 𝑃 𝐵 𝐴 is likelihood
• 𝑃(𝐴) is Prior
• B is event of interest
• A is evidence
4
Bayes Theorem
• Bayes Theorem
5
Recap - Naïve Bayes Classifier
• Applications:
• Disease Diagnosis
• Document Classification
• Credit Scoring
• Sentiment Analysis
• Recommender Systems
• Spam Filtering
6
Recap - Laplace Smoothing
• Used when zero frequency problem occurs
• Add a Laplace Smoothing Factor Alpha to each event
• Default value of Alpha is 1.
7
Gaussian Naïve Bayes Classifier
• Used when features are continuous
1 1 𝑥−𝜇 2
− ( )
𝑓 𝑥 = 𝑒 2 𝜎
𝜎 2𝜋
8
Gaussian Naïve Bayes Classifier
• Example – Gender Classification
• Classify a new person whose height is 6ft, weight is 130 lbs,
and foot size is 8 inch.
10
Gaussian Naïve Bayes Classifier – Example
11
Gaussian Naïve Bayes Classifier – Example
1 𝑥−𝜇 2
1 − ( )
•𝑓 𝑥 = 𝑒 2 𝜎
𝜎 2𝜋
12
Gaussian Naïve Bayes Classifier – Example
1 𝑥−𝜇 2
1 − ( )
•𝑓 𝑥 = 𝑒 2 𝜎
𝜎 2𝜋
• Based on your calculations, what is the gender of the new test
sample?
• Male / Female?
13
Bayesian Networks
A Bayesian network (BN) is a probabilistic graphical model for representing knowledge about an
uncertain domain, where each node corresponds to a random variable and each edge represents
the conditional probability for the corresponding random variables.
14
Bayesian Networks
• Identify all the variables
15
Bayesian Networks
• Alarm Example
• Earthquakes and burglaries are independent events.
• Either cause an alarm to go off.
• Suppose you get an alarm.
• Does hearing that there's an earthquake increase, decrease, or
keep constant the probability of a burglary?
16
In-class Activity
• Make a group of 4 students
• 10 mins
17
Bayesian Networks
• Example
• Medical Diagnosis
• A patient is coughing and have itchy eyes, do the patient have allergies or
cold?
• Make a DAG (variables, edges) and equate joint and local conditional
distributions…
18
Bayesian Networks – Solved example
• Example
• Medical Diagnosis
19
Questions?