[Solved] CSC411 Assignment 3- Robust Regression

$25

File Name: CSC411_Assignment_3-_Robust_Regression.zip
File Size: 357.96 KB

SKU: [Solved] CSC411 Assignment 3- Robust Regression Category: Tag:
5/5 - (1 vote)

In this assignment we will be working with the Boston Housing dataset. This dataset contains 506 entries. Each entry consists of a house price and 13 features for houses within the Boston area. We suggest working in python and using the scikit-learn package to load the data. Starter Code. Starter code written in Python is provided for Question 2.

  1. Robust Regression. One problem with linear regression using squared error loss is that it can be sensitive to outliers. Another loss function we could use is the Huber loss, parameterized by a hyperparameter :

if |a|

) if |a| >

  • Sketch the Huber loss L(y,t) and squared error loss for t = 0, either by hand or using a plotting library. Based on your sketch, why would you expect the Huber loss to be more robust to outliers?
  • Just as with linear regression, assume a linear model:

y = w>x + b.

Give formulas for the partial derivatives L/w and L/b. (We recommend you find a formula for the derivative H0(a), and then give your answers in terms of H0(y t).)

1

CSC411 Fall 2018 Homework 3

  • Write Python code to perform (full batch mode) gradient descent on this model. Assume the training dataset is given as a design matrix X and target vector y. Initialize w and b to all zeros. Your code should be vectorized, i.e. you should not have a for loop over training examples or input dimensions. You may find the function where helpful.

Submit your code as q1.py.

  1. Locally Weighted Regression.
    • Given {(x(1),y(1)),..,(x(N),y(N))} and positive weights a(1),,a(N) show that the solution to the weighted least squares problem

w = argmin (1)

is given by the formula

w = XTAXAy (2)

where X is the design matrix (defined in class) and A is a diagonal matrix where Aii =

a(i)

It may help you to review Section 3.1 of the csc321 notes[3].

  • Locally reweighted least squares combines ideas from k-NN and linear regression. For each new test example x we compute distance-based weights for each training example i , computes w = argmin

and predicts y = xTw. Complete the implementation of locally reweighted least

squares by providing the missing parts for q2.py.

Important things to notice while implementing: First, do not invert any matrix, use a linear solver (numpy.linalg.solve is one example). Second, notice that

but if we use B = maxj Aj it is much more numerically stable as

overflows/underflows easily. This is handled automatically in the scipy package with the scipy.misc.logsumexp function[4].

  • Randomly hold out 30% of the dataset as a validation set. Compute the average loss for different values of in the range [10,1000] on both the training set and the validation set. Plot the training and validation losses as a function of (using a log scale for ).
  • How would you expect this algorithm to behave as ? When 0? Is this what actually happened?

2

[1] http://www.cs.toronto.edu/~delve/data/boston/bostonDetail.html

[2] http://scikit-learn.org/stable/modules/generated/sklearn.datasets.load_boston.html

[3] http://www.cs.toronto.edu/~rgrosse/courses/csc321_2018/readings/L02%20Linear%20Regression.pdf

[4] https://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.misc.logsumexp.html

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] CSC411 Assignment 3- Robust Regression
$25