

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!


Machine Learning (CS 5350/CS 6350) Due 15 Feb 2007
Note: Please submit the written aspects of assignments in postscript or PDF format only. I highly recom- mend you use LATEX to prepare the assignments. A solution will be posted here after the due date. See http://www.cs.utah.edu/classes/cs5350/handin.html for handin instructions.
Complete the following exercise from PRML: 14.11 (only for entropy, not for Gini index).
Bonus: 14.8.
There are two parts to the programming part for this assignment. The first part involves implemented a k-nearest-neighbor classifier (CS6350 students have a little additional work here). The second part involves downloading and running other peopleās software to get familiar with standard software/data-formats.
Part I:
Implement a k-nearest neighbor classifier, with k as a parameter. Apply this classifier to both the data set from homework 1 as well as the new data set for this assignment (the new data set is a multiclass classification data set, so your implementation will need to accomodate this).
Allow k to range over all integers in [1, 20] and plot development and test error as a function of k. At which value of k is development error minimized? At which value of k is test error minimized? Rerun the averaged perceptron on both data sets (you can either use your implementation or mine) and find the iteration at which the development error is minimized. Look at the test error on this iteration. How does this compare to the kNN performance? Which model would you choose to use on these two data sets? You should hand in error plots for kNN and for the perceptron, together with answers to the questions from this paragraph.
Part II:
In this part, we will experiment using other peopleās software, so the programming aspect of this part will just be to write some short scripts for converting data formats. The two software packages we will use are
HW2: Non-linear models 2
libSVM http://www.csie.ntu.edu.tw/~cjlin/libsvm/ (which, not surprisingly, implements support vector machines) and FastDT http://hal3.name/FastDT (a decision tree implementation). You can either download and install these yourself, or you can use the version I have installed on CADE (in ~cs5350/bin, the libSVM executables are svm-train and svm-predict, while the FastDT executable is FastDT).
The libSVM file format is one-example-per-line. The first column is the class (for binary this should be ā 1 or 1; for multiclass this should be a number 0, 1 , 2 ,... ). The remaining columns have format D:N , where D is a feature number and N is the feature value. I.e., our matlab format might have a row like:
The corresponding libSVM line would be something like:
Note that we could exclude feature 5 because its value was zero. The features must appear sorted.
Using the same data set as from HW1, train the following SVMs (using just the training data): a linear SVM, a quadratic SVM, a cubic SVM and an RBF SVM. For each, try different values of C ranging in
CS6350 Students only... (the following is bonus for CS5350)
Now, play around with FastDT. This software only allows binary problems (this is fine) but also only allows binary features! The format for a single example is:
class f1 f2 f5 f
Here, class should be either 0 or 1. The existence of f1,f2,f5,f7 means that these five features have value 1; any feature that doesnāt appear is assumed to have value zero.
You will need to convert the real-valued features from the data sets to binary features. In order to do this, first normalize each feature so that it only has range [0, 1] on the training data (note that it may still be outside this range on the development or test data). Replace each real-valued feature with eight binary features: is the value above/below 0.2, above/below 0.4, 0.6, or 0.8. The features can be any strings. Suppose that after normalization, the example from above were something like ā1ā0.2ā0.75ā0.1ā0.9ā0.6. Then, the FastDT input might look something like:
0 f1>=0.2 f1<0.4 f1<0.6 f1<0.8 f2>=0.2 f2>=0.4 f2>=0.6 f2<0. f3<0.2 f3<0.4 f3<0.5 f3<0.8 f4>=0.2 f4>=0.4 f4>=0.6 f4>=0. f5>=0.2 f5>=0.4 f5>=0.6 f5<0.
(But obviously without the line breaks.)
Now, train four decision trees, each with a different maximum tree depth (command line option -maxd). Use depths 5, 10, 15 and 20. Compare the performance of this on develoment and test data. Between the SVMs and the decision tree, which tends to perform best overall?