Justin Tomlinson
Justin Tomlinson

Reputation: 23

How can I find the subsets of closest points within a set of points?

Problem

Say, for example, I am given a set of points like the following: Original Plot

I want to find the n points with the closest average distance between each other (assuming I know the distance between all points and the total number of points is divisible by n).

Case 1: So going on the example I showed before, let's say n was 3, then I would get something the following with no overlap:

2 Grouped Points

Case 2: If n was 2 then I should get the following:

3 Group Plot

Question: Is there any sort of algorithm that could be used to implement this?

Upvotes: 2

Views: 196

Answers (1)

yatu
yatu

Reputation: 88226

Yes, you could use Scikit-Learn's KMeans algorithm. With this algorithm you precisely have to set n beforehand, so it completely matches you're problem.

Here is the documentation and some examples so you see how to proceed.

Hope this helps.

Upvotes: 1

Related Questions