Docsity

Midterm Exam Questions - Machine Learning | CS 446, Exams of Computer Science

Toggle sidebar
bg1
CS446: Pattern Recognition and Machine Learning Fall 2010
Midterm
October 21, 2010
This is a closed book exam. Everything you need in order to solve the problems is supplied
in the body of this exam. Note that there is an appendix with possibly useful formulae and
computational shortcuts at the end.
The exam ends at 10:45 AM. It contains 5 problems. You have 75 minutes to earn a total
of 100 points. Answer each question in the space provided.
If you need more room, write on the back side of the paper and indicate that you have done so.
Besides having the correct answer, being concise and clear is very important.
For full credit, you must show your work and explain your answers.
Good Luck!
Name: (2 Points)
Problem 1 (20 points):
Problem 2 (20 points):
Problem 3 (20 points):
Problem 4 (20 points):
Problem 5 (18 points):
Total (100 points):
1
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Midterm Exam Questions - Machine Learning | CS 446 and more Exams Computer Science in PDF only on Docsity!

CS446: Pattern Recognition and Machine Learning Fall 2010

Midterm

October 21, 2010

This is a closed book exam. Everything you need in order to solve the problems is supplied in the body of this exam. Note that there is an appendix with possibly useful formulae and computational shortcuts at the end.

The exam ends at 10:45 AM. It contains 5 problems. You have 75 minutes to earn a total of 100 points. Answer each question in the space provided.

If you need more room, write on the back side of the paper and indicate that you have done so.

Besides having the correct answer, being concise and clear is very important. For full credit, you must show your work and explain your answers.

Good Luck!

Name: (2 Points)

Problem 1 (20 points): Problem 2 (20 points): Problem 3 (20 points): Problem 4 (20 points): Problem 5 (18 points): Total (100 points):

Problem 1: Decision Trees [20 points]

(a) Let x be a vector of n Boolean variables and let k be an integer less than n. Let Dk be the class of k-disjunctions over the n variables (that is, disjunctions consisting of k literals). Consider f ∈ Dk. State the size of the smallest possible consistent decision tree for f in terms of n and k and describe its shape. Solution: The smallest possible decision tree consistent with a hypothesis in Dk contains 2k + 1 nodes. Every non-leaf node has a branch labeled “1” (or “0”, depending on whether xi or ¬xi is in the disjunction, respectively) leading to a leaf node labeled ” and a branch labeled “0” ( or “1”) leading to another non-leaf node, except for the lowest non-leaf node, that has a branch leading to a leaf node labeled “0”. (b) We wish to learn a decision tree to help students pick restaurants using three aspects – the price, the location of the restaurant and the speed of service. The data for training the tree is presented in Table 1, where the target concept is the column labeled Like?.

Price Fast? On Campus? Like?

1 $ No No No 2 $ Yes Yes No 3 $$ No No No 4 $$ Yes Yes Yes 5 $$ Yes No Yes 6 $$ No Yes Yes 7 $$$ No No No 8 $$$ Yes Yes Yes

Table 1: Restaurant choice data

i. What is the entropy of the collection of examples with respect to the target label? Solution: Fraction of Yes, No labels = (p+, p−^ = (^12 , 12 ) Entropy = −p+^ log p+^ − p−^ log p−^ = 1. 0 ii. What is the entropy of the attribute Price? Solution: The fraction of examples for the three values of Price are p 1 = 1 4 , p^2 =^

1 2 , p^3 =^

1

  1. This gives us an entropy of^

3

iii. Compute the information gain of the attribute Fast? Solution:

Gain = 1. 0 −

Entropy(

Entropy(

Problem 2: PAC Learning [20 points]

Consider the following learning task: examples are points in the 2D space (x, y) ∈ ℜ^2. The concept space C is the region between two parallel lines, either (x=a, x=b) or (y=a, y=b) for a < b. That is, each concept f ∈ C is defined by two numbers, a and b and another Boolean indicator that determines whether the lines are parallel to the x axis or the y-axis. An example (x, y) is positive for the concept (X, a, b) if and only if

a ≤ x ≤ b.

An example (x, y) is positive for the concept (Y, a, b) if and only if

a ≤ y ≤ b.

In the learning scenario, we are given a collection of m examples labeled according to a hidden concept f = (u, v, w) ∈ C and are required to learn a concept h ∈ C that approximates f.

(a) Give an algorithm for learning this concept class. Explain it and prove its cor- rectness. Write down explicitly the final hypothesis of your algorithm. Solution: The following algorithm learns the concept:

  1. Let xmin, xmax = the x co-ordinates of the left most and right most positive point respectively
  2. If all positive points (x, y)have xmin ≤ x ≤ xmax, return the hypothesis (X, xmin, xmax)
  3. Let ymin, ymax = the y co-ordinates of the left most and right most positive point respectively
  4. If all positive points (x, y)have ymin ≤ y ≤ ymax, return the hypothesis (Y, ymin, ymax) Since the data is labeled according to the hidden function f ∈ C, either one of lines 2 or 4 should return a consistent hypothesis.

(b) If there are several possible consistent hypotheses, choose one of them and ar- gue using 1-2 sentences that it is likely to perform better than other possible hypotheses. Solution: Choose the lower and upper bounds such that they individually max- imize the margin between the positive and the negative examples because this hypothesis will generalize better. (c) Show that the concept class C is efficiently PAC learnable. Solution: The proof that the concept is efficiently PAC learnable has two parts: we should be able to learn the concept with a polynomial time algorithm and the VC dimension needs to be finite. The first part is easy – part (a) shows an algorithm that can learn the concept. For the second part, note that it is sufficient to show that the VC dimension is finite, which can be showed by considering a large number of points that cannot be shattered. Here, we show that the VC dimension is 4. To show that the VC dimension is greater than 4, consider the following points:

A

B

C

D

We can show by enumeration that there is some hypothesis in the hypothesis space that can correctly assign all possible label assignments to these points. If we have five points, then label the points with the lowest and highest x values and the points with lowest and highest y values as positive and label the other point as negative. This cannot be correctly classified using a member of our hypothesis space. (Of course, to make the proof rigorous, we need to consider edge cases where several points are on a line parallel to the x or y axes.)

(d) Compute I(x) · I(z).

Solution: I(x) · I(z) = 1 One way of showing this is to list out I(x) and I(z) and compute the dot product. We will see that only the following four monomials are true in both: ∅, x 1 , ¬x 3 , x 1 ∧ ¬x 3. Hence, only these four will contribute to the dot product.

(e) Let same(x, y) denote the number of bits that have the same value in x and y. Compute K(x, z) = I(x) · I(z) as a function of same(x, z). (You may need to consider separately the case in which same(x, z) is too small.) Solution: We see that same(x, z) = 2 (the first and the third variables). Hence, 2 same(x,z)^ = 4. We showed in the previous question that I(x) · I(z) = 4. General proof: Let L denote the literals that are the same in x and y. (In our case, these will be x 1 and ¬x 3 .) The elements corresponding to all the monomials of L will be 1 both in I(x) and in I(z). All other monomials will be 0 in I(x), I(z) or both. Hence the dot product of I(x) and I(z) will be the number of monomials that can be created using the literals in L. Since there are same(x, y) literals in L, the number of monomials is 2same(x,y). This gives us the required result: I(x) · I(z) = 2same(x,z)

Problem 4: Linear Threshold Functions [20 points]

We would like use the Perceptron algorithm to learn a Boolean function in the class L 10 , 20 , 100. This is the class of 10 out of 20 out of 100 , defined over {x 1 , x 2 ,... x 100 }. Recall that a function in the class L 10 , 20 , 100 is defined by a set of 20 relevant variables. An example x ∈ { 0 , 1 }^100 is positive if and only if at least 10 out these 20 are on.

(a) Let f ∈ L 10 , 20 , 100 be defined such that the set of relevant variables is R = {x 1 , x 2 ,... x 20 }. Write f as a linear threshold function. Solution: f ≡ sgn(v · x − θ), where the weight vector v ∈ ℜ^100 and vi = 1, for 1 ≤ i ≤ 20 and 0 otherwise and θ = 10.

(b) Write f as a linear threshold function that goes through the origin, and such that the weight vector w defining f has norm 1. Solution: f ≡ sgn(w · x′). Here, we assume that the input x′^ is the 101 dimensional example vector defined by adding an extra feature that is always −1. w is the new weight vector that is defined as follows:

w =

As in the previous case, there are 20 ones and 80 zeros. That is,

w =

[

v 10

]

Problem 5: Short Questions [20 points]

(a) Suggest a variation of the preceptron update rule which has the following property: If the algorithm sees two consecutive occurrences of the same example, it will not make a mistake on the second occurrence. Solution: Let w denote the weight vector and x denote n dimensional examples. Let the labels be denoted by y ∈ {− 1 , +1}. For any x, we use w to make a prediction as sgn(w · x). We say that w has made a mistake on an example (x, y) if yw · x < h, for some h ≥ 0, and we update w as follows:

w ← w +

h − yw · x x · x

yx,

This is the aggressive update rule that we saw in the class and in one of the problem sets. To prove that this works, let the weight vector be w when it sees an example (x, y) twice. Suppose, we make a mistake on the first occurrence of the example and weight vector is updated according to the following rule:

w′^ = w + yηx, (1)

where, η is the learning rate. If this should not make a mistake upon seeing the same example again, then we require that yw′^ · x ≥ h. That is,

yw′^ · x ≥ h ⇒ y (w + ηyx) · x ≥ h ⇒ yw · x + ηx · x ≥ h ⇒ η ≥ h− xy·wx ·x (2)

Choosing the equality case from (2), we get the required value of η in the update rule (1). Note that the same update rule can be obtained by explicitly optimizing w so that it will not make a mistake on the same example as follows: Set w′^ to the vector that is closest to the current weight and does not make a mistake on the current example. That is,

w ← min w′

||w′^ − w||^2 , subject to yw · x = h

If we solve this optimization problem, we get the same update rule as above. (b) Let f be a concept that is defined on examples drawn from a distribution D. The “true” error of the hypothesis h is defined as

ErrorD(h) = P rx∈D (h(x) 6 = f (x)).

In the class, we saw that the true error of a classifier is bounded above by two terms that relate to the data and the hypothesis space. That is

ErrorD(h) < A + B

What are A and B? (If you do not remember the exact functional forms of these terms, it is sufficient to describe what they mean.) Solution: We saw in class that

A = ErrorT raining(h), B =

log |H| + log (^1) δ 2 m The first term is the empirical error and the second term is a function of the complexity of the hypothesis space. The upper bound on the true error is a generalization bound that tells us how much the true error can deviate from the observed error on the training set.

(c) We measure the performance of a learning algorithm using loss functions. Give two examples of loss functions that we have seen in class. Solution We saw several loss functions in the class. Here are some (f (x) denotes the prediction and y ∈ {− 1 , +1} is the correct value): i. 0 − 1 loss: sgn(yf (x)) ii. Log loss: log

1 + e−yf^ (x)

iii. Hinge loss: max(0, 1 − yf (x)) iv. Square loss: (y − f (x))^2