2. Consider the data set shown in Table below: Instance A B C Class 1 0 0 1 - 2
ID: 3702256 • Letter: 2
Question
2. Consider the data set shown in Table below: Instance A B C Class 1 0 0 1 - 2 1 0 1 + 3 0 1 0 - 4 1 0 0 - 5 1 0 1 + 6 0 0 1 + 7 1 1 0 - 8 0 0 0 - 9 0 1 0 + 10 1 1 1 + (a) Estimate the conditional probabilities for P (A = 1|+), P (B = 1|+), P (C = 1|+), P (A = 1|-), P (B = 1|-), P (C = 1|-) using the same approach as in the previous problem. (b) Use the conditional probabilities in part (a) to predict the class label for a test sample (A =1, B=1, C=) using the naive Bayes approach. (c) Compare P (A=1), P (B=1), and P (A=1, 8=1) State the relationships between A and B. (d) Repeat the analysis in part (c) using P (A=1), P (B=0), and P(A=1, B=0). (e) Compare P (A=1, B=1|Class=+) against P(A=1|Class=+) and P (B=1|Class = +). Are the variables conditionally independent given the class?
Explanation / Answer
a) Formula for Conditional Probability P(A|B) = (P(A and B) / P(B) )
For P (A = 1|+)= (P(A=1 and class=+) / P(class= +) )
= (3/5)= 0.6
Similarly we can calculate other probabilities,
P (A = 1|+) = 0.6, P (B = 1|+) = 0.4, P (C = 1|+) = 0.8, P (A = 1|?) = 0.4, P (B = 1|?) = 0.4, and P (C = 1|?) = 0.2
b) Let R: (A = 1, B = 1, C = 1) be the test sample. To predict its class, we have to find P (+|R) and P (?|R). Using Bayes Theorem
P (+|R) = P (R|+) *P (+) / P (R) and P (?|R) = P (R|?)* P (?) / P (R). Since P (+) = P (?) = 0.5 and P (R) is constant, R can be classified by comparing P (+|R) and P (?|R).
P (R|+)= P (A = 1|+) * P (B = 1|+) * P (C = 1|+) = 0.192
P (R|-)= P (A = 1|-) * P (B = 1|-) * P (C = 1|-) = 0.032
Since the value of P (R|+) is large, hence the record is assigned to (+) class.
c) P (A = 1) = 5/10=0.5, P (B = 1) =4/10= 0.4 and P (A = 1, B = 1) = P (A) × P (B) = 2/10= 0.2.
Hence, A and B are independent.
d) P (A = 1) = 5/10= 0.5, P (B = 0) = 6/10= 0.6, and P (A = 1, B = 0) = P (A = 1) × P (B = 0) = 3/10= 0.3.
So A and B are still independent.
e) Compare P (A = 1, B = 1|+) = 1/5= 0.2 against P (A = 1|+) = 3/5= 0.6 and P (B = 1|Class = +) = 2/5= 0.4. Since the product of P (A = 1|+) and P (B = 1|+) is not is not equal to the value of P (A = 1, B = 1|+). Therefore, A and B are not conditionally independent given the class.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.