LFD Book Forum (http://book.caltech.edu/bookforum/index.php)
-   Homework 6 (http://book.caltech.edu/bookforum/forumdisplay.php?f=135)
-   -   Homework#6 Q2 (http://book.caltech.edu/bookforum/showthread.php?t=496)

 gaurav.jain@umassmed.edu 05-15-2012 01:24 AM

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.

 sakumar 05-15-2012 08:15 PM

Re: Homework#6 Q2

Quote:
 Originally Posted by gaurav.jain@umassmed.edu (Post 2130) 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.

 gaurav.jain@umassmed.edu 05-21-2012 09:35 PM

Re: Homework#6 Q2

Thank you so much. This was very clear. I got the right answers. :)

 lucifirm 05-23-2012 08:22 AM

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?

 kkkkk 05-23-2012 09:10 AM

Re: Homework#6 Q2

Quote:
 Originally Posted by lucifirm (Post 2395) 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.

 lucifirm 05-23-2012 09:44 AM

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... :(

 kkkkk 05-23-2012 10:04 AM

Re: Homework#6 Q2

Quote:
 Originally Posted by lucifirm (Post 2410) 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.

 lucifirm 05-23-2012 12:30 PM

Re: Homework#6 Q2

Quote:
 Originally Posted by kkkkk (Post 2412) 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! :)

 gah44 08-21-2012 02:33 PM

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.

 All times are GMT -7. The time now is 01:52 AM.

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