

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


CMPS 242 Second Homework, Winter 2009 3 Problems, due start of class Tuesday Feb. 3 This homework in to be done in groups of 2-3. Each group members should completely understand the group’s solutions and must acknowledge all sources of inspiration, techniques, and/or helpful ideas (web, people, books, etc.) other than the instructor and class text.
Generate a 10 example training set by picking points uniformly at random from the unit circle and generating labels (y-values) according to C. Calculate the gap of the best homogeneous separating line (this gap is the distance between the separating line and the closest example, and the best separating line is not likely to be C’s decision boundary). Run the Perceptron algorithm and note how many ”mistakes” it makes before finding a consistent hypothesis, and how many iterations through the data are required before it finds a consistent hypotheses.
Perform experiment 1 ten times and sort them by the gap. Do you see a relationship between the gaps and the number of iterations of number of mistakes made? Experiment 2:
Generate a 100 example training set by picking points uniformly at random from the unit circle, with noisy labels. For each example x = (x 1 , x 2 ) in the training set, generate a random number r in [0, 1]. If x 1 + x 2 + 2r − 1 > 0 then set the label of x to 1. If x 1 + x 2 + 2r − 1 ≤ 0 then set the label of x to −1. Also generate two 100 example test sets, one the same way and one without noise.
This generates a noisy version of C where the noise tends to be concentrated around the decision boundary. Run the following version of the perceptron algorithm for 500 iterations where each iteration uses a random point from the training set (rather than cycling through the training set) and save the weight vector wi after each iteration i. Compare how well the following prediction rules perform on the test sets.
(a) Last hypothesis: predict on x with sign(w 500 · x), using the hypotheses from the last iteration. (b) Voted hypothesis: predict on x using the majority of the wi, i.e. sign
(∑ 500 i=1 sign(wi^ ·^ x)
) . (c) Longest survivor: Each w values is created on some iteration t, predicts correctly for a while, and then makes a mistake at some later iteration t′. The survival time of w is t′^ − t. Let w` be the longest surviving hypothesis from the 500 iterations (pick the first one in case of ties, and assume that the last w makes an incorrect prediction on iteration 501).
Create 10 different training and testing sets, and run the perceptron algorithm on each training set. How well do each of the three prediction rules do on the test sets?
probability x has class 1 = p 1 (x|w) =
exp w · x 1 + exp w · x
and p 0 (x|w) = 1 − p 1 (x|w). Show that this is equivalent to w · x giving the log-odds:
ln
p 1 (x|w) p 0 (x|w)
= w · x.
Recommended exercises (not to be turned in):