LFD Book Forum  

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

Reply
 
Thread Tools Display Modes
  #1  
Old 04-08-2013, 01:15 PM
ykulkarni ykulkarni is offline
Junior Member
 
Join Date: Apr 2013
Posts: 2
Default Question about Qs 7

I haven't seen anyone else raise this question in the forum, so its probably something obvious that I'm missing to see. The question says:

"In each run, choose a random line in the plane as your target function f (do this by taking two random, uniformly distributed points in [-1,1] x [-1,1] and taking the line passing through them), where one side of the line maps to +1 and the other maps to 1."

Given a line, how do I figure out the function which separates points into +1 or -1 based on which side of the line they fall on?
Reply With Quote
  #2  
Old 04-08-2013, 04:00 PM
yaser's Avatar
yaser yaser is offline
Caltech
 
Join Date: Aug 2009
Location: Pasadena, California, USA
Posts: 1,477
Default Re: Question about Qs 7

Quote:
Originally Posted by ykulkarni View Post
I haven't seen anyone else raise this question in the forum, so its probably something obvious that I'm missing to see. The question says:

"In each run, choose a random line in the plane as your target function f (do this by taking two random, uniformly distributed points in [-1,1] x [-1,1] and taking the line passing through them), where one side of the line maps to +1 and the other maps to 1."

Given a line, how do I figure out the function which separates points into +1 or -1 based on which side of the line they fall on?
Hi,

Indeed, one line can represent a function and its negation. Put the equation of the line in the form w_0 x_0 +w_1 x_1 +w_2 x_2 = 0, where x_0=1. The vector {\bf w}=(w_0,w_1,w_2) as well as its negation represent the same line. If you take the function to be {\rm sign}(w_0 x_0 +w_1 x_1 +w_2 x_2), this fixes one of the two functions.
__________________
Where everyone thinks alike, no one thinks very much
Reply With Quote
  #3  
Old 04-08-2013, 04:10 PM
dazemoon dazemoon is offline
Junior Member
 
Join Date: Apr 2013
Posts: 1
Default Re: Question about Qs 7

You have 2 points defining the line, so one simple way is to express the line as y= a*x + b (see e.g. http://en.wikipedia.org/wiki/Linear_...Two-point_form)
then for any point P= (Px, Py) you can verify if Py > a*Px + b so that:
f maps P to 1 if [Py > a*Px + b], otherwise it maps P to -1. Or you can invert the mapping.
Reply With Quote
  #4  
Old 04-08-2013, 05:06 PM
Elroch Elroch is offline
Invited Guest
 
Join Date: Mar 2013
Posts: 143
Default Re: Question about Qs 7

Two other related concepts that you can use relate an arbitrary two points A and B on the line to a third point C not on it. The first is the sine of the angle between AB and AC (which can never be zero, but which can have either sign), and the second is the cross product of AB and AC (which will always be perpendicular to the plane, but which can be either up or down).
Reply With Quote
  #5  
Old 04-09-2013, 11:58 AM
ykulkarni ykulkarni is offline
Junior Member
 
Join Date: Apr 2013
Posts: 2
Default Re: Question about Qs 7

Quote:
Originally Posted by yaser View Post
Hi,

Indeed, one line can represent a function and its negation. Put the equation of the line in the form w_0 x_0 +w_1 x_1 +w_2 x_2 = 0, where x_0=1. The vector {\bf w}=(w_0,w_1,w_2) as well as its negation represent the same line. If you take the function to be {\rm sign}(w_0 x_0 +w_1 x_1 +w_2 x_2), this fixes one of the two functions.
Thank you Professor, this makes it clear to me.

-Yogi
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 01:51 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.