代写代考 Spring ¡®22 AI Homework 9: solutions – cscodehelp代写
Spring ¡®22 AI Homework 9: solutions
Suppose that you are trying to carry out classification learning where C is the classification attribute and the rest are predictive attributes. You are given the following data set shown below.
X, Y, Z are predictive attributes, with values 1 and 2 and C is the classification attribute, with values 1, 2, and 3. The null value indicates nothing was recorded for that attribute. ¡°#¡± is not an attribute, but rather the count of the occurrences in the training set. (imagine there are 10 lines in the training set with (1,1,1,1)
A. (5 points) How does Naive Bayes classify the instance X=1, Y=2, Z=1? Do not use the Laplacian correction.
Copyright By cscodehelp代写 加微信 cscodehelp
B (5 points) Using the Laplacian correction with ¦Ä = 1, how does Naive Bayes classify the instance X=1, Y=2, Z=2?
A. Determine the largest probability of:
P(C=1|X=1,Y=2,Z=1), P(C=2|X=1,Y=2,Z=1), P(C=3|X=1,Y=2,Z=1)
Using Naive Bayes these split into:
P(C=1|X=1,Y=2,Z=1) ~ P(C=1)*P(X=1|C=1)*P(Y=2|C=1)*P(Z=1|C=1) P(C=2|X=1,Y=2,Z=1) ~ P(C=2)*P(X=1|C=2)*P(Y=2|C=2)*P(Z=1|C=2) P(C=3|X=1,Y=2,Z=1) ~ P(C=3)*P(X=1|C=3)*P(Y=2|C=3)*P(Z=1|C=3)
count occurrences
P(C=1) = 20/100
P(C=2) = 34/100
P(C=3) = 46/100
P(X=1|C=1) = 15/20
P(X=1|C=2) = 8/34
P(X=1|C=3) = 21/36 # remove null X from denominator P(Y=2|C=1) = 5/20
P(Y=2|C=2) = 14/34
P(Y=2|C=3) = 20/46
P(Z=1|C=1) = 10/20
P(Z=1|C=2) = 16/34
P(Z=1|C=3) = 10/40 # remove null Z from denominator
Plugging back in
P(C=1|X=1,Y=2,Z=1) = 1/5 * 3/4 * 1/4 * 1/2 = 0.01875 P(C=2|X=1,Y=2,Z=1) = 17/50 * 8/17 * 7/17 * 4/17 = 0.0155 P(C=3|X=1,Y=2,Z=1) = 23/50 * 21/36 * 10/23 * 1/4 = 0.0292
Prediction: C=3. (Note how null removal increases the C3 probabilities.)
P(Z=2|C=1) = (10+1)/(20+2)
P(Z=2|C=2) = (18+1)/(34+2)
P(Z=2|C=3) = (30+1)/(40+2) # remove null Z from denominator
Do the same laplacian correction for previous calculations needed (opt: can skip correction for pure classification attributes, but I did not here)
P(C=1|X=1,Y=2,Z=2) = 21/103 * 16/22 * 6/22 * 11/22 = 0.0202
P(C=2|X=1,Y=2,Z=2) = 35/103 * 9/36 * 15/36 * 19/36 = 0.0187
P(C=3|X=1,Y=2,Z=2) = 47/103 * 22/38 * 21/48 * 31/42 = 0.0853
Prediction: C=3.
程序代写 CS代考 加微信: cscodehelp QQ: 2235208643 Email: kyit630461@163.com