By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,490 Members | 1,417 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,490 IT Pros & Developers. It's quick & easy.

Find closest (m) points using cosine distance - Python

P: 2
I am given n data points in the form of list of tuples like S=[(x1,y1),(x2,y2),(x3,y3),(x4,y4),(x5,y5),..,(xn,yn)] and a point P=(p,q)
My task is to find 5 closest points in S from P. We have to use cosine distance.

Example:

S= [(1,2),(3,4),(-1,1),(6,-7),(0, 6),(-5,-8),(-1,-1)(6,0),(1,-1)]
P= (3,-4)
Output:
(6,-7)
(1,-1)
(6,0)
(-5,-8)
(-1,-1)

I need to write python program for this. I am not getting any idea where to start. Any clues on how to start writing this program.
Jul 13 '19 #1
Share this Question
Share on Google+
2 Replies


Expert 100+
P: 620
There is no Python being used in the above post. Please move to a math forum, or where ever is most appropriate.
Jul 13 '19 #2

P: 2
Hi,
I need to write a python program for the above. Since I dont know where to start on this, I have posted it.
Jul 15 '19 #3

Post your reply

Sign in to post your reply or Sign up for a free account.