LFD Book Forum  

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

Reply
 
Thread Tools Display Modes
  #1  
Old 05-15-2012, 01:24 AM
gaurav.jain@umassmed.edu gaurav.jain@umassmed.edu is offline
Junior Member
 
Join Date: Apr 2012
Location: Worcester, MA
Posts: 3
Default Homework#6 Q2

hi everyone,
Can anyone please explain me how to transform the data using the nonlinear transformation is given by
phi(x1, x2) = (1, x1, x2, x21, x22 , x1x2, |x1 − x2|, |x1 + x2|)

I am just confused how to use that in my code. I mean for the new values which function to use for transformation?

is it x1=x1^2 and x2=x^2 and so on or something else. I am sure i am missing a big concept here. Any help would be great.

Thanks in advance.
Reply With Quote
  #2  
Old 05-15-2012, 08:15 PM
sakumar sakumar is offline
Member
 
Join Date: Apr 2012
Posts: 40
Default Re: Homework#6 Q2

Quote:
Originally Posted by gaurav.jain@umassmed.edu View Post
hi everyone,
Can anyone please explain me how to transform the data using the nonlinear transformation is given by
phi(x1, x2) = (1, x1, x2, x21, x22 , x1x2, |x1 − x2|, |x1 + x2|)

I am just confused how to use that in my code. I mean for the new values which function to use for transformation?

is it x1=x1^2 and x2=x^2 and so on or something else. I am sure i am missing a big concept here. Any help would be great.

Thanks in advance.
There is a typo in the way you have written the vector above. The 4th term is x1^2, the fifth term is x2^2.

But basically you have the right idea. You are given a data vector with two values. Create a larger data vector of 8 terms, seven of which are dependent on the original two values you are given.

In the new vector the first three terms are 1, x1, x2. The remaining 5 terms are obtained by applying "transformations" to x1 and x2. For example, the sixth term is x1*x2.

Then you do linear regression on the new x matrix you have built which is (for the given in.data) an 8x35 matrix. 35 data vectors, each with 8 terms as above.
Reply With Quote
  #3  
Old 05-21-2012, 09:35 PM
gaurav.jain@umassmed.edu gaurav.jain@umassmed.edu is offline
Junior Member
 
Join Date: Apr 2012
Location: Worcester, MA
Posts: 3
Thumbs up Re: Homework#6 Q2

Thank you so much. This was very clear. I got the right answers.
Reply With Quote
  #4  
Old 05-23-2012, 08:22 AM
lucifirm lucifirm is offline
Member
 
Join Date: Apr 2012
Posts: 20
Question Re: Homework#6 Q2

I have a question on the Eout. Should we create a new z or should we use the given test set to compute Eout?

In time, I have used the formula:

E_In_Sample = sum (sign (z*w)~= y)) / N

is this ok for Eout too?
Reply With Quote
  #5  
Old 05-23-2012, 09:10 AM
kkkkk kkkkk is offline
Invited Guest
 
Join Date: Mar 2012
Posts: 71
Default Re: Homework#6 Q2

Quote:
Originally Posted by lucifirm View Post
I have a question on the Eout. Should we create a new z or should we use the given test set to compute Eout?

In time, I have used the formula:

E_In_Sample = sum (sign (z*w)~= y)) / N

is this ok for Eout too?
If I am reading my code correctly, Eout is calculated from out.dta which is the test set. You cant generate new x or z since you do not know the target fn f.
The formula for Ein and Eout has to be the same so that we can compare them, only the set of test points - in or out of sample, differs.
Reply With Quote
  #6  
Old 05-23-2012, 09:44 AM
lucifirm lucifirm is offline
Member
 
Join Date: Apr 2012
Posts: 20
Default Re: Homework#6 Q2

Thanks kkkkk.
I did both cases, either generate new points and also used out.dta (no together, just for for comparison) and I'm using the same formula for E_in and E_out. My E_in is approx. 0.03, but I just can't get E_out to go near 0.08.... I'll check the code again, but it doesn't make sense, it's such a simple formula...
Reply With Quote
  #7  
Old 05-23-2012, 10:04 AM
kkkkk kkkkk is offline
Invited Guest
 
Join Date: Mar 2012
Posts: 71
Default Re: Homework#6 Q2

Quote:
Originally Posted by lucifirm View Post
Thanks kkkkk.
I did both cases, either generate new points and also used out.dta (no together, just for for comparison) and I'm using the same formula for E_in and E_out. My E_in is approx. 0.03, but I just can't get E_out to go near 0.08.... I'll check the code again, but it doesn't make sense, it's such a simple formula...
The code for Ein and Eout is about the same, just make sure you calculate w from the in sample and dont recalculate w using the out sample.
Reply With Quote
  #8  
Old 05-23-2012, 12:30 PM
lucifirm lucifirm is offline
Member
 
Join Date: Apr 2012
Posts: 20
Default Re: Homework#6 Q2

Quote:
Originally Posted by kkkkk View Post
The code for Ein and Eout is about the same, just make sure you calculate w from the in sample and dont recalculate w using the out sample.
Sometimes is best to forget about the problem and later come back to it with you head fresh... I just found out what was wrong...
It doesn't work for small sets of points, so I created a big set with 250 points, just as in the out.dta and, to my surprise... it works! The code had nothing wrong after all. Maybe there was some dirt undeleted variables, or maybe I am just stupid.

Thanks kkkkk!
Reply With Quote
  #9  
Old 08-21-2012, 02:33 PM
gah44 gah44 is offline
Invited Guest
 
Join Date: Jul 2012
Location: Seattle, WA
Posts: 153
Default Re: Homework#6 Q2

My first thought on reading this question, and "What values are closest" was how could two values be closest. When I found the answer, it was reasonably obvious, but there are some possible values where the first is closest for one answer, and the second for a different answer.

It could, instead, ask to round to two decimal places and then choose the appropriate answer.
Reply With Quote
Reply

Tags
hw6 #2

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 11:43 AM.


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.