Starting from:

$25

ML-Homework 3 Perceptron Solved

(Perceptron. Implement the Perceptron algorithm (in the file name perceptron.py). Do not forget to normalize the samples to have unit length (i.e., kxik = 1).

(a)    Use only the first n = 5,10,50,100,500,1000,5000 samples as an input to Perceptron. For each n, run Perceptron 100 times, each time with a different random order of inputs, and calculate the accuracy of the classifier on the test set of each run. You should therefore have 100 accuracy measurement per n. Print a table showing, for each n, the mean accuracy across the 100 runs, as well as the 5% and 95% percentiles of the accuracies obtained.

(b)   The weight vector w, returned by Percepton, can be viewed as a matrix of weights, with which we multiply each respective pixel in the input image. Run Perceptron on the entire training set, and show w, as a 28×28 image, for example with imshow(reshape(image, (28, 28)), interpolation=’nearest’). Give an intuitive interpretation of this image.

(c)    Calculate the accuracy of the classifier trained on the full training set, applied on the test set.

(d)   Choose one (or two) of the samples in the test set that was misclassified by Perceptron (with the full training set) and show it as an image (show the unscaled images). Can you explain why it was misclassified?

More products