0% found this document useful (0 votes)
14 views

P03 BayesianLearning

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

P03 BayesianLearning

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Aprendizagem 2023

Lab 3: Bayesian learning

Practical exercises

I. Probability theory

1. Consider the following registry where an experiment is repeated A B C D


𝐱1 1 1 0 0
six times and four events (A, B, C and D) are detected.
𝐱2 1 1 1 0
Considering frequentist estimates, compute: 𝐱3 0 0 0 1
𝑝(𝐴) 𝐱4 0 0 0 1
𝐱5 0 0 0 0
𝑝(𝐴, 𝐵) 0 0 0 0
𝐱6
𝑝(𝐵|𝐴)
𝑝(𝐴, 𝐵, 𝐶)
𝑝(𝐴|𝐵, 𝐶)
𝑝(𝐴, 𝐵, 𝐶, 𝐷)
𝑝(𝐷|𝐴, 𝐵, 𝐶)

2. Considering the following two-dimensional measurements {(-2,2),(-1,3),(0,1),(-2,1)}.


a) What are the maximum likelihood parameters of a multivariate Gaussian distribution for this
set of points?
b) What is the shape of the Gaussian? Draw it approximately using a contour map.

II. Bayesian learning

3. Consider the following dataset where:


y1 y2 y3 y4 y5 class
− 0: False and 1: True
𝐱1 1 1 0 1 0 1
− y1: Fast processing 𝐱2 1 1 1 0 0 0
− y2: Decent Battery 𝐱3 0 1 1 1 0 0
𝐱4 0 0 0 1 1 0
− y3: Good Camera
𝐱5 1 0 1 1 1 1
− y4: Good Look and Feel 𝐱6 0 0 1 0 0 1
− y5: Easiness of Use 𝐱7 0 0 0 0 1 1
− class: iPhone
And the query vector 𝐱 new = [1 1 1 1 1]𝑇
a) Using Bayes’ rule, without making any assumptions, compute the posterior probabilities for
the query vector. How is it classified?
b) What is the problem of working without assumptions?
c) Compute the class for the same query vector under the naive Bayes assumption.
d) Consider the presence of missings. Under the same naive Bayes assumption, how do you
classify 𝐱 new = [1 ? 1 ? 1]𝑇

4. Consider the following dataset

weight (kg) height (cm) NBA player


𝐱1 170 160 0
𝐱2 80 220 1
𝐱3 90 200 1
𝐱4 60 160 0
𝐱5 50 150 0
𝐱6 70 190 1

And the query vector 𝐱 new = [100 225]𝑇


a) Compute the most probable class for the query vector assuming that the likelihoods are
2-dimensional Gaussians
b) Compute the most probable class for the query vector, under the Naive Bayes assumption,
using 1-dimensional Gaussians to model the likelihoods

5. Assuming training examples with m Boolean features.


a) How many parameters do you have to estimate considering features are Boolean and:
i. no assumptions about how the data is distributed
ii. naive Bayes assumption
b) How many parameters do you have to estimate considering features are numeric and:
iii. multivariate Gaussian assumption
iv. naive Bayes with Gaussian assumption

Programming quests

Resources: Classification and Evaluation notebooks available at the course’s webpage

6. Reuse the sklearn code from last lab where we learnt a decision tree in the breast.w data:
a) apply the naïve Bayes classifier with default parameters
b) compare the accuracy of both classifiers using a 10-fold cross-validation

You might also like