Ask Your Question
2

K means question

asked 2015-08-14 13:18:51 -0600

mrzl gravatar image

updated 2015-12-21 03:05:28 -0600

Hey everybody,

I'm currently in the process of clustering a set of points into different sections. Though, the k means algorithm requires me to explicitly set the number of clusters to divide the set of points in. Is there an alternative algorithm, where I can pass in a set of points and a maximum distance, which divides point clusters from each other? What I would like to have returned is a list of clusters of yet unknown size, containing a sub-set of points.

I would be very thankful for any directions.

Thanks, Marcel

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
6

answered 2015-08-14 23:24:38 -0600

berak gravatar image

updated 2015-08-14 23:40:22 -0600

yes, you can use partition with a distance functor:

struct Dist {
    bool operator()(const Point& a, const Point &b) {
           return sqrt((a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y)) < 15;
    }
};

vector<Point> input = ...;
vector<int> labels;

partition(input, labels, Dist());
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-08-14 13:18:51 -0600

Seen: 1,267 times

Last updated: Aug 14 '15