17
Midterm Exam Solutions CMU 10-601: Machine Learning (Spring 2016) Feb. 29, 2016 Name: Andrew ID: START HERE: Instructions This exam has 17 pages and 5 Questions (page one is this cover page). Check to see if any pages are missing. Enter your name and Andrew ID above. You are allowed to use one page of notes, front and back. Electronic devices are not acceptable. Note that the questions vary in difficulty. Make sure to look over the entire exam before you start and answer the easier questions first. Question Point Score 1 20 2 20 3 20 4 20 5 20 Extra Credit 14 Total 114

Midterm Exam Solutions€¦ · The sample complexity bounds discussed in class show that this is rare, but not impossible. 10-601: Machine Learning Page 6 of172/29/2016 ... {2 sentences

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Midterm Exam Solutions€¦ · The sample complexity bounds discussed in class show that this is rare, but not impossible. 10-601: Machine Learning Page 6 of172/29/2016 ... {2 sentences

Midterm Exam Solutions

CMU 10-601: Machine Learning (Spring 2016)

Feb. 29, 2016

Name:

Andrew ID:

START HERE: Instructions

• This exam has 17 pages and 5 Questions (page one is this cover page). Check to see ifany pages are missing. Enter your name and Andrew ID above.

• You are allowed to use one page of notes, front and back.

• Electronic devices are not acceptable.

• Note that the questions vary in difficulty. Make sure to look over the entire exambefore you start and answer the easier questions first.

Question Point Score

1 20

2 20

3 20

4 20

5 20

Extra Credit 14

Total 114

Page 2: Midterm Exam Solutions€¦ · The sample complexity bounds discussed in class show that this is rare, but not impossible. 10-601: Machine Learning Page 6 of172/29/2016 ... {2 sentences

10-601: Machine Learning Page 2 of 17 2/29/2016

1 Naive Bayes, Probability, and MLE [20 pts. + 2 Extra Credit]

1.1 Naive Bayes

You are given a data set of 10,000 students with their sex, height, and hair color. You aretrying to build a classifier to predict the sex of a student, so you randomly split the datainto a training set and a testing set. Here are the specifications of the data set:

• sex ∈ male,female

• height ∈ [0,300] centimeters

• hair ∈ brown, black, blond, red, green

• 3240 men in the data set

• 6760 women in the data set

Under the assumptions necessary for Naive Bayes (not the distributional assumptions youmight naturally or intuitively make about the dataset) answer each question with T or Fand provide a one sentence explanation of your answer:

(a) [2 pts.] T or F: As height is a continuous valued variable, Naive Bayes is not appropriatesince it cannot handle continuous valued variables.

Solution: False. Naive Bayes can handle both continuous and discrete values as longas the appropriate distributions are used for conditional probabilities. For example,Gaussian for continuous and Bernoulli for discrete

(b) [2 pts.] T or F: Since there is not a similar number of men and women in the dataset,Naive Bayes will have high test error.

Solution: False. Since the data was randomly split, the same proportion of male andfemale will be in the training and testing sets. Thus this discrepancy will not affecttesting error.

(c) [2 pts.] T or F: P (height|sex, hair) = P (height|sex).

Solution: True. This results from the conditional independence assumption required forNaive Bayes.

(d) [2 pts.] T or F: P (height, hair|sex) = P (height|sex)P (hair|sex).

Solution: True. This results from the conditional independence assumption required forNaive Bayes.

1.2 Maximum Likelihood Estimation (MLE)

Assume we have a random sample that is Bernoulli distributed X1, . . . , Xn ∼ Bernoulli(θ).We are going to derive the MLE for θ. Recall that a Bernoulli random variable X takesvalues in 0, 1 and has probability mass function given by

P (X; θ) = θX(1− θ)1−X .

Page 3: Midterm Exam Solutions€¦ · The sample complexity bounds discussed in class show that this is rare, but not impossible. 10-601: Machine Learning Page 6 of172/29/2016 ... {2 sentences

10-601: Machine Learning Page 3 of 17 2/29/2016

(a) [2 pts.] Derive the likelihood, L(θ;X1, . . . , Xn).

Solution:

L(θ;X1, . . . , Xn) =n∏i=1

p(Xi; θ)

=n∏i=1

θxi(1− θ)1−xi

= θ∑n

i=1 xi(1− θ)n−∑n

i=1 xi .

Either of the final two steps are acceptable.

(b) [2 pts.] Derive the following formula for the log likelihood:

`(θ;X1, . . . , Xn) =

(n∑i=1

Xi

)log(θ) +

(n−

n∑i=1

Xi

)log(1− θ).

Solution:

l(θ;X1, . . . , Xn) = logL(θ;X1, . . . , Xn)

= log[θ∑n

i=1 xi(1− θ)n−∑n

i=1 xi]

= (n∑i=1

xi) log(θ) + (n−n∑i=1

xi) log(1− θ)

(c) Extra Credit: [2 pts.] Derive the following formula for the MLE: θ =1

n(∑n

i=1Xi).

Solution: To find the MLE we solve ddθ`(θ;X1, . . . , Xn) = 0. The derivative is given by

d

dθ`(θ;X1, . . . , Xn) =

d

[(n∑i=1

xi) log(θ) + (n−n∑i=1

xi) log(1− θ)]

=

∑ni=1 xiθ

− n−∑n

i=1 xi1− θ

Next, we solve ddθ`(θ;X1, . . . , Xn) = 0:∑n

i=1 xiθ

− n−∑n

i=1 xi1− θ

= 0

⇐⇒( n∑i=1

xi

)(1− θ)−

(n−

n∑i=1

xi

)θ = 0

⇐⇒n∑i=1

xi − nθ = 0

⇐⇒ θ =1

n(n∑i=1

Xi).

Page 4: Midterm Exam Solutions€¦ · The sample complexity bounds discussed in class show that this is rare, but not impossible. 10-601: Machine Learning Page 6 of172/29/2016 ... {2 sentences

10-601: Machine Learning Page 4 of 17 2/29/2016

1.3 MAP vs MLE

Answer each question with T or F and provide a one sentence explanation of youranswer:

(a) [2 pts.] T or F: In the limit, as n (the number of samples) increases, the MAP andMLE estimates become the same.

Solution: True. As the number of examples increases, the data likelihood goes to zerovery quickly, while the magnitude of the prior stays the same. In the limit, the priorplays an insignificant role in the MAP estimate and the two estimates will converge.

(b) [2 pts.] T or F: Naive Bayes can only be used with MAP estimates, and not MLEestimates.

Solution: False. In Naive Bayes we need to estimate the distribution of each feature Xi

given the label Y . Any technique for estimating the distribution can be used, includingboth the MLE and the MAP estimate.

1.4 Probability

Assume we have a sample space Ω. Answer each question with T or F. No justificationis required.

(a) [1 pts.] T or F: If events A, B, and C are disjoint then they are independent.

Solution: False. If they are disjoint, i.e. mutually exclusive, they are very dependent!

(b) [1 pts.] T or F: P (A|B) ∝ P (A)P (B|A)

P (A|B). (The sign ‘∝’ means ‘is proportional to’)

Solution: False. P (A|B) =P (A)P (B|A)

P (B)

(c) [1 pts.] T or F: P (A ∪B) ≤ P (A).

Solution: False. P (A ∪B) ≥ P (A)

(d) [1 pts.] T or F: P (A ∩B) ≥ P (A).

Solution: False. P (A ∩B) ≤ P (A)

Page 5: Midterm Exam Solutions€¦ · The sample complexity bounds discussed in class show that this is rare, but not impossible. 10-601: Machine Learning Page 6 of172/29/2016 ... {2 sentences

10-601: Machine Learning Page 5 of 17 2/29/2016

2 Errors, Errors Everywhere [20 pts.]

2.1 True Errors

Consider a classification problem on Rd with distribution D and target function c∗ : Rd →±1. Let S be an iid sample drawn from the distribution D. Answer each question with Tor F and provide a one sentence explanation of your answer:

(a) [4 pts.] T or F: The true error of a hypothesis h can be lower than its training error onthe sample S.

Solution: True. If the sample S happens to favor part of the space where h makesmistakes then the sample error will overestimate the true error. An extreme example iswhen the hypothesis h has true error 0.5, but the training sample S contains a singlesample that h incorrectly classifies.

(b) [4 pts.] T or F: Learning theory allows us to determine with 100% certainty the trueerror of a hypothesis to within any ε > 0 error.

Solution: False. There is always a small chance that the sample S is not representativeof the underlying distribution D, in which case the sample S may have no relationshipto the true error. The sample complexity bounds discussed in class show that this israre, but not impossible.

Page 6: Midterm Exam Solutions€¦ · The sample complexity bounds discussed in class show that this is rare, but not impossible. 10-601: Machine Learning Page 6 of172/29/2016 ... {2 sentences

10-601: Machine Learning Page 6 of 17 2/29/2016

2.2 Training Sample Size

In this problem, we will consider the effect of training sample size n on a logistic regressionclassifier with d features. The classifier is trained by optimizing the conditional log-likelihood.The optimization procedure stops if the estimated parameters perfectly classify the trainingdata or they converge. The following plot shows the general trend for how the training andtesting error change as we increase the sample size n = |S|. Your task in this question isto analyze this plot and identify which curve corresponds to the training and test error.Specifically:

Training set size

Erro

r curve (i)

curve (ii)

(a) [8 pts.] Which curve represents the training error? Please provide 1–2 sentences ofjustification.

Solution: It is easier to correctly classify small training datasets. For example, if thedata contains just a single point, then logistic regression will always have zero trainingerror. On the other hand, we don’t expect a classifier learned from few examples togeneralize well, so for small training sets the true error is large. Therefore, curve (ii)shows the general trend of the training error.

(b) [4 pt.] In one word, what does the gap between the two curves represent?

Solution: The gap between the two curves represents the amount of overfitting.

Page 7: Midterm Exam Solutions€¦ · The sample complexity bounds discussed in class show that this is rare, but not impossible. 10-601: Machine Learning Page 6 of172/29/2016 ... {2 sentences

10-601: Machine Learning Page 7 of 17 2/29/2016

3 Linear and Logistic Regression [20 pts. + 2 Extra Credit]

3.1 Linear regression

Given that we have an input x and we want to estimate an output y, in linear regressionwe assume the relationship between them is of the form y = wx+ b+ ε, where w and b arereal-valued parameters we estimate and ε represents the noise in the data. When the noiseis Gaussian, maximizing the likelihood of a dataset S = (x1, y1), . . . , (xn, yn) to estimatethe parameters w and b is equivalent to minimizing the squared error:

arg minw

n∑i=1

(yi − (wxi + b))2.

Consider the dataset S plotted in Fig. 1 along with its associated regression line. Foreach of the altered data sets Snew plotted in Fig. 3, indicate which regression line (relativeto the original one) in Fig. 2 corresponds to the regression line for the new data set. Writeyour answers in the table below.

Dataset (a) (b) (c) (d) (e)Regression line (b) (c) (b) (a) (a)

Figure 1: An observed data set and its associated regression line.

Figure 2: New regression lines for altered data sets Snew.

Page 8: Midterm Exam Solutions€¦ · The sample complexity bounds discussed in class show that this is rare, but not impossible. 10-601: Machine Learning Page 6 of172/29/2016 ... {2 sentences

10-601: Machine Learning Page 8 of 17 2/29/2016

(a) Adding one outlier to theoriginal data set.

(b) Adding two outliers to the original dataset.

(c) Adding three outliers to the original dataset. Two on one side and one on the otherside.

(d) Duplicating the original data set.

(e) Duplicating the original data set andadding four points that lie on the trajectoryof the original regression line.

Figure 3: New data set Snew.

Page 9: Midterm Exam Solutions€¦ · The sample complexity bounds discussed in class show that this is rare, but not impossible. 10-601: Machine Learning Page 6 of172/29/2016 ... {2 sentences

10-601: Machine Learning Page 9 of 17 2/29/2016

3.2 Logistic regression

Given a training set (xi, yi), i = 1, . . . , n where xi ∈ Rd is a feature vector and yi ∈ 0, 1is a binary label, we want to find the parameters w that maximize the likelihood for thetraining set, assuming a parametric model of the form

p(y = 1|x;w) =1

1 + exp(−wTx).

The conditional log likelihood of the training set is

`(w) =n∑i=1

yi log p(yi, |xi;w) + (1− yi) log(1− p(yi, |xi;w)),

and the gradient is

∇`(w) =n∑i=1

(yi − p(yi|xi;w))xi.

(a) [5 pts.] Is it possible to get a closed form for the parameters w that maximize theconditional log likelihood? How would you compute w in practice?

Solution: There is no closed form expression for maximizing the conditional log likeli-hood. One has to consider iterative optimization methods, such as gradient descent, tocompute w.

(b) [5 pts.] What is the form of the classifier output by logistic regression?

Solution: Given x, we predict y = 1, if p(y = 1|x) ≥ p(y = 0|x). This is reduces toy = 1, if wTx ≥ 0, which is a linear classifier.

(c) [2 pts.] Extra Credit: Consider the case with binary features, i.e, x ∈ 0, 1d ⊂ Rd,where feature x1 is rare and happens to appear in the training set with only label 1.What is w1? Is the gradient ever zero for any finite w? Why is it important to includea regularization term to control the norm of w?

Solution: If a binary feature was active for only label 1 in the training set then, bymaximizing the conditional log likelihood, we will make the weight associated to thatfeature be infinite. This is because, when this feature is observed in the training set,we will want to predict predict 1 irrespective of everything else. This is an undesiredbehaviour from the point of view of generalization performance, as most likely we donot believe this rare feature to have that much information about class 1. Most likely, itis spurious co-occurrence. Controlling the norm of the weight vector will prevent thesepathological cases.

Page 10: Midterm Exam Solutions€¦ · The sample complexity bounds discussed in class show that this is rare, but not impossible. 10-601: Machine Learning Page 6 of172/29/2016 ... {2 sentences

10-601: Machine Learning Page 10 of 17 2/29/2016

4 SVM, Perceptron and Kernels [20 pts. + 4 Extra Credit]

4.1 True or False

Answer each of the following questions with T or F and provide a one line justification.

(a) [2 pts.] Consider two datasets D(1) and D(2) where D(1) = (x(1)1 , y(1)1 ), ..., (x

(1)n , y

(1)n )

and D(2) = (x(2)1 , y(2)1 ), ..., (x

(2)m , y

(2)m ) such that x

(1)i ∈ Rd1 , x

(2)i ∈ Rd2 . Suppose d1 > d2

and n > m. Then the maximum number of mistakes a perceptron algorithm will makeis higher on dataset D(1) than on dataset D(2).

Solution: False. The maximum number of mistakes made by a perceptron is dependenton the margin and radius of the training data, not its dimension or size. The maximummistake a perceptron will make is (R

γ)2.

(b) [2 pts.] Suppose φ(x) is an arbitrary feature mapping from input x ∈ X to φ(x) ∈ RN

and let K(x, z) = φ(x) · φ(z). Then K(x, z) will always be a valid kernel function.

Solution: True. K is a kernel if it is an inner product after applying some featuretransformation.

(c) [2 pts.] Given the same training data, in which the points are linearly separable, themargin of the decision boundary produced by SVM will always be greater than or equalto the margin of the decision boundary produced by Perceptron.

Solution: True. SVM explicitly maximizes margin; Perceptron does not differentiatebetween decision boundaries as long as they lie within the margin of the training data.

4.2 Multiple Choice

(a) [3 pt.] If the data is linearly separable, SVM minimizes ‖w‖2 subject to the constraints∀i, yiw · xi ≥ 1. In the linearly separable case, which of the following may happen to thedecision boundary if one of the training samples is removed? Circle all that apply.

• Shifts toward the point removed Yes

• Shifts away from the point removed No

• Does not change Yes

(b) [3 pt.] Recall that when the data are not linearly separable, SVM minimizes ‖w‖2 +C∑

i ξi subject to the constraint that ∀i, yiw · xi ≥ 1 − ξi and ξi ≥ 0. Which of thefollowing may happen to the size of the margin if the tradeoff parameter C is increased?Circle all that apply.

• Increases No

• Decreases Yes

Page 11: Midterm Exam Solutions€¦ · The sample complexity bounds discussed in class show that this is rare, but not impossible. 10-601: Machine Learning Page 6 of172/29/2016 ... {2 sentences

10-601: Machine Learning Page 11 of 17 2/29/2016

• Remains the same Yes

Proof of part (b):

Let w∗0 = argmin ‖w‖2 + c0∑

i ξi and let w∗1 = argmin ‖w‖2 + c1∑

i ξi. Let c1 > c0. Weneed ‖w∗1‖2 ≥ ‖w∗0‖2. Define ξi(0) to be the slack variables under w∗0 and ξi(1) to be theslack variables under w∗1.

We first show that for any ‖w′‖2 < ‖w∗0‖2,∑

i ξ′i >

∑i ξi(0) where ξ′i are the slack

variables under w′.

By contradiction, assume ‖w′‖2 < ‖w∗0‖2 and∑

i ξ′i ≤

∑i ξi(0). Then, ‖w′‖2 + c0

∑i ξ′i <

‖w∗0‖2 + c0∑

i ξi(0) and w∗0 6= argmin ‖w‖2 + c0∑

i ξi.

Thus ∀‖w′‖2 ≤ ‖w∗0‖2,∑

i ξ′i ≥

∑i ξi(0).

Next, we show that if w∗0 = argmin ‖w‖2 + c0∑

i ξi and w∗1 = argmin ‖w‖2 + c1∑

i ξi,then ‖w∗1‖2 ≥ ‖w∗0‖2.By contradiction, assume ‖w∗1‖2 < ‖w∗0‖2. Since w∗0 = argmin ‖w‖2 + c0

∑i ξi:

‖w∗0‖2 + c0∑i

ξi(0) ≤ ‖w∗1‖2 + c0∑i

ξi(1)

Since c1 > c0 and∑

i ξi(1) >∑

i ξi(0), then

‖w∗0‖2 + c1∑i

ξi(0) < ‖w∗1‖2 + c1∑i

ξi(1)

But,

w∗1 = argmin ‖w‖2 + c1∑i

ξi

This yields a contradiction. Thus ‖w∗1‖2 ≥ ‖w∗0‖2.

4.3 Analysis

(a) [4 pts.] In one or two sentences, describe the benefit of using the Kernel trick.

Solution: Allows mapping features into higher dimensional space but avoids the extracomputational costs of mapping into higher dimensional feature space explicitly.

(b) [4 pt.] The concept of margin is essential in both SVM and Perceptron. Describe why alarge margin separator is desirable for classification.Solution: Separators with large margin will have low generalization errors with highprobability.

(c) [4 pts.] Extra Credit: Consider the dataset in Fig. 4. Under the SVM formulation insection 4.2(a),

(1) Draw the decision boundary on the graph.

Page 12: Midterm Exam Solutions€¦ · The sample complexity bounds discussed in class show that this is rare, but not impossible. 10-601: Machine Learning Page 6 of172/29/2016 ... {2 sentences

10-601: Machine Learning Page 12 of 17 2/29/2016

(2) What is the size of the margin?

(3) Circle all the support vectors on the graph.

Solution: x2 − 2.5 = 0. The size of margin is 0.5. Support vectors are x2, x3, x6, x7.

Figure 4: SVM toy dataset

Page 13: Midterm Exam Solutions€¦ · The sample complexity bounds discussed in class show that this is rare, but not impossible. 10-601: Machine Learning Page 6 of172/29/2016 ... {2 sentences

10-601: Machine Learning Page 13 of 17 2/29/2016

5 Learning Theory [20 pts.]

5.1 True or False

Answer each of the following questions with T or F and provide a one line justification.

(a) [3 pts.] T or F: It is possible to label 4 points in R2 in all possible 24 ways via linearseparators in R2.

Solution: F. The VC dimension of linear separator in R2 is 3, hence it cannot shattera set of size 4 in all possible ways.

(b) [3 pts.] T or F: To show that the VC-dimension of a concept class H (containingfunctions from X to 0, 1) is d, it is sufficient to show that there exists a subset of Xwith size d that can be labeled by H in all possible 2d ways.

Solution: F. This is only a necessary condition. We also need to show that no subsetof X with size d+ 1 can be shattered by H.

(c) [3 pts.] T or F: The VC dimension of a finite concept class H is upper bounded bydlog2 |H|e.Solution: T. For any finite set S, if H shatters S, then H at least needs to have 2|S|

elements, which implies |S| ≤ dlog2 |H|e.

(d) [3 pts.] T or F: The VC dimension of a concept class with infinite size is also infinite.

Solution: F. Consider all the half-spaces in R2, which has infinite cardinality but theVC dimension is 3.

(e) [3 pts.] T or F: For every pair of classes, H1, H2, if H1 ⊆ H2 and H1 6= H2, thenVCdim(H1) < VCdim(H2) (note that this is a strict inequality).

Solution: F. Let H1 be the collection of all the half-spaces in R2 with finite slopes andlet H2 be the collection of all the half-spaces in R2. Clearly H1 ⊆ H2 and H1 6= H2, butV C(H1) = V C(H2) = 3.

(f) [3 pts.] T or F: Given a realizable concept class and a set of training instances, aconsistent learner will output a concept that achieves 0 error on the training instances.

Solution: T. Since the concept class is realizable, then the consistent learner can outputthe oracle labeler by definition, which is guaranteed to achieve 0 error on the trainingset.

Page 14: Midterm Exam Solutions€¦ · The sample complexity bounds discussed in class show that this is rare, but not impossible. 10-601: Machine Learning Page 6 of172/29/2016 ... {2 sentences

10-601: Machine Learning Page 14 of 17 2/29/2016

5.2 VC dimension

Briefly explain in 2–3 sentences the importance of sample complexity and VC dimensionin learning with generalization guarantees.

Solution: Sample complexity guarantees quantify how many training samples we needto see from the underlying data distribution D in order to guarantee that uniformly forall hypotheses in the class of functions under consideration we have that their empiricalerror rates are close to their true errors. This is important because we care abut findinga hypothesis of small true error, but we can only optimize over a fixed training sample.VC bounds are one kind of sample complexity guarantee, where the bound depends on theVC-dimension of the hypothesis class, and they are particularly useful when the class offunctions is infinite.

Page 15: Midterm Exam Solutions€¦ · The sample complexity bounds discussed in class show that this is rare, but not impossible. 10-601: Machine Learning Page 6 of172/29/2016 ... {2 sentences

10-601: Machine Learning Page 15 of 17 2/29/2016

6 Extra Credit: Neural Networks [6 pts.]

In this problem we will use a neural network to classify the crosses (×) from the circles () inthe simple dataset shown in Figure 5a. Even though the crosses and circles are not linearlyseparable, we can break the examples into three groups, S1, S2, and S3 (shown in Figure 5a)so that S1 is linearly separable from S2 and S2 is linearly separable from S3. We will exploitthis fact to design weights for the neural network shown in Figure 5b in order to correctlyclassify this training set. For all nodes, we will use the threshold activation function

φ(z) =

1 z > 00 z ≤ 0.

0 1 2 3 4 50

1

2

3

4

5

x1

x2S1

S2

S3

(a) The dataset with groups S1, S2, and S3.

y

h1 h2

x1 x2

w11 w21w12 w22

w31w32

(b) The neural network architecture

Figure 5

0 1 2 3 4 50

1

2

3

4

5

x1

x2

(a) Set S2 and S3

0 1 2 3 4 50

1

2

3

4

5

x1

x2

(b) Set S1 and S2

0 1 2 3 4 50

1

2

3

4

5

x1

x2

(c) Set S1, S2 and S3

Figure 6: NN classification.

Page 16: Midterm Exam Solutions€¦ · The sample complexity bounds discussed in class show that this is rare, but not impossible. 10-601: Machine Learning Page 6 of172/29/2016 ... {2 sentences

10-601: Machine Learning Page 16 of 17 2/29/2016

(a) First we will set the parameters w11, w12 and b1 of the neuron labeled h1 so that itsoutput h1(x) = φ(w11x1 + w12x2 + b1) forms a linear separator between the sets S2 andS3.

(1) [1 pt.] On Fig. 6a, draw a linear decision boundary that separates S2 and S3.

(2) [1 pt.] Write down the corresponding weights w11, w12, and b1 so that h1(x) = 0 forall points in S3 and h1(x) = 1 for all points in S2.

Solution: w11 = −1, w12 = 0, b1 = 3. With these parameters, we have w11x1 +w22x2 + b1 > 0 if and only if −x1 > −3, which is equivalent to x1 < 3.

(b) Next we set the parameters w21, w22 and b2 of the neuron labeled h2 so that its outputh2(x) = φ(w21x1 + w22x2 + b2) forms a linear separator between the sets S1 and S2.

(1) [1 pt.] On Fig. 6b, draw a linear decision boundary that separates S1 and S2.

(2) [1 pt.] Write down the corresponding weights w21, w22, and b2 so that h2(x) = 0 forall points in S1 and h2(x) = 1 for all points in S2.

Solution: The provided line has a slope of −2 and crosses the x2 axis at the value5. From this, the equation for the region above the line (those points for whichh2(x) = 1)) is given by x2 ≥ −2x1 + 5 or, equivalently, x2 + 2x1 − 5 ≥ 0. Therefore,w21 = 2, w22 = 1, b2 = −5.

(c) Now we have two classifiers h1 (to classify S2 from S3) and h2 (to classify S1 from S2). Wewill set the weights of the final neuron of the neural network based on the results from h1and h2 to classify the crosses from the circles. Let h3(x) = φ

(w31h1(x) +w32h2(x) + b3

).

(1) [1 pt.] Compute w31, w32, b3 such that h3(x) correctly classifies the entire dataset.

Solution: Consider the weights w31 = w32 = 1 and b3 = −1.5. With these weights,h3(x) = 1 if h1(x) + h2(x) ≥ 1.5. For points in S1 and S3 either h1 or h2 is zero, sothey will be classified as 0, as required. For points in S2, both h1 and h2 output 1,so the point is classified as 1. This rule has zero training error.

(2) [1 pt.] Draw your decision boundary in Fig. 6c.

Page 17: Midterm Exam Solutions€¦ · The sample complexity bounds discussed in class show that this is rare, but not impossible. 10-601: Machine Learning Page 6 of172/29/2016 ... {2 sentences

10-601: Machine Learning Page 17 of 17 2/29/2016

Use this page for scratch work