Warning: Declaration of action_plugin_tablewidth::register(&$controller) should be compatible with DokuWiki_Action_Plugin::register(Doku_Event_Handler $controller) in /s/bach/b/class/cs545/public_html/fall16/lib/plugins/tablewidth/action.php on line 93
assignments:assignment3 [CS545 fall 2016]

User Tools

Site Tools


assignments:assignment3

This is an old revision of the document!



Warning: Declaration of syntax_plugin_comment::handle($match, $state, $pos, &$handler) should be compatible with DokuWiki_Syntax_Plugin::handle($match, $state, $pos, Doku_Handler $handler) in /s/bach/b/class/cs545/public_html/fall16/lib/plugins/comment/syntax.php on line 19

Warning: Declaration of syntax_plugin_comment::render($mode, &$renderer, $data) should be compatible with DokuWiki_Syntax_Plugin::render($format, Doku_Renderer $renderer, $data) in /s/bach/b/class/cs545/public_html/fall16/lib/plugins/comment/syntax.php on line 19

Warning: Declaration of syntax_plugin_fontsize2::handle($match, $state, $pos, &$handler) should be compatible with DokuWiki_Syntax_Plugin::handle($match, $state, $pos, Doku_Handler $handler) in /s/bach/b/class/cs545/public_html/fall16/lib/plugins/fontsize2/syntax.php on line 116

Warning: Declaration of syntax_plugin_fontsize2::render($mode, &$renderer, $data) should be compatible with DokuWiki_Syntax_Plugin::render($format, Doku_Renderer $renderer, $data) in /s/bach/b/class/cs545/public_html/fall16/lib/plugins/fontsize2/syntax.php on line 116

Warning: Declaration of syntax_plugin_tablewidth::handle($match, $state, $pos, &$handler) should be compatible with DokuWiki_Syntax_Plugin::handle($match, $state, $pos, Doku_Handler $handler) in /s/bach/b/class/cs545/public_html/fall16/lib/plugins/tablewidth/syntax.php on line 57

Warning: Declaration of syntax_plugin_tablewidth::render($mode, &$renderer, $data) should be compatible with DokuWiki_Syntax_Plugin::render($format, Doku_Renderer $renderer, $data) in /s/bach/b/class/cs545/public_html/fall16/lib/plugins/tablewidth/syntax.php on line 57

Warning: Declaration of syntax_plugin_mathjax_protecttex::render($mode, &$renderer, $data) should be compatible with DokuWiki_Syntax_Plugin::render($format, Doku_Renderer $renderer, $data) in /s/bach/b/class/cs545/public_html/fall16/lib/plugins/mathjax/syntax/protecttex.php on line 157

Assignment 3

Due: 10/3 at 11:59pm.

Preliminaries

In this assignment you will explore ridge regression applied to the task of predicting wine quality. You will use the wine quality dataset from the UCI machine learning repository, and compare accuracy obtained using ridge regression to the results from a recent publication (if you have trouble accessing that version of the paper, here's a link to a preprint. The wine data is composed of two datasets - one for white wines, and one for reds. In this assignment perform all your analyses on just the red wine data.

The features for the wine dataset are not standardized, so make sure you do this, especially since we are going to consider the magnitude of the weight vector (recall that standardization entails subtracting the mean and then dividing by the standard deviation for each feature; you can use the Numpy statistics module to perform the required calculations).

Part 1

Implement ridge regression in a class called RidgeRegression that implements the classifier API, i.e. fit and predict methods with the same signature as the classifiers you implemented in the previous assignment. Also implement functions for computing the following measures of error:

  • The Root Mean Square Error (RMSE).
  • The Maximum Absolute Deviation (MAD).

For a hypothesis $h$, they are defined as follows:

$$RMSE(h) = \sqrt{\frac{1}{N}\sum_{i=1}^N (y_i - h(\mathbf{x}_i))^2}$$

and

$$MAD(h) = \frac{1}{N}\sum_{i=1}^N |y_i - h(\mathbf{x}_i)|.$$

With the code you just implemented, your next task is to explore the dependence of error on the value of the regularization parameter, $\lambda$. In what follows set aside 30% of the data as a test-set, and compute the in-sample error, and the test-set error as a function of the parameter $\lambda$ on the red wine data. Choose the values of $\lambda$ on a logarithmic scale with values 0.01, 0.1, 1, 10, 100, 1000 and plot the RMSE only. Repeat the same experiment where instead of using all the training data, choose 20 random examples out of the training set, and train your model using those 20 examples.

Now answer the following:

  • What is the optimal value of $\lambda$?
  • What observations can you make on the basis of these plots? (The concepts of overfitting/underfitting should be addressed in your answer).
  • Finally, compare the results that you are getting with the published results in the paper linked above. In particular, is the performance you have obtained is comparable to that observed in the paper?

Part 2

Regression Error Characteristic (REC) curves are an interesting way of visualizing regression error as described in the following paper. Write a function that plots the REC curve of a regression method, and plot the REC curve of the best regressor you found in Part 1 of the assignment (i.e. the one that gave the lowest error on the validation set). Plot the REC curve for both the validation set and the training set. What can you learn from this curve that you cannot learn from an error measure such as RMSE or MAD?

Part 3

As we discussed in class, the magnitude of the weight vector can be interpreted as a measure of feature importance. Train a ridge regression classifier on a subset of the dataset that you reserved for training. We will explore the relationship between the magnitude of weight vector components and their relevance to the classification task in several ways. Each feature is associated with a component of the weight vector. It can also be associated with the correlation of that feature with the vector of labels. As we discussed in class, the magnitude of the weight vector can give an indication of feature relevance; another measure of relevance of a feature is its correlation with the labels. To compare the two, create a scatter plot of weight vector components against the Pearson correlation coefficient of the corresponding feature with the labels (again, you can use the Numpy statistics module to compute it). What can you conclude from this plot? The paper ranks features according to their importance using a different approach. Compare your results with what they obtain.

Next, perform the following experiment: Incrementally remove the feature with the lowest absolute value of the weight vector and retrain the ridge regression classifier. Plot RMSE as a function of the number of features that remain on the test set which you have set aside and comment on the results.

Submission

Submit your report via Canvas. Python code can be displayed in your report if it is short, and helps understand what you have done. The sample LaTex document provided in assignment 1 shows how to display Python code. Submit the Python code that was used to generate the results as a file called assignment3.py (you can split the code into several .py files; Canvas allows you to submit multiple files). Typing

$ python assignment3.py

should generate all the tables/plots used in your report.

Grading

A few general guidelines for this and future assignments in the course:

  • Your answers should be concise and to the point.
  • You need to use LaTex to write the report.
  • The report is well structured, the writing is clear, with good grammar and correct spelling; good formatting of math, code, figures and captions (every figure and table needs to have a caption that explains what is being shown).
  • Whenever you use information from the web or published papers, a reference should be provided. Failure to do so is considered plagiarism.

We will take off points if these guidelines are not followed.

  • Always provide a description of the method you used to produce a given result in sufficient detail such that the reader can reproduce your results on the basis of the description. You can use a few lines of python code or pseudo-code.
  • You can provide results in the form of tables, figures or text - whatever form is most appropriate for a given problem. There are no rules about how much space each answer should take. BUT we will take off points if we have to wade through a lot of redundant data.
  • In any machine learning paper there is a discussion of the results. There is a similar expectation from your assignments that you reason about your results. For example, for the learning curve problem, what can you say on the basis of the observed learning curve?
Grading sheet for assignment 3

Part 1:  50 points.
(15 points):  Ridge regression is correctly implemented.
(15 points):  Plots of RMSE as a function of lambda are generated correctly.
(20 points):  Discussion of the results

Part 2:  25 points.
(15 points):  REC curves are generated correctly
(10 points):  discussion of REC curves

Part 3:  25 points.
(20 points):  Weight vector analysis
( 5 points):  Comparison to the published results
assignments/assignment3.1474385590.txt.gz ยท Last modified: 2016/09/20 09:33 by asa