LFD Book Forum Homework#6 Q2
 User Name Remember Me? Password
 Register FAQ Calendar Mark Forums Read

 Thread Tools Display Modes
#1
05-15-2012, 01:24 AM
 gaurav.jain@umassmed.edu Junior Member Join Date: Apr 2012 Location: Worcester, MA Posts: 3
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.
#2
05-15-2012, 08:15 PM
 sakumar Member Join Date: Apr 2012 Posts: 40
Re: Homework#6 Q2

Quote:
 Originally Posted by gaurav.jain@umassmed.edu 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.
#3
05-21-2012, 09:35 PM
 gaurav.jain@umassmed.edu Junior Member Join Date: Apr 2012 Location: Worcester, MA Posts: 3
Re: Homework#6 Q2

Thank you so much. This was very clear. I got the right answers.
#4
05-23-2012, 08:22 AM
 lucifirm Member Join Date: Apr 2012 Posts: 20
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?
#5
05-23-2012, 09:10 AM
 kkkkk Invited Guest Join Date: Mar 2012 Posts: 71
Re: Homework#6 Q2

Quote:
 Originally Posted by lucifirm 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.
#6
05-23-2012, 09:44 AM
 lucifirm Member Join Date: Apr 2012 Posts: 20
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...
#7
05-23-2012, 10:04 AM
 kkkkk Invited Guest Join Date: Mar 2012 Posts: 71
Re: Homework#6 Q2

Quote:
 Originally Posted by lucifirm 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.
#8
05-23-2012, 12:30 PM
 lucifirm Member Join Date: Apr 2012 Posts: 20
Re: Homework#6 Q2

Quote:
 Originally Posted by kkkkk 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!
#9
08-21-2012, 02:33 PM
 gah44 Invited Guest Join Date: Jul 2012 Location: Seattle, WA Posts: 153
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.

 Tags hw6 #2

 Thread Tools Display Modes Linear Mode

 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 Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home General     General Discussion of Machine Learning     Free Additional Material         Dynamic e-Chapters         Dynamic e-Appendices Course Discussions     Online LFD course         General comments on the course         Homework 1         Homework 2         Homework 3         Homework 4         Homework 5         Homework 6         Homework 7         Homework 8         The Final         Create New Homework Problems Book Feedback - Learning From Data     General comments on the book     Chapter 1 - The Learning Problem     Chapter 2 - Training versus Testing     Chapter 3 - The Linear Model     Chapter 4 - Overfitting     Chapter 5 - Three Learning Principles     e-Chapter 6 - Similarity Based Methods     e-Chapter 7 - Neural Networks     e-Chapter 8 - Support Vector Machines     e-Chapter 9 - Learning Aides     Appendix and Notation     e-Appendices

All times are GMT -7. The time now is 08:36 PM.

 Contact Us - LFD Book - Top

Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2021, 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.