 LFD Book Forum Linear Regression Classification HW2 Q5/6

#1
 KMoff Junior Member Join Date: Aug 2014 Posts: 2 Linear Regression Classification HW2 Q5/6

Hello, I am having trouble understanding the procedure for binary classification using linear regression.

For ordinary linear regression, as I understand it, we may compute the weights by taking the product pseudo-inverse matrix and the y-vector. In 2D, the line obtained by linear regression is then y = w0 + w1 * x.

Now for the binary case, instead of using the actual y-coordinate value of a data point, we use its binary classification relative to the target function. In this case, the only difference would be that the y-vector which is to be multiplied by the pseudo-inverse matrix consists only of +1 and -1 values.

However, when I try this I get an hypothesis line nearly perpendicular to the target function.

#2
 KMoff Junior Member Join Date: Aug 2014 Posts: 2 Re: Linear Regression Classification HW2 Q5/6

On further investigation. I now think that the y-vector should be the vector whose elements are sign(wf + wf * x) where the target function is y = wf + wf * x. I now have an E_in of about 0.13.
#3
 sandeeps Junior Member Join Date: Sep 2015 Posts: 5 Re: Linear Regression Classification HW2 Q5/6

I get average E_in as ~ 0.13, however the answer is shown as [Answer edited out by admin].
What I have done:
• Generated a random line (target function)
• Generated 100 random points; xn
• Computed yn using target function
• Computed w using the linear regression equation
• Computed Ein = mean(h(x) != yn) i.e. number of values incorrectly estimated by w
• Repeated the above steps 1000 times and averaged Ein

What have I done wrong?
#4 yaser Caltech Join Date: Aug 2009 Location: Pasadena, California, USA Posts: 1,477 Re: Linear Regression Classification HW2 Q5/6

Quote:
 Originally Posted by sandeeps I get average E_in as ~ 0.13, however the answer is shown as [Answer edited out by admin]. What I have done:Generated a random line (target function) Generated 100 random points; xn Computed yn using target function Computed w using the linear regression equation Computed Ein = mean(h(x) != yn) i.e. number of values incorrectly estimated by w Repeated the above steps 1000 times and averaged Ein What have I done wrong?
The steps seem fine. Can you visually check if the hypothesis line makes sense in a few of the runs?

BTW, if you want to discuss specific answers (chosen or excluded), you need to do so in a thread whose title starts with the warning *ANSWER* per the announcement above.
__________________
Where everyone thinks alike, no one thinks very much
#5
 sandeeps Junior Member Join Date: Sep 2015 Posts: 5 Re: Linear Regression Classification HW2 Q5/6

Sorry for posting the answer in the comment.
I had a bug in the target function which was causing erroneous partitioning. Once I fixed it, things started working as expected. Thank you! Thread Tools Show Printable Version Email this Page Display Modes Linear Mode Switch to Hybrid Mode Switch to Threaded 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 10:47 AM. 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.