Docsity

Conditional Entropy - Artificial Intelligence - Solved Exam, Exams of Artificial Intelligence

Partial preview of the text

Download Conditional Entropy - Artificial Intelligence - Solved Exam and more Exams Artificial Intelligence in PDF only on Docsity!

Final Examination

CS 540: Introduction to Artificial Intelligence

May 16, 2012

LAST NAME: SOLUTIONS

FIRST NAME:

Problem Score Max Score

1 ___________ 19

2 ___________ 10

3 ___________ 14

4 ___________ 10

5 ___________ 18

___________

___________

Total ___________ 100

Question 1. [19] Decision Trees

(a) [8] Suppose you are using the Decision Tree Learning algorithm to learn a binary classification variable, C , and you must decide which attribute to assign to a node in the tree. At this node there are 100 examples; 25 are positive and 75 are negative. If attribute A is selected, its first child will get 5 positive and 50 negative examples, and its second child will get 20 positive and 25 negative examples.

(i) [4] Write an expression in terms of logs and fractions for computing the entropy of C , i.e., H ( C ). You do not need to simplify this or give a real-valued answer.

H ( C ) = H(25/100, 75/100) = -(25/100 * log 2 25/100 + 75/100 * log 2 75/100)

(ii) [4] Write an expression in terms of logs and fractions for computing the conditional entropy (also called Remainder) of choosing attribute A , i.e., H ( C | A ). You do not need to simplify this or compute a real-valued answer.

H ( C | A ) = 45/100 * H (5/55, 50/55) + 55/100 * H (20/45, 25/45)

= .45 * [-5/55 * log 5/55 – 50/55 * log 50/55]

  • .55 * [-20/45 * log 20/45 – 25/45 * log 25/45]

(b) [3] In a problem where each example has n binary attributes, to select the best attribute for a decision tree node at depth k , where the root node is at depth 0, how many attributes are candidates for selection at this node?

n - k

Question 2. [10] Probabilistic Reasoning

A barrel contains many balls, some of which are red and the rest are blue. 40% of the balls are made of metal and the rest are made of wood. 30% of the metal balls are colored blue, and 10% of the wood balls are colored blue. Let Boolean random variables B mean a ball is blue (so ¬ B means a ball is red), and M means a ball is metal (and ¬ M means it is wood).

(a) [2] What is the probability that a wood ball is red, i.e., P (¬ B | ¬ M )?

P (¬ B | ¬ M ) = 1 - P ( B | ¬ M ) = 1 - 0.1 = 0.

(b) [4] What is the prior probability that a ball is blue, i.e., P ( B )?

P ( B ) = P ( B | M ) P ( M ) + P ( B |¬ M ) P (¬ M ) = .3 * .4 + .1 * (1 - .4) = 0.

(c) [4] What is the posterior probability that a blue ball is metal, i.e., P ( M | B )?

P ( M | B ) = P ( B | M ) P ( M ) / P ( B ) = .3 * .4 / .18 = 0.

Question 3. [14] Naïve Bayes

Consider the problem of detecting if an email message contains a Virus. Say we use four random variables to model this problem: Boolean class variable V indicates if the message contains a virus or not, and three Boolean feature variables: A , B and C. We decide to use a Naïve Bayes Classifier to solve this problem so we create a Bayesian network with arcs from V to each of A , B and C. Their associated CPTs are created from the following data: P ( V )=0.2, P (¬ V )=0.8, P ( A | V )=0.8, P ( A |¬ V )=0.4, P ( B | V )=0.3, P ( B |¬ V )=0.1, P ( C | V )=0.1, P ( C |¬ V )=0.

V P ( A | V ) P ( B | V ) P ( C | V ) P ( V )

False 0.4 0.1 0.6 0.

True 0.8 0.3 0.1 0.

(a) [3] Compute P (¬ A , B , C | V )

P (¬ A , B , C | V ) = (1 - P ( A | V )) P ( B | V ) P ( C | V ) = .2 * .3 * .1 = 0.

(b) [3] Compute P (¬ A , C , V )

P (¬ A , C , V ) = P (¬ A | C , V ) P ( C , V ) = P (¬ A | V ) P ( C | V ) P ( V ) = .2 * .1 * .2 = 0.

(c) [4] Compute P ( A , ¬ B , ¬ C )

P ( A , ¬ B , ¬ C ) = P ( A | V ) P (¬ B | V ) P (¬ C | V ) P ( V )

  • P ( A | ¬ V ) P (¬ B | ¬ V ) P (¬ C | ¬ V ) P (¬ V )

= .8 * .7 * .9 * .2 + .4 * .9 * .4 * .8 = 0.

(d) [4] Compute P ( V | A , ¬ B , ¬ C )

P ( V | A , ¬ B , ¬ C ) = P ( A , ¬ B , ¬ C | V ) P(V) / P ( A , ¬ B , ¬ C )

= P ( A | V ) P (¬ B | V ) P (¬ C | V ) P ( V ) / .216 = 0.

Question 5. [18] Hidden Markov Models

The following HMM describes Chuck's emotional state on consecutive days. Each day he is either Happy or Sad. But he hides his emotional state so all you can observe is his facial expression each day, which is either a Smile , Frown , Laugh , or Yell. Let qt define his emotional state on day t. Let ot indicate his observed facial expression on day t. The arcs from the Start state give the probabilities of his initial emotional state on day 1 (i.e., they specify the π vector in the HMM).

(a) [3] Compute P ( q 1 = Sad , q 2 = Sad , q 3 = Happy , q 4 = Happy )

0.3 * 0.8 * 0.2 * 0.8 = 0.

(b) [5] Compute P ( q 2 = Happy )

P ( q 2 = Happy ) = P ( q 2 = Happy | q 1 = Happy ) P ( q 1 = Happy )

  • P ( q 2 = Happy | q 1 = Sad ) P ( q 1 = Sad ) = .8 * .7 + .2 * .3 = 0.

(c) [5] Compute P ( o 2 = Frown )

P ( o 2 = Frown ) = P ( o 2 = Frown, q 2 = Happy, q 1 = Happy )

  • P ( o 2 = Frown, q 2 = Happy, q 1 = Sad )

  • P ( o 2 = Frown, q 2 = Sad, q 1 = Happy )

  • P ( o 2 = Frown, q 2 = Sad, q 1 = Sad )

= .7.8.1 + .3.2.1 + .7.2.5 + .3.8.5 = 0.

(d) [5] Compute P ( q 1 = Sad | o 1 = Frown )

P ( q 1 = Sad | o 1 = Frown ) = P ( o 1 = Frown | q 1 = Sad ) P ( q 1 = Sad ) / P ( o 1 = Frown )

= P ( o 1 = Frown | q 1 = Sad ) P ( q 1 = Sad ) / [ P ( o 1 = Frown | q 1 = Sad ) P ( q 1 = Sad )

  • P ( o 1 = Frown | q 1 = Happy ) P ( q 1 = Happy )]

= .5 * .3 / [.5 * .3 + .1 * .7] = 0.

Question 6. [23] Propositional Logic

(a) [2] If α |= β and β |= α what does this mean about relation between the two PL sentences α and β?

They are logically equivalent.

(b) [2] If (α |- β) ⇒ (α |= β) for arbitrary PL sentences α and β, what does this mean about the inference algorithm associated with |-?

It means the inference algorithm is sound.

(c) [2] If |- denotes a complete inference algorithm and α |= β then α ∧ ¬β |- ___________

False

(d) [3] Is the sentence (( P ⇒ Q ) ∧ Q ) ⇒ P valid, satisfiable, or unsatisfiable?

Satisfiable (but not valid) since when P =T and Q =T the sentence is True, but when P =F and Q =T, the sentence is False.

(e) [2] True or false: ( P ⇔ Q ) |= ( P ∨ Q )

False because one of the models of P ⇔ Q has P =F and Q =F, which does not satisfy P ∨ Q

(f) [3] Convert to CNF the sentence ( P ∨ Q ) ⇔ R

(¬ R ∨ P ∨ Q ) ∧ (¬ P ∨ R ) ∧ (¬ Q ∨ R )

(g) [2] True or false: The sentence ( P ∨ Q ) ⇒ ( R ∨ S ) can be represented by a set of Horn clauses.

False

(h) [2] True or false: The sentence ( P ∧ Q ) ⇔ R can be represented by a set of Horn clauses.

True since this is equivalent to (¬ P ∨ ¬ Q ∨ R ) ∧ (¬ R ∨ P ) ∧ (¬ R ∨ Q )

(i) [5] Given the four PL sentences: ¬ P ∨ ¬ Q , ( P ∨ Q ) ∧ ( P ∨ R ), ( S ∨ Q ) ∧ ( S ∨ ¬ R ), ¬ R defining a KB, prove S using the Resolution Refutation algorithm. Show your answer as a proof tree.

  1. Resolve ¬S and S ∨ Q to obtain Q
  2. Resolve Q and ¬P ∨ ¬Q to obtain ¬P
  3. Resolve ¬P and P ∨ R to obtain R
  4. Resolve R and ¬R to obtain False