LFD Book Forum  

Go Back   LFD Book Forum > Course Discussions > Online LFD course > Homework 6

Reply
 
Thread Tools Display Modes
  #1  
Old 08-15-2012, 12:36 PM
invis invis is offline
Senior Member
 
Join Date: Jul 2012
Posts: 50
Default Homework#6 Q3

I have some problems with understanding the question #3.

Ok, we have a formula for linear regression with regularization:
w_{reg} = (Z^T Z- \lambda I)^{-1} Z^T y

But I cant catch this:
"add the term \lambda /N \sum_{i=0}^7 w_i^2 to the squared in sample error"

What w I suppose to use in this formula ? The w without regularization ? And why adding to squared error ?
Reply With Quote
  #2  
Old 08-15-2012, 02:30 PM
yaser's Avatar
yaser yaser is offline
Caltech
 
Join Date: Aug 2009
Location: Pasadena, California, USA
Posts: 1,477
Default Re: Homework#6 Q3

Quote:
Originally Posted by invis View Post
What w I suppose to use in this formula ? The w without regularization ? And why adding to squared error ?
The solution w_{\rm reg} = (Z^T Z+ \lambda I)^{-1} Z^T y (notice the plus sign) comes from solving the case of augmented error where the regularization term is added to the in-sample mean-squared error.
__________________
Where everyone thinks alike, no one thinks very much
Reply With Quote
  #3  
Old 08-16-2012, 03:22 AM
invis invis is offline
Senior Member
 
Join Date: Jul 2012
Posts: 50
Default Re: Homework#6 Q3

Just one more question ... at this time

Why when we computing w_{lin} there is no eye matrix ? We do the same divide to w by Z^T Z w.

But eye matrix appears when we divide (Z^T Z w + \lambda w) by w. That confusing me.
Reply With Quote
  #4  
Old 08-16-2012, 04:34 AM
yaser's Avatar
yaser yaser is offline
Caltech
 
Join Date: Aug 2009
Location: Pasadena, California, USA
Posts: 1,477
Default Re: Homework#6 Q3

Quote:
Originally Posted by invis View Post
Just one more question ... at this time

Why when we computing w_{lin} there is no eye matrix ? We do the same divide to w by Z^T Z w.

But eye matrix appears when we divide (Z^T Z w + \lambda w) by w. That confusing me.
The "divide by" is in fact multiplying by a matrix inverse. In the case of augmented error, in order to put things in terms of a matrix, we write Z^T Z w + \lambda w as Z^T Z w + \lambda I w, then factor out Z^T Z + \lambda I which becomes the matrix to be inverted. In the linear regression case, there is no I term (or you can think of it as \lambda=0 killing that term).
__________________
Where everyone thinks alike, no one thinks very much
Reply With Quote
  #5  
Old 08-20-2012, 08:32 AM
ESRogs ESRogs is offline
Member
 
Join Date: Jul 2012
Posts: 12
Default Re: Homework#6 Q3

In the lecture, the formula for w_{reg} was derived for the case where the weights were being multiplied by Legendre polynomials. Is it still valid when the set of transformations is different, such as those specified in the problem?
Reply With Quote
  #6  
Old 08-20-2012, 01:01 PM
yaser's Avatar
yaser yaser is offline
Caltech
 
Join Date: Aug 2009
Location: Pasadena, California, USA
Posts: 1,477
Default Re: Homework#6 Q3

Quote:
Originally Posted by ESRogs View Post
In the lecture, the formula for w_{reg} was derived for the case where the weights were being multiplied by Legendre polynomials. Is it still valid when the set of transformations is different, such as those specified in the problem?
The formula is valid for any nonlinear transformation into a {\cal Z}.
__________________
Where everyone thinks alike, no one thinks very much
Reply With Quote
  #7  
Old 02-14-2013, 06:16 PM
melipone melipone is offline
Senior Member
 
Join Date: Jan 2013
Posts: 72
Default Re: Homework#6 Q3

Quote:
Originally Posted by yaser View Post
The solution w_{\rm reg} = (Z^T Z+ \lambda I)^{-1} Z^T y (notice the plus sign) comes from solving the case of augmented error where the regularization term is added to the in-sample mean-squared error.
I am confused. Are we supposed to rederive the result of Slide 11?
Reply With Quote
  #8  
Old 02-14-2013, 06:38 PM
yaser's Avatar
yaser yaser is offline
Caltech
 
Join Date: Aug 2009
Location: Pasadena, California, USA
Posts: 1,477
Default Re: Homework#6 Q3

Quote:
Originally Posted by melipone View Post
I am confused. Are we supposed to rederive the result of Slide 11?
No rederivation needed. You can always use the results given in the lectures.
__________________
Where everyone thinks alike, no one thinks very much
Reply With Quote
  #9  
Old 05-13-2013, 04:07 AM
Kekeli Kekeli is offline
Junior Member
 
Join Date: Apr 2013
Posts: 6
Default Re: Homework#6 Q3

My answers for any value of K are order(s) of magnitude higher that the options.

w_reg = (Z^\top Z + λI)^-1 Z^T y

As a Python noob, perhaps someone can confirm that I need the linalg.inv of the first term in parentheses, because we cannot use the pinv method when the weight term is present.
thanks.

Last edited by Kekeli; 05-13-2013 at 05:04 AM. Reason: Realized the upper bound isn't the issue
Reply With Quote
  #10  
Old 05-13-2013, 06:48 PM
jlaurentum jlaurentum is offline
Member
 
Join Date: Apr 2013
Location: Venezuela
Posts: 41
Default Re: Homework#6 Q3

Kekeli:

I don't know about Python, but in R I was using the "chol2inv" function of the "Matrix" library to find the matrix inverse. It turns out this wasn't the right tool for the job. I ended up using "solve" from the base package to find the inverse. So in R, I used the following functions:
  1. t(M) for the transpose of an M matrix
  2. %*% for matrix-matrix or matrix-vector multiplication (or inner product)
  3. diag(...) to generate a diagonal matrix such as needed for the \lambda I part.
  4. solve(M) to find the inverse of an M matrix.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 09:16 PM.


Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
The contents of this forum are to be used ONLY by readers of the Learning From Data book by Yaser S. Abu-Mostafa, Malik Magdon-Ismail, and Hsuan-Tien Lin, and participants in the Learning From Data MOOC by Yaser S. Abu-Mostafa. No part of these contents is to be communicated or made accessible to ANY other person or entity.